From abcbce3e954d112811b731b26fdb6af98128f988 Mon Sep 17 00:00:00 2001 From: 98spag Date: Sun, 16 Apr 2023 12:38:21 +0200 Subject: [PATCH] feat: swiper and bottom nav bar first draft --- .dart_tool/package_config.json | 56 ++++---- .dart_tool/package_config_subset | 108 +++++++------- .dart_tool/version | 2 +- android/app/src/main/AndroidManifest.xml | 1 + lib/main.dart | 176 +++++++++++++---------- pubspec.lock | 9 ++ pubspec.yaml | 2 +- 7 files changed, 199 insertions(+), 155 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 253e523..952c81f 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -3,145 +3,151 @@ "packages": [ { "name": "async", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.10.0", "packageUri": "lib/", "languageVersion": "2.18" }, { "name": "boolean_selector", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1", "packageUri": "lib/", "languageVersion": "2.17" }, + { + "name": "card_swiper", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/card_swiper-2.0.4", + "packageUri": "lib/", + "languageVersion": "2.12" + }, { "name": "characters", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/characters-1.2.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.2.1", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "clock", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/clock-1.1.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/clock-1.1.1", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "collection", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/collection-1.17.0", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.17.0", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "cupertino_icons", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.5", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/cupertino_icons-1.0.5", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "fake_async", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/fake_async-1.3.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "flutter", - "rootUri": "file:///usr/local/Caskroom/flutter/3.7.7/flutter/packages/flutter", + "rootUri": "file:///C:/Users/Nutzer/flutter/packages/flutter", "packageUri": "lib/", "languageVersion": "2.17" }, { "name": "flutter_lints", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/flutter_lints-2.0.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.1", "packageUri": "lib/", "languageVersion": "2.17" }, { "name": "flutter_test", - "rootUri": "file:///usr/local/Caskroom/flutter/3.7.7/flutter/packages/flutter_test", + "rootUri": "file:///C:/Users/Nutzer/flutter/packages/flutter_test", "packageUri": "lib/", "languageVersion": "2.17" }, { "name": "js", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/js-0.6.5", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/js-0.6.5", "packageUri": "lib/", "languageVersion": "2.16" }, { "name": "lints", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/lints-2.0.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.0.1", "packageUri": "lib/", "languageVersion": "2.17" }, { "name": "matcher", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/matcher-0.12.13", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.13", "packageUri": "lib/", "languageVersion": "2.18" }, { "name": "material_color_utilities", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/material_color_utilities-0.2.0", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.2.0", "packageUri": "lib/", "languageVersion": "2.13" }, { "name": "meta", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/meta-1.8.0", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.8.0", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "path", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/path-1.8.2", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "sky_engine", - "rootUri": "file:///usr/local/Caskroom/flutter/3.7.7/flutter/bin/cache/pkg/sky_engine", + "rootUri": "file:///C:/Users/Nutzer/flutter/bin/cache/pkg/sky_engine", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "source_span", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/source_span-1.9.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/source_span-1.9.1", "packageUri": "lib/", "languageVersion": "2.14" }, { "name": "stack_trace", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/stack_trace-1.11.0", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/stack_trace-1.11.0", "packageUri": "lib/", "languageVersion": "2.18" }, { "name": "stream_channel", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/stream_channel-2.1.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/stream_channel-2.1.1", "packageUri": "lib/", "languageVersion": "2.14" }, { "name": "string_scanner", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/string_scanner-1.2.0", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/string_scanner-1.2.0", "packageUri": "lib/", "languageVersion": "2.18" }, { "name": "term_glyph", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/term_glyph-1.2.1", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/term_glyph-1.2.1", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "test_api", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/test_api-0.4.16", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.4.16", "packageUri": "lib/", "languageVersion": "2.18" }, { "name": "vector_math", - "rootUri": "file:///Users/bogdan/.pub-cache/hosted/pub.dev/vector_math-2.1.4", + "rootUri": "file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4", "packageUri": "lib/", "languageVersion": "2.14" }, @@ -152,7 +158,7 @@ "languageVersion": "2.19" } ], - "generated": "2023-04-13T20:45:03.708493Z", + "generated": "2023-04-16T10:37:14.046582Z", "generator": "pub", "generatorVersion": "2.19.6" } diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset index dc93315..17af9d8 100644 --- a/.dart_tool/package_config_subset +++ b/.dart_tool/package_config_subset @@ -1,101 +1,105 @@ async 2.18 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/async-2.10.0/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.10.0/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.10.0/lib/ boolean_selector 2.17 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1/lib/ +card_swiper +2.12 +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/card_swiper-2.0.4/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/card_swiper-2.0.4/lib/ characters 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/characters-1.2.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/characters-1.2.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.2.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.2.1/lib/ clock 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/clock-1.1.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/clock-1.1.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/clock-1.1.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/clock-1.1.1/lib/ collection 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/collection-1.17.0/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/collection-1.17.0/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.17.0/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.17.0/lib/ cupertino_icons 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.5/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.5/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/cupertino_icons-1.0.5/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/cupertino_icons-1.0.5/lib/ fake_async 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/fake_async-1.3.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/fake_async-1.3.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1/lib/ flutter_lints 2.17 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/flutter_lints-2.0.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/flutter_lints-2.0.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_lints-2.0.1/lib/ js 2.16 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/js-0.6.5/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/js-0.6.5/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/js-0.6.5/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/js-0.6.5/lib/ lints 2.17 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/lints-2.0.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/lints-2.0.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.0.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/lints-2.0.1/lib/ matcher 2.18 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/matcher-0.12.13/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/matcher-0.12.13/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.13/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.13/lib/ material_color_utilities 2.13 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/material_color_utilities-0.2.0/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/material_color_utilities-0.2.0/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.2.0/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.2.0/lib/ meta 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/meta-1.8.0/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/meta-1.8.0/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.8.0/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.8.0/lib/ path 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/path-1.8.2/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/path-1.8.2/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/path-1.8.2/lib/ source_span 2.14 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/source_span-1.9.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/source_span-1.9.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/source_span-1.9.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/source_span-1.9.1/lib/ stack_trace 2.18 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/stack_trace-1.11.0/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/stack_trace-1.11.0/lib/ stream_channel 2.14 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/stream_channel-2.1.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/stream_channel-2.1.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/stream_channel-2.1.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/stream_channel-2.1.1/lib/ string_scanner 2.18 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/string_scanner-1.2.0/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/string_scanner-1.2.0/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/string_scanner-1.2.0/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/string_scanner-1.2.0/lib/ term_glyph 2.12 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/term_glyph-1.2.1/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/term_glyph-1.2.1/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/term_glyph-1.2.1/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/term_glyph-1.2.1/lib/ test_api 2.18 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/test_api-0.4.16/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/test_api-0.4.16/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.4.16/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.4.16/lib/ vector_math 2.14 -file:///Users/bogdan/.pub-cache/hosted/pub.dev/vector_math-2.1.4/ -file:///Users/bogdan/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/ -ernaehrung -2.19 -file:///Users/bogdan/IdeaProjects/ernaehrung/ -file:///Users/bogdan/IdeaProjects/ernaehrung/lib/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4/ +file:///C:/Users/Nutzer/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4/lib/ sky_engine 2.12 -file:///usr/local/Caskroom/flutter/3.7.7/flutter/bin/cache/pkg/sky_engine/ -file:///usr/local/Caskroom/flutter/3.7.7/flutter/bin/cache/pkg/sky_engine/lib/ +file:///C:/Users/Nutzer/flutter/bin/cache/pkg/sky_engine/ +file:///C:/Users/Nutzer/flutter/bin/cache/pkg/sky_engine/lib/ flutter 2.17 -file:///usr/local/Caskroom/flutter/3.7.7/flutter/packages/flutter/ -file:///usr/local/Caskroom/flutter/3.7.7/flutter/packages/flutter/lib/ +file:///C:/Users/Nutzer/flutter/packages/flutter/ +file:///C:/Users/Nutzer/flutter/packages/flutter/lib/ flutter_test 2.17 -file:///usr/local/Caskroom/flutter/3.7.7/flutter/packages/flutter_test/ -file:///usr/local/Caskroom/flutter/3.7.7/flutter/packages/flutter_test/lib/ +file:///C:/Users/Nutzer/flutter/packages/flutter_test/ +file:///C:/Users/Nutzer/flutter/packages/flutter_test/lib/ +ernaehrung +2.19 +file:///C:/Users/Nutzer/source/repos/Flutter-Ernaehrungsapp/ +file:///C:/Users/Nutzer/source/repos/Flutter-Ernaehrungsapp/lib/ 2 diff --git a/.dart_tool/version b/.dart_tool/version index 7560320..ad64131 100644 --- a/.dart_tool/version +++ b/.dart_tool/version @@ -1 +1 @@ -3.7.9 \ No newline at end of file +3.7.11 \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7bb52fe..631cb46 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -31,4 +31,5 @@ android:name="flutterEmbedding" android:value="2" /> + diff --git a/lib/main.dart b/lib/main.dart index 008fa38..1c4a394 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,115 +1,139 @@ import 'package:flutter/material.dart'; +import 'package:card_swiper/card_swiper.dart'; void main() { - runApp(const MyApp()); + runApp(MyApp()); } class MyApp extends StatelessWidget { - const MyApp({super.key}); - - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. primarySwatch: Colors.blue, ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), + home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - final String title; + MyHomePage({required this.title}); + @override - State createState() => _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { - int _counter = 0; + int _selectedIndex = 0; + final PageController _pageController = PageController(initialPage: 0); - void _incrementCounter() { + void _onItemTapped(int index) { setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; + _selectedIndex = index; + _pageController.animateToPage(index, + duration: const Duration(milliseconds: 300), curve: Curves.easeInOut); }); } @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), - ], - ), + body: PageView( + controller: _pageController, + children: _widgetOptions, + onPageChanged: (int index) { + setState(() { + _selectedIndex = index; + }); + }, + ), + bottomNavigationBar: BottomNavigationBar( + items: const [ + 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, ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. ); } + + static final List _widgetOptions = [ + 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: [ + Text(title, style: const TextStyle(fontSize: 24.0)), + const SizedBox(height: 8.0), + Text(description, style: const TextStyle(fontSize: 16.0)), + ], + ), + ), + ), + ); + + } } diff --git a/pubspec.lock b/pubspec.lock index b2cb69d..0825636 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + card_swiper: + dependency: "direct main" + description: + name: card_swiper + sha256: "0c94c538f47be1dab52d018d4900a7046b4cb0700dc7f95b8628da89d1212b35" + url: "https://pub.dev" + source: hosted + version: "2.0.4" characters: dependency: transitive description: @@ -186,3 +194,4 @@ packages: version: "2.1.4" sdks: dart: ">=2.19.6 <3.0.0" + flutter: ">=0.1.4" diff --git a/pubspec.yaml b/pubspec.yaml index 55f1d5c..678a817 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: flutter: sdk: flutter - + card_swiper : ^2.0.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2