90 lines
2.2 KiB
Dart
90 lines
2.2 KiB
Dart
|
import 'package:card_swiper/card_swiper.dart';
|
||
|
import 'package:ernaehrung/components/cardComponent.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class NavigationScreen extends StatefulWidget {
|
||
|
const NavigationScreen({super.key});
|
||
|
|
||
|
@override
|
||
|
NavigationScreenState createState() => NavigationScreenState();
|
||
|
}
|
||
|
|
||
|
class NavigationScreenState extends State<NavigationScreen> {
|
||
|
int _selectedIndex = 0;
|
||
|
final PageController _pageController = PageController(initialPage: 0);
|
||
|
|
||
|
void _onItemTapped(int index) {
|
||
|
setState(() {
|
||
|
_selectedIndex = index;
|
||
|
_pageController.animateToPage(index,
|
||
|
duration: const Duration(milliseconds: 300), curve: Curves.easeInOut);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
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 CardComponent(
|
||
|
title: 'Page 1',
|
||
|
description: 'This is page 1',
|
||
|
);
|
||
|
},
|
||
|
itemCount: 1,
|
||
|
loop: false,
|
||
|
),
|
||
|
Swiper(
|
||
|
itemBuilder: (BuildContext context, int index) {
|
||
|
return const CardComponent(
|
||
|
title: 'Page 2',
|
||
|
description: 'This is page 2',
|
||
|
);
|
||
|
},
|
||
|
itemCount: 1,
|
||
|
loop: false,
|
||
|
),
|
||
|
Swiper(
|
||
|
itemBuilder: (BuildContext context, int index) {
|
||
|
return const CardComponent(
|
||
|
title: 'Page 3',
|
||
|
description: 'This is page 3',
|
||
|
);
|
||
|
},
|
||
|
itemCount: 1,
|
||
|
loop: false,
|
||
|
),
|
||
|
];
|
||
|
}
|