Skip to content
Snippets Groups Projects
Commit b226af95 authored by Anager's avatar Anager
Browse files

Merge remote-tracking branch 'flutter/settings_Harald' into home_page_Chaitanya

# Conflicts:
#	lib/main.dart
parents a143a8fb 6715ef28
No related branches found
No related tags found
1 merge request!2Home page chaitanya
assets/defaultProfilePicture.png

23.3 KiB

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),
),
)
],
),
);
}
}
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
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()
],
),
),
);
}
}
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
......@@ -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],
......
......@@ -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:
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment