diff --git a/assets/defaultProfilePicture.png b/assets/defaultProfilePicture.png new file mode 100644 index 0000000000000000000000000000000000000000..5d743050db584d75db2c3acde64448c6c023edeb Binary files /dev/null and b/assets/defaultProfilePicture.png differ diff --git a/lib/bottom_navigation_bar_buttons/profile/profile.dart b/lib/bottom_navigation_bar_buttons/profile/profile.dart new file mode 100644 index 0000000000000000000000000000000000000000..b31edc4530305c3dc147da9d5ecc3c07c864d68f --- /dev/null +++ b/lib/bottom_navigation_bar_buttons/profile/profile.dart @@ -0,0 +1,124 @@ + +import 'package:flutter/material.dart'; +import 'package:deggendorf_app/bottom_navigation_bar_buttons/settings/settings.dart'; + +class Profile extends StatefulWidget { + const Profile({Key? key}) : super(key: key); + + @override + _ProfilePage createState() => _ProfilePage(); +} + +/* +profile Page + */ + +class _ProfilePage extends State<Profile> { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Konto'), + actions: <Widget>[ + IconButton(onPressed:(){ + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const SettingScreen()), + ); + }, icon: Icon(Icons.settings)) + ], + backgroundColor: Colors.brown, + ), + body: Column( + children: <Widget>[ + Padding( + padding: const EdgeInsets.all(30), + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.brown, shape: BoxShape.rectangle), + child: Padding( + padding: const EdgeInsets.all(5), + child: Text( + "Example Username", + maxLines: 2, + textScaleFactor: 2, + textAlign: TextAlign.center, + ), + )), + ), + Container( + alignment: Alignment.center, + decoration: + BoxDecoration(color: Colors.brown, shape: BoxShape.circle), + child: Padding( + padding: const EdgeInsets.all(5), + child: CircleAvatar( + radius: 60, + backgroundColor: Colors.brown, + backgroundImage: + AssetImage('assets/defaultProfilePicture.png'), + ), + )), + Padding( + padding: const EdgeInsets.fromLTRB(30, 10, 30, 20), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ProfileEntry( + category: "Name", description: "Very long example Name"), + ProfileEntry(category: "Age", description: "123"), + ProfileEntry(category: "Birthday", description: "12.34.") + ], + ), + ) + ], + ), + + //const Center(child: Text("Diese Seite wurde noch nicht entwickelt!!!")), + ); + } +} + +class ProfileEntry extends StatefulWidget { + var category; + var description; + + ProfileEntry({Key? key, required this.category, required this.description}) + : super(key: key); + + @override + _ProfileEntryState createState() => _ProfileEntryState(); +} + +class _ProfileEntryState extends State<ProfileEntry> { + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: () { }, + style: TextButton.styleFrom(primary: Colors.brown), + child: Row( + children: [ + Expanded( + flex: 30, + child: Container( + padding: EdgeInsets.fromLTRB(0, 5, 10, 5), + child: Text( + widget.category + ":", + textAlign: TextAlign.right, + + ), + ), + ), + Expanded( + flex: 70, + child: Container( + padding: const EdgeInsets.fromLTRB(10, 5, 0, 5), + child: Text(widget.description), + ), + ) + ], + ), + ); + } +} diff --git a/lib/bottom_navigation_bar_buttons/settings/dropdownbutton.dart b/lib/bottom_navigation_bar_buttons/settings/dropdownbutton.dart new file mode 100644 index 0000000000000000000000000000000000000000..88e967c63c3942ddef0d62cf028f58eaf9468a70 --- /dev/null +++ b/lib/bottom_navigation_bar_buttons/settings/dropdownbutton.dart @@ -0,0 +1,92 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + + +class DropdownSettingButton extends StatefulWidget { + const DropdownSettingButton({Key? key}) : super(key: key); + + @override + State<DropdownSettingButton> createState() => _DropdownSettingButtonState(); +} + +class _DropdownSettingButtonState extends State<DropdownSettingButton> { + bool _expanded = false; + String currentCity = "Die aktuelle Stadt ändern"; + + String getCurrentCity(){ + getCurrentCityFromSharedPreferences(); + return currentCity; + } + + getCurrentCityFromSharedPreferences() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + String val = prefs.getString('currentCity') ?? "Not Selected"; + currentCity = val; + } + + setCurrentCityInSharedPreferences(String newCity) async{ + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.setString('currentCity', newCity); + } + + + @override + Widget build(BuildContext context) { + return ExpansionPanelList( + animationDuration: Duration(microseconds: 2000), + children:[ + ExpansionPanel( + canTapOnHeader: true, + isExpanded: _expanded, + headerBuilder: (context, isExpanded){ + String city = getCurrentCity(); + return ListTile( + title: Text(city, + style: TextStyle(fontSize: 20, color: Color.fromRGBO( + 1, 1, 1, 0.5)) + ), + ); + }, + body: Column( + children: <Widget> [ + TextButton( + onPressed: (){ + setCurrentCityInSharedPreferences("Deggendorf"); + _expanded = false; + getCurrentCityFromSharedPreferences(); + setState(() { + }); + }, + child: Text( + "Deggendorf", + style: TextStyle(fontSize: 20, color: Color.fromRGBO( + 1, 1, 1, 0.5)), + ) + ), + TextButton( + onPressed: (){ + setCurrentCityInSharedPreferences("Plattling"); + _expanded = false; + getCurrentCityFromSharedPreferences(); + setState(() { + }); + }, + child: Text( + "Plattling", + style: TextStyle(fontSize: 20, color: Color.fromRGBO( + 1, 1, 1, 0.5)), + ) + ), + ], + ) + ) + ], + expansionCallback: (panelIndex, isExpanded){ + _expanded = !_expanded; + setState(() { + + }); + }, + ); + } +} \ No newline at end of file diff --git a/lib/bottom_navigation_bar_buttons/settings/settings.dart b/lib/bottom_navigation_bar_buttons/settings/settings.dart new file mode 100644 index 0000000000000000000000000000000000000000..ec998f55f86994f5c6170e2fcc7595de0fda8c82 --- /dev/null +++ b/lib/bottom_navigation_bar_buttons/settings/settings.dart @@ -0,0 +1,35 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +import 'package:deggendorf_app/bottom_navigation_bar_buttons/settings/dropdownbutton.dart'; +import 'package:deggendorf_app/bottom_navigation_bar_buttons/settings/standardsettingbutton.dart'; + + +class SettingScreen extends StatelessWidget { + const SettingScreen({Key? key}) : super(key: key); + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.pink, + title: Text( + "Einstellungen", + style: TextStyle(fontSize: 25, color: Colors.white), + ), + ), + body: Container( + padding: EdgeInsets.all(8), + child: ListView( + children: [ + StandardSettingButton(xOffset: 150, title: "Kennwort", label: "",), + StandardSettingButton(xOffset: 127, title: "Benutzername", label: ""), + DropdownSettingButton() + ], + ), + ), + ); + } +} diff --git a/lib/bottom_navigation_bar_buttons/settings/standardsettingbutton.dart b/lib/bottom_navigation_bar_buttons/settings/standardsettingbutton.dart new file mode 100644 index 0000000000000000000000000000000000000000..42e7af757aa9c2c0d133bd097a0b9f0efe272481 --- /dev/null +++ b/lib/bottom_navigation_bar_buttons/settings/standardsettingbutton.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; + + +class StandardSettingButton extends StatefulWidget { + const StandardSettingButton({Key? key, + required this.xOffset, + required this.title, + required this.label + }) : super(key: key); + + final double xOffset; + final String title; + final String label; + + @override + State<StandardSettingButton> createState() => _StandardSettingButtonState(); +} + +class _StandardSettingButtonState extends State<StandardSettingButton> { + + bool isPassword(){ + if (widget.title == "Kennwort"){ + return true; + } + return false; + } + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: (){ + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text( + "Wollen Sie ${widget.title} ändern?", + style: TextStyle( + fontSize: 16 + ), + ), + content: TextField( + obscureText: isPassword() , + decoration: InputDecoration( + hintText: "geben Sie ${widget.title} ein" + ), + ), + actions: [ + TextButton( + onPressed: (){Navigator.pop(context);}, + child: Text("ändern") + ), + TextButton( + onPressed: (){ + Navigator.pop(context); + }, + child: Text("abbrechen") + ) + ], + ), + ); + }, + child: Row( + children: <Widget>[ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.title, + style: TextStyle(fontSize: 25, color: Color.fromRGBO( + 1, 1, 1, 0.5)), + ), + Text( + "drücken um das ${widget.title} zu ändern", + style: TextStyle(fontSize: 10, color: Color.fromRGBO( + 1, 1, 1, 0.37)), + ) + ], + ), + SizedBox( + width: widget.xOffset, + ), + Icon( + Icons.keyboard_arrow_right_rounded, + color: Color.fromRGBO(1, 1, 1, 0.5), + size: 40, + ) + ], + ) + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 07b800e1677a70bdbd10566d0eb88207ff5e490b..7fc1a267c0f836fa79c20677e0e6f753a6799874 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:deggendorf_app/bottom_navigation_bar_buttons/home_page/home_page 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/home_page/weather/current_weather.dart'; void main() { @@ -50,9 +51,8 @@ class _MyHomePageState extends State<MyHomePage> { //Index: 2, Forum(), //Index: 3 - SecondRoute(), + Profile(), //Index: 4 - SecondRoute() ]; void _onItemTapped(int index) { @@ -72,6 +72,7 @@ class _MyHomePageState extends State<MyHomePage> { body: Center( child: _widgetOptions.elementAt(_selectedIndex), ), + /* From here are the bottom navigation bar's buttons Each button has an icon, a label and a colour, each of which are optional @@ -98,11 +99,6 @@ class _MyHomePageState extends State<MyHomePage> { label: 'Konto', backgroundColor: Colors.brown, ), - BottomNavigationBarItem( - icon: Icon(Icons.settings), - label: 'Einstellung', - backgroundColor: Colors.pink, - ), ], currentIndex: _selectedIndex, selectedItemColor: Colors.amber[800], diff --git a/pubspec.lock b/pubspec.lock index 68f343a07f115803e2891e0aa1ac0566ce5fd944..43b7434e23a0f80460ea9f2ce04e94e0552f9f7e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -90,11 +90,30 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" + flutter_material_color_picker: + dependency: transitive + description: + name: flutter_material_color_picker + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0+2" + flutter_settings_screens: + dependency: "direct main" + description: + name: flutter_settings_screens + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.2+1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" google_fonts: dependency: "direct dev" description: @@ -116,6 +135,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" lints: dependency: transitive description: @@ -144,6 +170,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" + nested: + dependency: transitive + description: + name: nested + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" path: dependency: transitive description: @@ -200,6 +233,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" platform: dependency: transitive description: @@ -221,6 +261,69 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.4" + provider: + dependency: transitive + description: + name: provider + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.13" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + shared_preferences_ios: + dependency: transitive + description: + name: shared_preferences_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" sky_engine: dependency: transitive description: flutter @@ -288,7 +391,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.4.4" + version: "2.5.1" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4d3a0c9d13912cb43132768822850e7a86afdde5..4d4effe43123c63d481bcef03293c244f812699c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,8 @@ dependencies: # 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 dev_dependencies: flutter_test: