Merge pull request 'swiper-bottom-nav-bar' (#1) from swiper-bottom-nav-bar into main
Reviewed-on: #1welcome
commit
78c2415391
|
@ -13,6 +13,12 @@
|
|||
"packageUri": "lib/",
|
||||
"languageVersion": "2.17"
|
||||
},
|
||||
{
|
||||
"name": "card_swiper",
|
||||
"rootUri": "file:///Users/bogdan/.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",
|
||||
|
@ -152,7 +158,7 @@
|
|||
"languageVersion": "2.19"
|
||||
}
|
||||
],
|
||||
"generated": "2023-04-13T20:45:03.708493Z",
|
||||
"generated": "2023-04-17T20:45:45.108623Z",
|
||||
"generator": "pub",
|
||||
"generatorVersion": "2.19.6"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ 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/
|
||||
card_swiper
|
||||
2.12
|
||||
file:///Users/bogdan/.pub-cache/hosted/pub.dev/card_swiper-2.0.4/
|
||||
file:///Users/bogdan/.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/
|
||||
|
@ -84,8 +88,8 @@ 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:///Users/bogdan/IdeaProjects/erna%CC%88hrung/
|
||||
file:///Users/bogdan/IdeaProjects/erna%CC%88hrung/lib/
|
||||
sky_engine
|
||||
2.12
|
||||
file:///usr/local/Caskroom/flutter/3.7.7/flutter/bin/cache/pkg/sky_engine/
|
||||
|
|
|
@ -31,4 +31,5 @@
|
|||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class CardComponent extends StatelessWidget {
|
||||
final String title;
|
||||
final String description;
|
||||
|
||||
const CardComponent({super.key, 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)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
import 'package:ernaehrung/views/navigation/navigationScreen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WelcomePageStateTextFieldState extends StatefulWidget {
|
||||
const WelcomePageStateTextFieldState({super.key});
|
||||
|
||||
@override
|
||||
State<WelcomePageStateTextFieldState> createState() =>
|
||||
_WelcomePageStateTextFieldState();
|
||||
}
|
||||
|
||||
class _WelcomePageStateTextFieldState
|
||||
extends State<WelcomePageStateTextFieldState> {
|
||||
final firstnameTextEditingController = TextEditingController();
|
||||
final secondnameTextEditingController = TextEditingController();
|
||||
final weightTextEditingController = TextEditingController();
|
||||
final heightTextEditingController = TextEditingController();
|
||||
final caloriesTextEditingController = TextEditingController();
|
||||
|
||||
bool isNameVisible = false;
|
||||
bool isSNameVisible = false;
|
||||
bool isWeightVisible = false;
|
||||
bool isHeightVisible = false;
|
||||
bool isCaloriesVisible = false;
|
||||
|
||||
void setNameVisible(bool visibility) {
|
||||
setState(() => isNameVisible = visibility);
|
||||
}
|
||||
|
||||
void setSNameVisible(bool visibility) {
|
||||
setState(() => isSNameVisible = visibility);
|
||||
}
|
||||
|
||||
void setWeightVisible(bool visibility) {
|
||||
setState(() => isWeightVisible = visibility);
|
||||
}
|
||||
|
||||
void setHeightVisible(bool visibility) {
|
||||
setState(() => isHeightVisible = visibility);
|
||||
}
|
||||
|
||||
void setCaloriesVisible(bool visibility) {
|
||||
setState(() => isCaloriesVisible = visibility);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
TextFormField(
|
||||
onChanged: (newText) {
|
||||
if (newText.isNotEmpty) {
|
||||
setNameVisible(true);
|
||||
} else {
|
||||
setNameVisible(false);
|
||||
}
|
||||
},
|
||||
controller: firstnameTextEditingController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Name',
|
||||
border: const OutlineInputBorder(gapPadding: 8),
|
||||
suffixIcon: isNameVisible
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
firstnameTextEditingController.clear();
|
||||
setState(() => isNameVisible = false);
|
||||
},
|
||||
icon: const Icon(Icons.clear))
|
||||
: null,
|
||||
),
|
||||
keyboardType: TextInputType.text,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
TextFormField(
|
||||
onChanged: (newText) {
|
||||
if (newText.isNotEmpty) {
|
||||
setSNameVisible(true);
|
||||
} else {
|
||||
setSNameVisible(false);
|
||||
}
|
||||
},
|
||||
controller: secondnameTextEditingController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Vorname',
|
||||
border: const OutlineInputBorder(gapPadding: 8),
|
||||
suffixIcon: isSNameVisible
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
secondnameTextEditingController.clear();
|
||||
setState(() => isSNameVisible = false);
|
||||
},
|
||||
icon: const Icon(Icons.clear))
|
||||
: null,
|
||||
),
|
||||
keyboardType: TextInputType.text),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
TextFormField(
|
||||
onChanged: (newText) {
|
||||
if (newText.isNotEmpty) {
|
||||
setWeightVisible(true);
|
||||
} else {
|
||||
setWeightVisible(false);
|
||||
}
|
||||
},
|
||||
controller: weightTextEditingController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Gewicht',
|
||||
border: const OutlineInputBorder(gapPadding: 8),
|
||||
suffixIcon: isWeightVisible
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
weightTextEditingController.clear();
|
||||
setState(() => isWeightVisible = false);
|
||||
},
|
||||
icon: const Icon(Icons.clear))
|
||||
: null,
|
||||
),
|
||||
keyboardType: TextInputType.number),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
TextFormField(
|
||||
onChanged: (newText) {
|
||||
if (newText.isNotEmpty) {
|
||||
setHeightVisible(true);
|
||||
} else {
|
||||
setHeightVisible(false);
|
||||
}
|
||||
},
|
||||
controller: heightTextEditingController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Größe',
|
||||
border: const OutlineInputBorder(gapPadding: 8),
|
||||
suffixIcon: isHeightVisible
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
heightTextEditingController.clear();
|
||||
setState(() => isHeightVisible = false);
|
||||
},
|
||||
icon: const Icon(Icons.clear))
|
||||
: null,
|
||||
),
|
||||
keyboardType: TextInputType.number),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
TextFormField(
|
||||
onChanged: (newText) {
|
||||
if (newText.isNotEmpty) {
|
||||
setCaloriesVisible(true);
|
||||
} else {
|
||||
setCaloriesVisible(false);
|
||||
}
|
||||
},
|
||||
controller: caloriesTextEditingController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'gewünschte Kalorienzufuhr',
|
||||
border: const OutlineInputBorder(gapPadding: 8),
|
||||
suffixIcon: isCaloriesVisible
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
caloriesTextEditingController.clear();
|
||||
setState(() => isCaloriesVisible = false);
|
||||
},
|
||||
icon: const Icon(Icons.clear))
|
||||
: null,
|
||||
),
|
||||
keyboardType: TextInputType.number),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
ElevatedButton(onPressed: (){
|
||||
Navigator.pushAndRemoveUntil(context,
|
||||
MaterialPageRoute(builder: (context) => const NavigationScreen()), (r) => false);
|
||||
}, child: const Text('Bestätigen'))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
102
lib/main.dart
102
lib/main.dart
|
@ -1,3 +1,5 @@
|
|||
import 'package:ernaehrung/views/navigation/navigationScreen.dart';
|
||||
import 'package:ernaehrung/views/welcome/welcomeScreen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
|
@ -7,109 +9,17 @@ void main() {
|
|||
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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _incrementCounter() {
|
||||
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++;
|
||||
});
|
||||
}
|
||||
|
||||
@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: <Widget>[
|
||||
const Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: const Icon(Icons.add),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
home: const WelcomeScreen(),
|
||||
routes: {
|
||||
'/navigation': (context) => const NavigationScreen(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
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,
|
||||
),
|
||||
];
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
import 'package:ernaehrung/components/welcomePageChildrenTextField.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WelcomeScreen extends StatelessWidget {
|
||||
const WelcomeScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: 'Welcome Screen',
|
||||
home: WelcomeScreenPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WelcomeScreenPage extends StatefulWidget {
|
||||
const WelcomeScreenPage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => WelcomeScreenPageState();
|
||||
}
|
||||
|
||||
class WelcomeScreenPageState extends State<WelcomeScreenPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Welcome Screen'),
|
||||
),
|
||||
body: const SizedBox(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
child: WelcomePageStateTextFieldState(),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue