2023-04-13 23:01:48 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2023-04-16 12:38:21 +02:00
|
|
|
import 'package:card_swiper/card_swiper.dart';
|
2023-04-13 23:01:48 +02:00
|
|
|
|
|
|
|
void main() {
|
2023-04-16 12:38:21 +02:00
|
|
|
runApp(MyApp());
|
2023-04-13 23:01:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Flutter Demo',
|
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
),
|
2023-04-16 12:38:21 +02:00
|
|
|
home: MyHomePage(title: 'Flutter Demo Home Page'),
|
2023-04-13 23:01:48 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
final String title;
|
|
|
|
|
2023-04-16 12:38:21 +02:00
|
|
|
MyHomePage({required this.title});
|
|
|
|
|
2023-04-13 23:01:48 +02:00
|
|
|
@override
|
2023-04-16 12:38:21 +02:00
|
|
|
_MyHomePageState createState() => _MyHomePageState();
|
2023-04-13 23:01:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2023-04-16 12:38:21 +02:00
|
|
|
int _selectedIndex = 0;
|
|
|
|
final PageController _pageController = PageController(initialPage: 0);
|
2023-04-13 23:01:48 +02:00
|
|
|
|
2023-04-16 12:38:21 +02:00
|
|
|
void _onItemTapped(int index) {
|
2023-04-13 23:01:48 +02:00
|
|
|
setState(() {
|
2023-04-16 12:38:21 +02:00
|
|
|
_selectedIndex = index;
|
|
|
|
_pageController.animateToPage(index,
|
|
|
|
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
|
2023-04-13 23:01:48 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(widget.title),
|
|
|
|
),
|
2023-04-16 12:38:21 +02:00
|
|
|
body: PageView(
|
|
|
|
controller: _pageController,
|
|
|
|
children: _widgetOptions,
|
|
|
|
onPageChanged: (int index) {
|
|
|
|
setState(() {
|
|
|
|
_selectedIndex = index;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
|
|
items: const <BottomNavigationBarItem>[
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.home),
|
|
|
|
label: 'Page 1',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.work),
|
|
|
|
label: 'Page 2',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.school),
|
|
|
|
label: 'Page 3',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
currentIndex: _selectedIndex,
|
|
|
|
onTap: _onItemTapped,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static final List<Widget> _widgetOptions = <Widget>[
|
|
|
|
Swiper(
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return const CardContent(
|
|
|
|
title: 'Page 1',
|
|
|
|
description: 'This is page 1',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: 1,
|
|
|
|
loop: false,
|
|
|
|
),
|
|
|
|
Swiper(
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return const CardContent(
|
|
|
|
title: 'Page 2',
|
|
|
|
description: 'This is page 2',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: 1,
|
|
|
|
loop: false,
|
|
|
|
),
|
|
|
|
Swiper(
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return const CardContent(
|
|
|
|
title: 'Page 3',
|
|
|
|
description: 'This is page 3',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: 1,
|
|
|
|
loop: false,
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
class CardContent extends StatelessWidget {
|
|
|
|
final String title;
|
|
|
|
final String description;
|
|
|
|
|
|
|
|
const CardContent({required this.title, required this.description});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SizedBox(
|
|
|
|
height: MediaQuery.of(context).size.height * 0.8,
|
|
|
|
child: Card(
|
|
|
|
margin: const EdgeInsets.all(20.0),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(title, style: const TextStyle(fontSize: 24.0)),
|
|
|
|
const SizedBox(height: 8.0),
|
|
|
|
Text(description, style: const TextStyle(fontSize: 16.0)),
|
|
|
|
],
|
|
|
|
),
|
2023-04-13 23:01:48 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2023-04-16 12:38:21 +02:00
|
|
|
|
2023-04-13 23:01:48 +02:00
|
|
|
}
|
|
|
|
}
|