From 2d2e08cb7a941b94a191bb8ff8c2cc06faf05dfb Mon Sep 17 00:00:00 2001 From: Chaitanya <schlockmangra@gmail.com> Date: Wed, 20 Apr 2022 11:17:28 +0200 Subject: [PATCH] event_chaitanya --- lib/{ => bin}/main.dart | 13 +- .../event/event.dart | 121 ++++++++++++++++++ .../forum/forum.dart | 2 +- .../{ => homepage manager}/home_page.dart | 24 ++-- .../list_of_widgets_for_home_page.dart | 20 ++- .../profile/profile.dart | 24 ++-- pubspec.lock | 7 + pubspec.yaml | 2 + 8 files changed, 178 insertions(+), 35 deletions(-) rename lib/{ => bin}/main.dart (88%) create mode 100644 lib/bottom_navigation_bar_buttons/event/event.dart rename lib/bottom_navigation_bar_buttons/home_page/{ => homepage manager}/home_page.dart (76%) rename lib/bottom_navigation_bar_buttons/home_page/{ => homepage manager}/list_of_widgets_for_home_page.dart (59%) diff --git a/lib/main.dart b/lib/bin/main.dart similarity index 88% rename from lib/main.dart rename to lib/bin/main.dart index f71cbdd..1ce43cb 100644 --- a/lib/main.dart +++ b/lib/bin/main.dart @@ -1,10 +1,11 @@ -import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/home_page.dart'; +import 'package:deggendorf_app/bottom_navigation_bar_buttons/event/event.dart'; +import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/homepage%20manager/home_page.dart'; import 'package:flutter/material.dart'; -import 'bottom_navigation_bar_buttons/forum/forum.dart'; -import 'bottom_navigation_bar_buttons/profile/profile.dart'; -import 'bottom_navigation_bar_buttons/profile/profile.dart'; -import 'bottom_navigation_bar_buttons/home_page/weather/current_weather.dart'; +import '../bottom_navigation_bar_buttons/forum/forum.dart'; +import '../bottom_navigation_bar_buttons/profile/profile.dart'; +import '../bottom_navigation_bar_buttons/profile/profile.dart'; +import '../bottom_navigation_bar_buttons/home_page/weather/current_weather.dart'; void main() { runApp(const MyApp()); @@ -48,7 +49,7 @@ class _MyHomePageState extends State<MyHomePage> { //Index: 0 HomePage(), //Index: 1, - SecondRoute(), + EventMainPage(), //Index: 2, Forum(), //Index: 3 diff --git a/lib/bottom_navigation_bar_buttons/event/event.dart b/lib/bottom_navigation_bar_buttons/event/event.dart new file mode 100644 index 0000000..5981a43 --- /dev/null +++ b/lib/bottom_navigation_bar_buttons/event/event.dart @@ -0,0 +1,121 @@ +import 'package:deggendorf_app/bin/main.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_speed_dial/flutter_speed_dial.dart'; + +class EventMainPage extends StatefulWidget { + const EventMainPage({Key? key}) : super(key: key); + + @override + _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); +} + +class _MyStatefulWidgetState extends State<EventMainPage> { + //This boolean variable is used for the checkboxes + bool _value = false; + + /*This list contains the elements to be displayed on the event page. + These elements were originally thought to be bars which once clicked upon + are marked as checked. + If you want to add a new item to the scrollable list, add it in this list; + more specifically in the method initializeMyList. + */ + List<Widget> myListToBeDisplayed = []; + + /*If you need to add a new item to the list, add it here. + */ + void initializeMyList() { + myListToBeDisplayed = [ + sizedBox("Bar 1", "Mehr Informationen über Bar 1", + Icons.local_bar_rounded, 100, SecondRoute()), + sizedBox("Bar 2", "Mehr Informationen über Bar 1", + Icons.local_bar_rounded, 200, SecondRoute()), + sizedBox("Bar 3", "Mehr Informationen über Bar 3", + Icons.local_bar_rounded, 100, SecondRoute()), + sizedBox("Bar 4", "Mehr Informationen über Bar 4", + Icons.local_bar_rounded, 100, SecondRoute()), + sizedBox("Bar 5", "Mehr Informationen über Bar 5", + Icons.local_bar_rounded, 100, SecondRoute()), + sizedBox("Bar 6", "Mehr Informationen über Bar 6", + Icons.local_bar_rounded, 100, SecondRoute()), + ]; + } + + @override + Widget build(BuildContext context) { + initializeMyList(); + return Scaffold( + backgroundColor: Colors.blue[200], + appBar: AppBar( + title: Text("Eventname"), + backgroundColor: Colors.green, + ), + body: Container( + child: Center( + child: ListView( + children: myListToBeDisplayed, + ), + ), + ), + //This is the floating button at the bottom right of the page. + floatingActionButton: SpeedDial( + //edit here to change the colour and opacity of the overlay, when the button is pressed. + overlayColor: Colors.black, + overlayOpacity: 0.3, + animatedIcon: AnimatedIcons.menu_close, + backgroundColor: Colors.green[700], + children: [ + SpeedDialChild( + child: Icon(Icons.info), + label: 'Option 1', + backgroundColor: Colors.red), + SpeedDialChild( + child: Icon(Icons.phone_android), + label: 'Option 2', + backgroundColor: Colors.green) + ], + ), + ); + } + + //This sized box is used in the list myListToBeDisplayed + SizedBox sizedBox(String mainTitle, String subtitle, IconData iconData, + double heightOfCheckBox, Widget navigateTo) { + return SizedBox( + height: heightOfCheckBox, + + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration: BoxDecoration( + color: Colors.green[100], + border: Border.all(color: Colors.green), + borderRadius: BorderRadius.circular(20), + ), //BoxDecoration + child: CheckboxListTile( + title: Text(mainTitle), + subtitle: Text(subtitle), + secondary: Icon(iconData), + activeColor: Colors.green, + checkColor: Colors.white, + selected: _value, + value: _value, + onChanged: (bool? value) { + //This piece of code can be used to change the value of the checkbox upon click. + //It is commented because it is not used here. + setState(() { + _value = value!; + } + /*Navigator.push( + context, + MaterialPageRoute( + builder: (context) => navigateTo, + )*/); + }, + ), //CheckboxListTile + ), //Container + ), //Padding + ); + } + + +} diff --git a/lib/bottom_navigation_bar_buttons/forum/forum.dart b/lib/bottom_navigation_bar_buttons/forum/forum.dart index 4ae4dfe..949d102 100644 --- a/lib/bottom_navigation_bar_buttons/forum/forum.dart +++ b/lib/bottom_navigation_bar_buttons/forum/forum.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../main.dart'; +import '../../bin/main.dart'; class Forum extends StatefulWidget { const Forum({Key? key}) : super(key: key); diff --git a/lib/bottom_navigation_bar_buttons/home_page/home_page.dart b/lib/bottom_navigation_bar_buttons/home_page/homepage manager/home_page.dart similarity index 76% rename from lib/bottom_navigation_bar_buttons/home_page/home_page.dart rename to lib/bottom_navigation_bar_buttons/home_page/homepage manager/home_page.dart index f992c36..e9101eb 100644 --- a/lib/bottom_navigation_bar_buttons/home_page/home_page.dart +++ b/lib/bottom_navigation_bar_buttons/home_page/homepage manager/home_page.dart @@ -1,6 +1,5 @@ -import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/list_of_widgets_for_home_page.dart'; -import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/weather/current_weather.dart'; -import 'package:deggendorf_app/main.dart'; +import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/homepage%20manager/list_of_widgets_for_home_page.dart'; +import 'package:deggendorf_app/bin/main.dart'; import 'package:flutter/material.dart'; class HomePage extends StatelessWidget { @@ -22,8 +21,6 @@ class MyStatefulWidget extends StatefulWidget { } class _MyStatefulWidgetState extends State<MyStatefulWidget> { - List<int> bottom = <int>[0]; - @override Widget build(BuildContext context) { const Key centerKey = ValueKey<String>('bottom-sliver-list'); @@ -71,23 +68,20 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> { (BuildContext context, int index) { return new InkWell( onTap: () { - if (index == 0) { //If the widget tapped is the weather widget, then open weather page :) Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const CurrentWeather()), - ); - } + context, + MaterialPageRoute( + builder: (context) => + new MyList(context).myListToBeTappedOn[index], + )); }, child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20)), height: 125, - child: new MyList(context).myList[index], + child: new MyList(context).myListToBeDisplayed[index], )); }, - childCount: new MyList(context).myList.length, + childCount: new MyList(context).myListToBeDisplayed.length, ), ), ], diff --git a/lib/bottom_navigation_bar_buttons/home_page/list_of_widgets_for_home_page.dart b/lib/bottom_navigation_bar_buttons/home_page/homepage manager/list_of_widgets_for_home_page.dart similarity index 59% rename from lib/bottom_navigation_bar_buttons/home_page/list_of_widgets_for_home_page.dart rename to lib/bottom_navigation_bar_buttons/home_page/homepage manager/list_of_widgets_for_home_page.dart index 05a8fa1..c3a30e9 100644 --- a/lib/bottom_navigation_bar_buttons/home_page/list_of_widgets_for_home_page.dart +++ b/lib/bottom_navigation_bar_buttons/home_page/homepage manager/list_of_widgets_for_home_page.dart @@ -1,10 +1,14 @@ +import 'package:deggendorf_app/bin/main.dart'; import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/weather/current_weather.dart'; import 'package:flutter/cupertino.dart'; class MyList { - List<Widget> myList = []; + + List<Widget> myListToBeDisplayed = []; + List<Widget> myListToBeTappedOn = []; + MyList(BuildContext buildContext) { - myList = [ + myListToBeDisplayed = [ actualWeatherContainer(buildContext), Text("Input your widget here"), Text("Input your widget here"), @@ -15,6 +19,18 @@ class MyList { Text("Input your widget here"), Text("Input your widget here"), ]; + + myListToBeTappedOn = [ + CurrentWeather(), + SecondRoute(), + SecondRoute(), + SecondRoute(), + SecondRoute(), + SecondRoute(), + SecondRoute(), + SecondRoute(), + SecondRoute(), + ]; } } diff --git a/lib/bottom_navigation_bar_buttons/profile/profile.dart b/lib/bottom_navigation_bar_buttons/profile/profile.dart index b31edc4..0a73406 100644 --- a/lib/bottom_navigation_bar_buttons/profile/profile.dart +++ b/lib/bottom_navigation_bar_buttons/profile/profile.dart @@ -1,6 +1,6 @@ - import 'package:flutter/material.dart'; -import 'package:deggendorf_app/bottom_navigation_bar_buttons/settings/settings.dart'; + +import '../settings/settings.dart'; class Profile extends StatefulWidget { const Profile({Key? key}) : super(key: key); @@ -20,12 +20,15 @@ class _ProfilePage extends State<Profile> { appBar: AppBar( title: const Text('Konto'), actions: <Widget>[ - IconButton(onPressed:(){ - Navigator.push( - context, - MaterialPageRoute(builder: (context) => const SettingScreen()), - ); - }, icon: Icon(Icons.settings)) + IconButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingScreen()), + ); + }, + icon: Icon(Icons.settings)) ], backgroundColor: Colors.brown, ), @@ -95,7 +98,7 @@ class _ProfileEntryState extends State<ProfileEntry> { @override Widget build(BuildContext context) { return TextButton( - onPressed: () { }, + onPressed: () {}, style: TextButton.styleFrom(primary: Colors.brown), child: Row( children: [ @@ -105,8 +108,7 @@ class _ProfileEntryState extends State<ProfileEntry> { padding: EdgeInsets.fromLTRB(0, 5, 10, 5), child: Text( widget.category + ":", - textAlign: TextAlign.right, - + textAlign: TextAlign.right, ), ), ), diff --git a/pubspec.lock b/pubspec.lock index 43b7434..18aca1f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -104,6 +104,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.2+1" + flutter_speed_dial: + dependency: "direct main" + description: + name: flutter_speed_dial + url: "https://pub.dartlang.org" + source: hosted + version: "4.6.6" flutter_test: dependency: "direct dev" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 4d4effe..ce1d3b4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,12 +32,14 @@ dependencies: + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.4 http: ^0.13.4 flutter_settings_screens: ^0.2.2+1 shared_preferences: ^2.0.13 + flutter_speed_dial: ^4.3.0 dev_dependencies: flutter_test: -- GitLab