Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 2 additions & 152 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:marvel_app/screens/main_screen.dart';

void main() {
runApp(const MyApp());
Expand All @@ -16,159 +17,8 @@ class MyApp extends StatelessWidget {
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: PageViewHeros(),
home: MainScreen(),
);
}
}

class PageViewHeros extends StatefulWidget {
const PageViewHeros({Key? key}) : super(key: key);

@override
_PageViewHerosState createState() => _PageViewHerosState();
}

class _PageViewHerosState extends State<PageViewHeros> {
final PageController _pageController = PageController(
viewportFraction: 0.75,
);

int currentPage = 0;

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
alignment: Alignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
padding: const EdgeInsets.only(top: 80),
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage(cities[currentPage].imageBGPath),
fit: BoxFit.cover,
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
top: 50,
),
child: Image.asset(
'assets/images/marvel.png',
height: 50,
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 40.0),
child: Text(
'Choose your hero',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
),
),
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 1.7,
child: PageView.builder(
controller: _pageController,
onPageChanged: (value) => {
setState(
() {
currentPage = value;
},
)
},
itemCount: cities.length,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, int index) {
return AnimatedScale(
scale: index == currentPage ? 1 : 0.8,
duration: const Duration(milliseconds: 300),
child: Container(
//margin: const EdgeInsets.only(left: 12, right: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
image: DecorationImage(
image: ExactAssetImage(cities[index].imagePath),
fit: BoxFit.cover),
),
child: Container(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(25.0),
child: Text(
cities[index].name,
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
),
),
),
),
);
},
),
),
],
)
],
),
);
}
}

class Heros {
final String name;
final String imagePath;
final String imageBGPath;

Heros(this.name, this.imagePath, this.imageBGPath);
}

final List<Heros> cities = [
Heros(
'Capitan',
'assets/images/heros/capitan.jpg',
'assets/images/background/bluebg.png',
),
Heros(
'Deadpool',
'assets/images/heros/dedpool.jpg',
'assets/images/background/redbg.png',
),
Heros(
'Iron man',
'assets/images/heros/iron.jpg',
'assets/images/background/yellowbg.png',
),
Heros(
'Spiderman',
'assets/images/heros/spiderman.jpg',
'assets/images/background/purplebg.png',
),
Heros(
'Dr. Strange',
'assets/images/heros/strange.jpg',
'assets/images/background/greenbg.png',
),
Heros(
'Tanos',
'assets/images/heros/tanos.jpg',
'assets/images/background/redbg.png',
),
Heros(
'Thor',
'assets/images/heros/thor.jpg',
'assets/images/background/bluebg.png',
),
];
8 changes: 8 additions & 0 deletions lib/models/hero.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class MarvelHero {
final String name;
final String description;
final String imagePath;
final String imageBGPath;

MarvelHero(this.name, this.description, this.imagePath, this.imageBGPath,);
}
48 changes: 48 additions & 0 deletions lib/models/models_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@


import 'package:marvel_app/models/hero.dart';

final List<MarvelHero> heros = [
MarvelHero(
'Capitan',
'I am Capitan',
'assets/images/heros/capitan.jpg',
'assets/images/background/bluebg.png',
),
MarvelHero(
'Deadpool',
'I am Deadpool',
'assets/images/heros/dedpool.jpg',
'assets/images/background/redbg.png',
),
MarvelHero(
'Iron man',
'I am Iron man',
'assets/images/heros/iron.jpg',
'assets/images/background/yellowbg.png',
),
MarvelHero(
'Spiderman',
'I am Spiderman',
'assets/images/heros/spiderman.jpg',
'assets/images/background/purplebg.png',
),
MarvelHero(
'Dr. Strange',
'I am Dr. Strange',
'assets/images/heros/strange.jpg',
'assets/images/background/greenbg.png',
),
MarvelHero(
'Tanos',
'I am Tanos',
'assets/images/heros/tanos.jpg',
'assets/images/background/redbg.png',
),
MarvelHero(
'Thor',
'I am Thor',
'assets/images/heros/thor.jpg',
'assets/images/background/bluebg.png',
),
];
87 changes: 87 additions & 0 deletions lib/screens/info_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:marvel_app/models/hero.dart';

class InfoScreen extends StatefulWidget {
const InfoScreen({super.key, required this.hero});

final MarvelHero hero;

@override
State<InfoScreen> createState() => _InfoScreenState();
}

class _InfoScreenState extends State<InfoScreen> {


_backPage(){
Navigator.pop(context);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

использовать линтер, устанавливать возвращаемый тип


@override
Widget build(BuildContext context) {
return Scaffold(
//appBar: AppBar(backgroundColor: Colors.transparent,),
body: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
padding: const EdgeInsets.only(top: 80),
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage(widget.hero.imageBGPath),
fit: BoxFit.cover,
),
),
),
Hero(
tag: widget.hero.name,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage(widget.hero.imagePath),
fit: BoxFit.cover),
),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.hero.name,
style: const TextStyle(
color: Colors.white,
fontSize: 40,
fontWeight: FontWeight.bold),
),
Text(
widget.hero.description,
style: const TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
),
],
),
),
),
),
Padding(
padding: const EdgeInsets.all(18.0),
child: IconButton(
alignment: Alignment.topLeft,
onPressed: () {_backPage();},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tear-off

icon: const Icon(
Icons.arrow_back,
color: Colors.white,
),
),
),
],
),
);
}
}
Loading