From 9c5eacb4de182cfaae90c431ca59b04f93916e77 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 10 Aug 2019 16:00:04 +0800 Subject: [PATCH 01/16] feat: add basic settings tab --- lib/src/ui/home.dart | 3 +- lib/src/ui/settings_tab/settings_tab.dart | 40 ++++++++++ .../ui/settings_tab/widgets/home_view.dart | 74 +++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 lib/src/ui/settings_tab/settings_tab.dart create mode 100644 lib/src/ui/settings_tab/widgets/home_view.dart diff --git a/lib/src/ui/home.dart b/lib/src/ui/home.dart index 78db81d..6c42e7e 100644 --- a/lib/src/ui/home.dart +++ b/lib/src/ui/home.dart @@ -9,6 +9,7 @@ import "../blocs/message_bloc.dart"; import "./conversation_tab/conversation_tab.dart"; import "./contact_tab/contact_tab.dart"; +import './settings_tab/settings_tab.dart'; import "./bottom_bar/bottom_bar.dart"; class Home extends StatefulWidget { @@ -89,7 +90,7 @@ class _HomeState extends State with SingleTickerProviderStateMixin { children: [ ContactTab(), ConversationTab(), - Container(), + SettingsTab(), ]), bottomNavigationBar: Column(mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/src/ui/settings_tab/settings_tab.dart b/lib/src/ui/settings_tab/settings_tab.dart new file mode 100644 index 0000000..3b81d51 --- /dev/null +++ b/lib/src/ui/settings_tab/settings_tab.dart @@ -0,0 +1,40 @@ +import "package:flutter/material.dart"; + +import "./widgets/home_view.dart"; + +class SettingsTab extends StatefulWidget { + @override + State createState() { + return _SettingsTabState(); + } +} + +class _SettingsTabState extends State { + @override + Widget build(BuildContext context) { + return Navigator( + initialRoute: "settings/home", + onGenerateRoute: (RouteSettings settings) { + WidgetBuilder builder; + switch (settings.name) { + case "settings/home": + builder = (BuildContext _) => HomeView(); + break; + // case "settings/profile_pic": + // builder = (BuildContext _) => NewsettingsView(); + // break; + // case "settings/new/group": + // builder = (BuildContext _) => NewGroupView(); + // break; + // case "settings/new/groupinfo": + // final List users = settings.arguments; + // builder = (BuildContext _) => NewGroupInfoView(users: users); + // break; + default: + throw Exception("Invalid route: ${settings.name}"); + } + return MaterialPageRoute(builder: builder, settings: settings); + }, + ); + } +} diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart new file mode 100644 index 0000000..79e1f22 --- /dev/null +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -0,0 +1,74 @@ +import "package:flutter/material.dart"; +import 'package:frontend_flutter/src/ui/widgets/image_avatar.dart'; + +import "../../widgets/top_bar.dart"; +import "../../widgets/list_button.dart"; + +class HomeView extends StatefulWidget { + @override + State createState() { + return _HomeViewState(); + } +} + +class _HomeViewState extends State { + final searchController = TextEditingController(); + + @override + initState() { + super.initState(); + } + + @override + dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Column(children: [ + TopBar(title: "Settings", children: [ + BackButton(), + Spacer(), + ]), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(20.0), + child: ImageAvatar( + info: ImageAvatarInfo(lastName: 'Daniel'), radius: 70.0), + ), + ], + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // 'Daniel Lim Hai', + // style: Theme.of(context) + // .textTheme + // .title + // .copyWith(fontSize: 18.0), + // ), + // Text( + // 'Insert bio here', + // style: Theme.of(context).textTheme.subtitle, + // ), + // ], + // ), + ), + Expanded( + child: ListView( + padding: EdgeInsets.only(top: 0.0), + children: [ + ListButton( + icon: Icons.person, + text: 'Daniel Lim Hai', + onClickCallback: () {}, + ), + ], + ), + ), + ]); + } +} From 1d28d3585aed3c7cd0ccc505b3943ab039de4373 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 10 Aug 2019 16:01:04 +0800 Subject: [PATCH 02/16] feat: add subtitles and styling to list_button --- lib/src/ui/widgets/list_button.dart | 41 ++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/src/ui/widgets/list_button.dart b/lib/src/ui/widgets/list_button.dart index 791c4ab..b577143 100644 --- a/lib/src/ui/widgets/list_button.dart +++ b/lib/src/ui/widgets/list_button.dart @@ -6,11 +6,19 @@ class ListButton extends StatelessWidget { final IconData icon; final String text; final OnClickCallback onClickCallback; + final String subtitle; + final TextStyle textStyle; + final TextStyle subtitleStyle; + final Color iconColor; ListButton( {@required this.icon, @required this.text, - @required this.onClickCallback}); + @required this.onClickCallback, + this.subtitle, + this.textStyle, + this.subtitleStyle, + this.iconColor}); @override Widget build(BuildContext context) { @@ -27,12 +35,33 @@ class ListButton extends StatelessWidget { children: [ Icon(icon, size: 30.0, - color: Theme.of(context).primaryColorDark), + color: + iconColor ?? Theme.of(context).primaryColorDark), Padding( - padding: EdgeInsets.only(left: 20.0), - child: Text(text, - style: Theme.of(context).textTheme.title.copyWith( - color: Theme.of(context).primaryColorDark))), + padding: EdgeInsets.only(left: 20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + text, + style: textStyle ?? + Theme.of(context).textTheme.title.copyWith( + color: + Theme.of(context).primaryColorDark), + ), + (subtitle == null) + ? Container() + : Padding( + padding: EdgeInsets.only(top: 3.0), + child: Text( + subtitle, + style: subtitleStyle ?? + Theme.of(context).textTheme.subtitle, + ), + ), + ], + ), + ), ])))); } } From c3b3445b292badd515e6bcec5d30fe1abb1019a4 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 10 Aug 2019 16:01:49 +0800 Subject: [PATCH 03/16] feat: improve settings layout --- .../ui/settings_tab/widgets/home_view.dart | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index 79e1f22..e966091 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -64,7 +64,55 @@ class _HomeViewState extends State { ListButton( icon: Icons.person, text: 'Daniel Lim Hai', + subtitle: 'Name', onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.info, + text: 'Hey there, I am using Beep!', + subtitle: 'Bio', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + Divider(), + ListButton( + icon: Icons.notifications, + text: 'Notifications', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.security, + text: 'Security', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.exit_to_app, + text: 'Sign Out', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Colors.redAccent), + iconColor: Colors.redAccent, ), ], ), From ef0f13bb580085cfb38854021ef1a1c5f9b67d18 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 10 Aug 2019 16:32:28 +0800 Subject: [PATCH 04/16] refactor: remove commented out code --- lib/src/ui/settings_tab/widgets/home_view.dart | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index e966091..86f1266 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -40,22 +40,6 @@ class _HomeViewState extends State { info: ImageAvatarInfo(lastName: 'Daniel'), radius: 70.0), ), ], - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Text( - // 'Daniel Lim Hai', - // style: Theme.of(context) - // .textTheme - // .title - // .copyWith(fontSize: 18.0), - // ), - // Text( - // 'Insert bio here', - // style: Theme.of(context).textTheme.subtitle, - // ), - // ], - // ), ), Expanded( child: ListView( From d469f41bc9c7ea527c48a7dbdbf36aaa835959b5 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 10 Aug 2019 21:27:47 +0800 Subject: [PATCH 05/16] feat: add popup dialog for changing name and bio --- .../ui/settings_tab/widgets/home_view.dart | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index 86f1266..927c0c8 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -1,3 +1,5 @@ +import 'dart:async' show Future; + import "package:flutter/material.dart"; import 'package:frontend_flutter/src/ui/widgets/image_avatar.dart'; @@ -12,7 +14,7 @@ class HomeView extends StatefulWidget { } class _HomeViewState extends State { - final searchController = TextEditingController(); + final _textFieldController = TextEditingController(); @override initState() { @@ -22,6 +24,7 @@ class _HomeViewState extends State { @override dispose() { super.dispose(); + _textFieldController.dispose(); } @override @@ -49,7 +52,17 @@ class _HomeViewState extends State { icon: Icons.person, text: 'Daniel Lim Hai', subtitle: 'Name', - onClickCallback: () {}, + onClickCallback: () { + _displayTextFieldDialog( + context: context, + title: 'Edit Name', + existingText: 'Daniel Lim Hai', + hintText: 'Name', + ).then((text) { + //TODO: Logic for changing name + print(text); + }); + }, textStyle: Theme.of(context) .textTheme .title @@ -60,7 +73,17 @@ class _HomeViewState extends State { icon: Icons.info, text: 'Hey there, I am using Beep!', subtitle: 'Bio', - onClickCallback: () {}, + onClickCallback: () { + _displayTextFieldDialog( + context: context, + title: 'Edit Bio', + existingText: 'Placeholder bio', + hintText: 'Bio', + ).then((text) { + //TODO: Logic for changing bio + print(text); + }); + }, textStyle: Theme.of(context) .textTheme .title @@ -103,4 +126,46 @@ class _HomeViewState extends State { ), ]); } + + _displayTextFieldDialog({ + @required BuildContext context, + @required String title, + String existingText, + String hintText, + }) async { + _textFieldController.text = existingText; + + // Introduce artificial delay so the button press animation can be seen + await new Future.delayed(const Duration(milliseconds: 220)); + + return showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + title, + style: Theme.of(context).textTheme.title, + ), + content: TextField( + controller: _textFieldController, + decoration: InputDecoration(hintText: hintText), + autofocus: true, + ), + actions: [ + new FlatButton( + child: new Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + new FlatButton( + child: new Text('Submit'), + onPressed: () { + Navigator.of(context).pop(_textFieldController.text); + }, + ), + ], + ); + }); + } } From b31b89cdf376cd06a00064010a3c4cf0c1589b0d Mon Sep 17 00:00:00 2001 From: shihern Date: Mon, 12 Aug 2019 15:51:54 +0800 Subject: [PATCH 06/16] refactor: use local variables for name and bio --- .../ui/settings_tab/widgets/home_view.dart | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index 927c0c8..b3b9697 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -15,6 +15,8 @@ class HomeView extends StatefulWidget { class _HomeViewState extends State { final _textFieldController = TextEditingController(); + String name = 'Daniel Lim Hai'; + String bio = 'Hey there, I am using Meep!'; @override initState() { @@ -37,11 +39,13 @@ class _HomeViewState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Padding( - padding: const EdgeInsets.all(20.0), - child: ImageAvatar( - info: ImageAvatarInfo(lastName: 'Daniel'), radius: 70.0), - ), + Stack(children: [ + Padding( + padding: const EdgeInsets.all(20.0), + child: ImageAvatar( + info: ImageAvatarInfo(lastName: 'Daniel'), radius: 70.0), + ), + ]), ], ), Expanded( @@ -50,17 +54,22 @@ class _HomeViewState extends State { children: [ ListButton( icon: Icons.person, - text: 'Daniel Lim Hai', + text: name, subtitle: 'Name', onClickCallback: () { _displayTextFieldDialog( context: context, title: 'Edit Name', - existingText: 'Daniel Lim Hai', + existingText: name, hintText: 'Name', ).then((text) { //TODO: Logic for changing name - print(text); + if (text != null) { + setState(() { + name = text; + print(text); + }); + } }); }, textStyle: Theme.of(context) @@ -71,17 +80,22 @@ class _HomeViewState extends State { ), ListButton( icon: Icons.info, - text: 'Hey there, I am using Beep!', + text: bio, subtitle: 'Bio', onClickCallback: () { _displayTextFieldDialog( context: context, title: 'Edit Bio', - existingText: 'Placeholder bio', + existingText: bio, hintText: 'Bio', ).then((text) { //TODO: Logic for changing bio - print(text); + if (text != null) { + setState(() { + bio = text; + print(text); + }); + } }); }, textStyle: Theme.of(context) From b25e7771332daa13edda1ce500a169e7fbe304c2 Mon Sep 17 00:00:00 2001 From: shihern Date: Mon, 12 Aug 2019 17:11:29 +0800 Subject: [PATCH 07/16] feat: add additional settings --- .../ui/settings_tab/widgets/home_view.dart | 304 ++++++++++-------- 1 file changed, 174 insertions(+), 130 deletions(-) diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index b3b9697..ce3c333 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -31,114 +31,157 @@ class _HomeViewState extends State { @override Widget build(BuildContext context) { - return Column(children: [ - TopBar(title: "Settings", children: [ - BackButton(), - Spacer(), - ]), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Stack(children: [ - Padding( - padding: const EdgeInsets.all(20.0), - child: ImageAvatar( - info: ImageAvatarInfo(lastName: 'Daniel'), radius: 70.0), - ), - ]), - ], - ), - Expanded( - child: ListView( - padding: EdgeInsets.only(top: 0.0), + return Column( + children: [ + TopBar( + title: "Settings", children: [ - ListButton( - icon: Icons.person, - text: name, - subtitle: 'Name', - onClickCallback: () { - _displayTextFieldDialog( - context: context, - title: 'Edit Name', - existingText: name, - hintText: 'Name', - ).then((text) { - //TODO: Logic for changing name - if (text != null) { - setState(() { - name = text; - print(text); - }); - } - }); - }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), - iconColor: Theme.of(context).primaryColorDark, - ), - ListButton( - icon: Icons.info, - text: bio, - subtitle: 'Bio', - onClickCallback: () { - _displayTextFieldDialog( - context: context, - title: 'Edit Bio', - existingText: bio, - hintText: 'Bio', - ).then((text) { - //TODO: Logic for changing bio - if (text != null) { - setState(() { - bio = text; - print(text); - }); - } - }); - }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), - iconColor: Theme.of(context).primaryColorDark, - ), - Divider(), - ListButton( - icon: Icons.notifications, - text: 'Notifications', - onClickCallback: () {}, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), - iconColor: Theme.of(context).primaryColorDark, - ), - ListButton( - icon: Icons.security, - text: 'Security', - onClickCallback: () {}, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), - iconColor: Theme.of(context).primaryColorDark, - ), - ListButton( - icon: Icons.exit_to_app, - text: 'Sign Out', - onClickCallback: () {}, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Colors.redAccent), - iconColor: Colors.redAccent, + BackButton(), + Spacer(), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + children: [ + Positioned( + child: ImageAvatar( + padding: EdgeInsets.all(20.0), + info: ImageAvatarInfo(lastName: 'Daniel'), + radius: 70.0, + ), + ), + Positioned( + top: 115.0, + left: 115.0, + child: FloatingActionButton( + backgroundColor: Theme.of(context).primaryColorDark, + onPressed: () => {}, + mini: true, + child: Icon( + Icons.edit, + color: Colors.white, + ), + ), + ), + ], ), ], ), - ), - ]); + Expanded( + child: ListView( + padding: EdgeInsets.only(top: 0.0), + children: [ + ListButton( + icon: Icons.person, + text: name, + subtitle: 'Name', + onClickCallback: () { + _displayTextFieldDialog( + context: context, + title: 'Edit Name', + existingText: name, + hintText: 'Name', + ).then((text) { + //TODO: Logic for changing name + if (text != null) { + setState(() { + name = text; + print(text); + }); + } + }); + }, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.info, + text: bio, + subtitle: 'Bio', + onClickCallback: () { + _displayTextFieldDialog( + context: context, + title: 'Edit Bio', + existingText: bio, + hintText: 'Bio', + ).then((text) { + //TODO: Logic for changing bio + if (text != null) { + setState(() { + bio = text; + print(text); + }); + } + }); + }, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + Divider(), + ListButton( + icon: Icons.notifications, + text: 'Notifications', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.color_lens, + text: 'Interface', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.security, + text: 'Privacy and Security', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + ListButton( + icon: Icons.data_usage, + text: 'Data Usage', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor), + iconColor: Theme.of(context).primaryColorDark, + ), + Divider(), + ListButton( + icon: Icons.exit_to_app, + text: 'Sign Out', + onClickCallback: () {}, + textStyle: Theme.of(context) + .textTheme + .title + .copyWith(color: Colors.redAccent), + iconColor: Colors.redAccent, + ), + ], + ), + ), + ], + ); } _displayTextFieldDialog({ @@ -153,33 +196,34 @@ class _HomeViewState extends State { await new Future.delayed(const Duration(milliseconds: 220)); return showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - title, - style: Theme.of(context).textTheme.title, + context: context, + builder: (context) { + return AlertDialog( + title: Text( + title, + style: Theme.of(context).textTheme.title, + ), + content: TextField( + controller: _textFieldController, + decoration: InputDecoration(hintText: hintText), + autofocus: true, + ), + actions: [ + new FlatButton( + child: new Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, ), - content: TextField( - controller: _textFieldController, - decoration: InputDecoration(hintText: hintText), - autofocus: true, + new FlatButton( + child: new Text('Submit'), + onPressed: () { + Navigator.of(context).pop(_textFieldController.text); + }, ), - actions: [ - new FlatButton( - child: new Text('Cancel'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - new FlatButton( - child: new Text('Submit'), - onPressed: () { - Navigator.of(context).pop(_textFieldController.text); - }, - ), - ], - ); - }); + ], + ); + }, + ); } } From 02cd55a1c6f071fc9b966dac16e550251e88c006 Mon Sep 17 00:00:00 2001 From: shihern Date: Mon, 12 Aug 2019 22:17:00 +0800 Subject: [PATCH 08/16] feat: add views for each page --- lib/src/ui/settings_tab/settings_tab.dart | 23 +++++++++---- .../settings_tab/widgets/data_usage_view.dart | 29 +++++++++++++++++ .../ui/settings_tab/widgets/home_view.dart | 32 +++++++++++++------ .../settings_tab/widgets/interface_view.dart | 29 +++++++++++++++++ .../widgets/notifications_view.dart | 29 +++++++++++++++++ .../widgets/privacy_security_view.dart | 29 +++++++++++++++++ 6 files changed, 156 insertions(+), 15 deletions(-) create mode 100644 lib/src/ui/settings_tab/widgets/data_usage_view.dart create mode 100644 lib/src/ui/settings_tab/widgets/interface_view.dart create mode 100644 lib/src/ui/settings_tab/widgets/notifications_view.dart create mode 100644 lib/src/ui/settings_tab/widgets/privacy_security_view.dart diff --git a/lib/src/ui/settings_tab/settings_tab.dart b/lib/src/ui/settings_tab/settings_tab.dart index 3b81d51..07d87d5 100644 --- a/lib/src/ui/settings_tab/settings_tab.dart +++ b/lib/src/ui/settings_tab/settings_tab.dart @@ -1,4 +1,9 @@ import "package:flutter/material.dart"; +import 'package:frontend_flutter/src/ui/settings_tab/widgets/data_usage_view.dart'; +import 'package:frontend_flutter/src/ui/settings_tab/widgets/interface_view.dart'; +import 'package:frontend_flutter/src/ui/settings_tab/widgets/notifications_view.dart'; +import 'package:frontend_flutter/src/ui/settings_tab/widgets/privacy_security_view.dart'; +import 'package:frontend_flutter/src/ui/widgets/top_bar.dart'; import "./widgets/home_view.dart"; @@ -20,12 +25,18 @@ class _SettingsTabState extends State { case "settings/home": builder = (BuildContext _) => HomeView(); break; - // case "settings/profile_pic": - // builder = (BuildContext _) => NewsettingsView(); - // break; - // case "settings/new/group": - // builder = (BuildContext _) => NewGroupView(); - // break; + case "settings/interface": + builder = (BuildContext _) => InterfaceView(); + break; + case "settings/notifications": + builder = (BuildContext _) => NotificationsView(); + break; + case "settings/privacy_security": + builder = (BuildContext _) => PrivacySecurityView(); + break; + case "settings/data_usage": + builder = (BuildContext _) => DataUsageView(); + break; // case "settings/new/groupinfo": // final List users = settings.arguments; // builder = (BuildContext _) => NewGroupInfoView(users: users); diff --git a/lib/src/ui/settings_tab/widgets/data_usage_view.dart b/lib/src/ui/settings_tab/widgets/data_usage_view.dart new file mode 100644 index 0000000..b75453c --- /dev/null +++ b/lib/src/ui/settings_tab/widgets/data_usage_view.dart @@ -0,0 +1,29 @@ +import "package:flutter/material.dart"; + +import "../../widgets/top_bar.dart"; +import "../../widgets/list_button.dart"; + +class DataUsageView extends StatefulWidget { + @override + State createState() { + return _DataUsageViewState(); + } +} + +class _DataUsageViewState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + TopBar( + title: "Data Usage", + children: [ + BackButton(), + Spacer(), + ], + ), + Text('Data Usage View'), + ], + ); + } +} diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index ce3c333..2495b8e 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -36,7 +36,13 @@ class _HomeViewState extends State { TopBar( title: "Settings", children: [ - BackButton(), + Visibility( + child: BackButton(), + maintainSize: true, + maintainAnimation: true, + maintainState: true, + visible: false, + ), Spacer(), ], ), @@ -127,9 +133,11 @@ class _HomeViewState extends State { ), Divider(), ListButton( - icon: Icons.notifications, - text: 'Notifications', - onClickCallback: () {}, + icon: Icons.color_lens, + text: 'Interface', + onClickCallback: () { + Navigator.of(context).pushNamed("settings/interface"); + }, textStyle: Theme.of(context) .textTheme .title @@ -137,9 +145,11 @@ class _HomeViewState extends State { iconColor: Theme.of(context).primaryColorDark, ), ListButton( - icon: Icons.color_lens, - text: 'Interface', - onClickCallback: () {}, + icon: Icons.notifications, + text: 'Notifications', + onClickCallback: () { + Navigator.of(context).pushNamed("settings/notifications"); + }, textStyle: Theme.of(context) .textTheme .title @@ -149,7 +159,9 @@ class _HomeViewState extends State { ListButton( icon: Icons.security, text: 'Privacy and Security', - onClickCallback: () {}, + onClickCallback: () { + Navigator.of(context).pushNamed("settings/privacy_security"); + }, textStyle: Theme.of(context) .textTheme .title @@ -159,7 +171,9 @@ class _HomeViewState extends State { ListButton( icon: Icons.data_usage, text: 'Data Usage', - onClickCallback: () {}, + onClickCallback: () { + Navigator.of(context).pushNamed("settings/data_usage"); + }, textStyle: Theme.of(context) .textTheme .title diff --git a/lib/src/ui/settings_tab/widgets/interface_view.dart b/lib/src/ui/settings_tab/widgets/interface_view.dart new file mode 100644 index 0000000..29b375b --- /dev/null +++ b/lib/src/ui/settings_tab/widgets/interface_view.dart @@ -0,0 +1,29 @@ +import "package:flutter/material.dart"; + +import "../../widgets/top_bar.dart"; +import "../../widgets/list_button.dart"; + +class InterfaceView extends StatefulWidget { + @override + State createState() { + return _InterfaceViewState(); + } +} + +class _InterfaceViewState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + TopBar( + title: "Interface", + children: [ + BackButton(), + Spacer(), + ], + ), + Text('Interface View'), + ], + ); + } +} diff --git a/lib/src/ui/settings_tab/widgets/notifications_view.dart b/lib/src/ui/settings_tab/widgets/notifications_view.dart new file mode 100644 index 0000000..e7b2da8 --- /dev/null +++ b/lib/src/ui/settings_tab/widgets/notifications_view.dart @@ -0,0 +1,29 @@ +import "package:flutter/material.dart"; + +import "../../widgets/top_bar.dart"; +import "../../widgets/list_button.dart"; + +class NotificationsView extends StatefulWidget { + @override + State createState() { + return _NotificationsViewState(); + } +} + +class _NotificationsViewState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + TopBar( + title: "Notifications", + children: [ + BackButton(), + Spacer(), + ], + ), + Text('Notifications View'), + ], + ); + } +} diff --git a/lib/src/ui/settings_tab/widgets/privacy_security_view.dart b/lib/src/ui/settings_tab/widgets/privacy_security_view.dart new file mode 100644 index 0000000..4f84ac0 --- /dev/null +++ b/lib/src/ui/settings_tab/widgets/privacy_security_view.dart @@ -0,0 +1,29 @@ +import "package:flutter/material.dart"; + +import "../../widgets/top_bar.dart"; +import "../../widgets/list_button.dart"; + +class PrivacySecurityView extends StatefulWidget { + @override + State createState() { + return _PrivacySecurityViewState(); + } +} + +class _PrivacySecurityViewState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + TopBar( + title: "Privacy and Security", + children: [ + BackButton(), + Spacer(), + ], + ), + Text('Privacy and Security View'), + ], + ); + } +} From e0e2eeba7b3766a30616db3d8dde979402fdaf4b Mon Sep 17 00:00:00 2001 From: shihern Date: Tue, 20 Aug 2019 21:10:51 +0800 Subject: [PATCH 09/16] refactor: use local variable for text styles --- .../ui/settings_tab/widgets/home_view.dart | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/lib/src/ui/settings_tab/widgets/home_view.dart b/lib/src/ui/settings_tab/widgets/home_view.dart index 2495b8e..8507fc6 100644 --- a/lib/src/ui/settings_tab/widgets/home_view.dart +++ b/lib/src/ui/settings_tab/widgets/home_view.dart @@ -31,6 +31,10 @@ class _HomeViewState extends State { @override Widget build(BuildContext context) { + var _titleTheme = Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor); return Column( children: [ TopBar( @@ -99,10 +103,7 @@ class _HomeViewState extends State { } }); }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), + textStyle: _titleTheme, iconColor: Theme.of(context).primaryColorDark, ), ListButton( @@ -125,10 +126,7 @@ class _HomeViewState extends State { } }); }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), + textStyle: _titleTheme, iconColor: Theme.of(context).primaryColorDark, ), Divider(), @@ -138,10 +136,7 @@ class _HomeViewState extends State { onClickCallback: () { Navigator.of(context).pushNamed("settings/interface"); }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), + textStyle: _titleTheme, iconColor: Theme.of(context).primaryColorDark, ), ListButton( @@ -150,10 +145,7 @@ class _HomeViewState extends State { onClickCallback: () { Navigator.of(context).pushNamed("settings/notifications"); }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), + textStyle: _titleTheme, iconColor: Theme.of(context).primaryColorDark, ), ListButton( @@ -162,10 +154,7 @@ class _HomeViewState extends State { onClickCallback: () { Navigator.of(context).pushNamed("settings/privacy_security"); }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), + textStyle: _titleTheme, iconColor: Theme.of(context).primaryColorDark, ), ListButton( @@ -174,10 +163,7 @@ class _HomeViewState extends State { onClickCallback: () { Navigator.of(context).pushNamed("settings/data_usage"); }, - textStyle: Theme.of(context) - .textTheme - .title - .copyWith(color: Theme.of(context).accentColor), + textStyle: _titleTheme, iconColor: Theme.of(context).primaryColorDark, ), Divider(), From db07c8cb43edb104485611c5aff52f3cbf268f97 Mon Sep 17 00:00:00 2001 From: shihern Date: Tue, 20 Aug 2019 21:11:16 +0800 Subject: [PATCH 10/16] feat: add text-only list button --- lib/src/ui/widgets/list_text_button.dart | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/src/ui/widgets/list_text_button.dart diff --git a/lib/src/ui/widgets/list_text_button.dart b/lib/src/ui/widgets/list_text_button.dart new file mode 100644 index 0000000..ec1b637 --- /dev/null +++ b/lib/src/ui/widgets/list_text_button.dart @@ -0,0 +1,57 @@ +import "package:flutter/material.dart"; + +typedef void OnClickCallback(); + +class ListTextButton extends StatelessWidget { + final String text; + final OnClickCallback onClickCallback; + final String subtitle; + final TextStyle textStyle; + final TextStyle subtitleStyle; + + ListTextButton({ + @required this.text, + @required this.onClickCallback, + this.subtitle, + this.textStyle, + this.subtitleStyle, + }); + + @override + Widget build(BuildContext context) { + return Material( + type: MaterialType.transparency, + elevation: 1, + child: InkWell( + onTap: onClickCallback, + child: Container( + padding: + EdgeInsets.only(left: 15.0, right: 15.0, top: 12.0, bottom: 12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + text, + style: textStyle ?? + Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).primaryColorDark), + ), + (subtitle == null) + ? Container() + : Padding( + padding: EdgeInsets.only(top: 3.0), + child: Text( + subtitle, + style: subtitleStyle ?? + Theme.of(context).textTheme.subtitle, + ), + ), + ], + ), + ), + ), + ); + } +} From 8119de8afae74034b0c5070d947821576072c3e6 Mon Sep 17 00:00:00 2001 From: shihern Date: Tue, 20 Aug 2019 21:31:44 +0800 Subject: [PATCH 11/16] feat: add basic interface options --- .../settings_tab/widgets/interface_view.dart | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/settings_tab/widgets/interface_view.dart b/lib/src/ui/settings_tab/widgets/interface_view.dart index 29b375b..ac9c7bb 100644 --- a/lib/src/ui/settings_tab/widgets/interface_view.dart +++ b/lib/src/ui/settings_tab/widgets/interface_view.dart @@ -1,4 +1,5 @@ import "package:flutter/material.dart"; +import 'package:frontend_flutter/src/ui/widgets/list_text_button.dart'; import "../../widgets/top_bar.dart"; import "../../widgets/list_button.dart"; @@ -11,8 +12,15 @@ class InterfaceView extends StatefulWidget { } class _InterfaceViewState extends State { + bool _enterToSend = false; + @override Widget build(BuildContext context) { + var _buttonTextTheme = Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor); + return Column( children: [ TopBar( @@ -22,7 +30,37 @@ class _InterfaceViewState extends State { Spacer(), ], ), - Text('Interface View'), + Expanded( + child: ListView( + padding: EdgeInsets.only(top: 0.0), + children: [ + SwitchListTile( + title: Text('Enter to Send', style: _buttonTextTheme), + value: _enterToSend, + onChanged: (bool value) { + setState(() { + _enterToSend = value; + }); + }, + ), + ListTextButton( + text: 'Font Size', + subtitle: 'Medium', + textStyle: _buttonTextTheme, + onClickCallback: () { + + }, + ), + ListTextButton( + text: 'Wallpaper', + textStyle: _buttonTextTheme, + onClickCallback: () { + + }, + ), + ], + ), + ), ], ); } From f6c57b67a78ea598856585b7097ed4a5f8b829f7 Mon Sep 17 00:00:00 2001 From: shihern Date: Tue, 20 Aug 2019 21:42:04 +0800 Subject: [PATCH 12/16] fix: height of button is always fixed --- lib/src/ui/widgets/list_text_button.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/ui/widgets/list_text_button.dart b/lib/src/ui/widgets/list_text_button.dart index ec1b637..56be5df 100644 --- a/lib/src/ui/widgets/list_text_button.dart +++ b/lib/src/ui/widgets/list_text_button.dart @@ -25,10 +25,12 @@ class ListTextButton extends StatelessWidget { child: InkWell( onTap: onClickCallback, child: Container( + height: 62.0, padding: EdgeInsets.only(left: 15.0, right: 15.0, top: 12.0, bottom: 12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ Text( text, From 064972bf5e795d8c6a6b74f21094f430d22c94d7 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 24 Aug 2019 17:26:28 +0800 Subject: [PATCH 13/16] fix: add default button height --- lib/src/ui/widgets/list_text_button.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/ui/widgets/list_text_button.dart b/lib/src/ui/widgets/list_text_button.dart index 56be5df..bd57def 100644 --- a/lib/src/ui/widgets/list_text_button.dart +++ b/lib/src/ui/widgets/list_text_button.dart @@ -25,7 +25,7 @@ class ListTextButton extends StatelessWidget { child: InkWell( onTap: onClickCallback, child: Container( - height: 62.0, + height: (subtitle == null) ? 62.0 : null, // Default height if no subtitles padding: EdgeInsets.only(left: 15.0, right: 15.0, top: 12.0, bottom: 12.0), child: Column( From 841b3f14381a665f1608e45f5d73cdd89f202ef2 Mon Sep 17 00:00:00 2001 From: shihern Date: Sat, 24 Aug 2019 17:27:06 +0800 Subject: [PATCH 14/16] feat: add notification settings view --- .../widgets/notifications_view.dart | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/src/ui/settings_tab/widgets/notifications_view.dart b/lib/src/ui/settings_tab/widgets/notifications_view.dart index e7b2da8..e0c0a23 100644 --- a/lib/src/ui/settings_tab/widgets/notifications_view.dart +++ b/lib/src/ui/settings_tab/widgets/notifications_view.dart @@ -1,7 +1,7 @@ import "package:flutter/material.dart"; +import 'package:frontend_flutter/src/ui/widgets/list_text_button.dart'; import "../../widgets/top_bar.dart"; -import "../../widgets/list_button.dart"; class NotificationsView extends StatefulWidget { @override @@ -11,8 +11,14 @@ class NotificationsView extends StatefulWidget { } class _NotificationsViewState extends State { + bool _inChatSounds = false; + @override Widget build(BuildContext context) { + var _buttonTextTheme = Theme.of(context) + .textTheme + .title + .copyWith(color: Theme.of(context).accentColor); return Column( children: [ TopBar( @@ -22,7 +28,38 @@ class _NotificationsViewState extends State { Spacer(), ], ), - Text('Notifications View'), + Expanded( + child: ListView( + padding: EdgeInsets.only(top: 0.0), + children: [ + SwitchListTile( + title: Text('In-Chat Sounds', style: _buttonTextTheme), + value: _inChatSounds, + onChanged: (bool value) { + setState(() { + _inChatSounds = value; + }); + }, + ), + ListTextButton( + text: 'Notification Sound', + subtitle: 'Default', + textStyle: _buttonTextTheme, + onClickCallback: () { + + }, + ), + ListTextButton( + text: 'Vibrate', + subtitle: 'Default', + textStyle: _buttonTextTheme, + onClickCallback: () { + + }, + ), + ], + ), + ), ], ); } From beab1448bfde28206ba60ba2225054af32c90a38 Mon Sep 17 00:00:00 2001 From: Sudharshan Date: Sat, 31 Aug 2019 11:52:29 +0800 Subject: [PATCH 15/16] feat: added in the pinned conversation support to the bottom bar --- lib/src/blocs/conversation_bloc.dart | 5 +- .../widgets/conversation_inactive_view.dart | 63 ++++++++++++------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/lib/src/blocs/conversation_bloc.dart b/lib/src/blocs/conversation_bloc.dart index 66fe24a..67a6be1 100644 --- a/lib/src/blocs/conversation_bloc.dart +++ b/lib/src/blocs/conversation_bloc.dart @@ -11,8 +11,9 @@ class ConversationsBloc { _conversationsFetcher.stream; Observable> get pinnedConversations => - _conversationsFetcher.stream.map((conversationList) => - conversationList.where((conversation) => conversation.pinned)); + _conversationsFetcher.stream.map((conversationList) => conversationList + .where((conversation) => conversation.pinned ?? false) + .toList()); fetchConversations() async { List conversationList = diff --git a/lib/src/ui/bottom_bar/widgets/conversation_inactive_view.dart b/lib/src/ui/bottom_bar/widgets/conversation_inactive_view.dart index 431d0bb..125aa6d 100644 --- a/lib/src/ui/bottom_bar/widgets/conversation_inactive_view.dart +++ b/lib/src/ui/bottom_bar/widgets/conversation_inactive_view.dart @@ -1,33 +1,52 @@ import "package:flutter/material.dart"; import "../../widgets/image_avatar.dart"; -import "../../../models/user_model.dart"; +import "../../../models/conversation_model.dart"; +import "../../../blocs/conversation_bloc.dart"; + +class ConversationInactiveView extends StatefulWidget { + @override + State createState() { + return _ConversationInactiveViewState(); + } +} + +class _ConversationInactiveViewState extends State { + @override + initState() { + super.initState(); + conversationsBloc.fetchConversations(); + } -class ConversationInactiveView extends StatelessWidget { @override Widget build(BuildContext context) { return Container( child: Column(mainAxisSize: MainAxisSize.min, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - ImageAvatar( - radius: 18, - padding: EdgeInsets.only(right: 5.0), - info: ImageAvatarInfo.fromUser( - User("1", "Isaac", "Tay", "+65 91043593", "", "", ""))), - ImageAvatar( - radius: 18, - padding: EdgeInsets.only(right: 5.0), - info: ImageAvatarInfo.fromUser( - User("1", "Isaac", "Tay", "+65 91043593", "", "", ""))), - ImageAvatar( - radius: 18, - padding: EdgeInsets.only(right: 5.0), - info: ImageAvatarInfo.fromUser( - User("1", "Isaac", "Tay", "+65 91043593", "", "", ""))) - ]) + StreamBuilder( + stream: conversationsBloc.pinnedConversations, + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.hasData) { + return Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: (snapshot.data.length < 1) + ? [ + Spacer(), + Text("No pinned conversations :("), + Spacer() + ] + : snapshot.data + .map((conversation) => ImageAvatar( + radius: 18, + padding: EdgeInsets.only(right: 5.0), + info: ImageAvatarInfo.fromConversation( + conversation))) + .toList()); + } else if (snapshot.hasError) { + return Text(snapshot.error.toString()); + } + return Center(child: CircularProgressIndicator()); + }) ])); } } From d4de5a174bcf98c0e5544caa293edd9d77768769 Mon Sep 17 00:00:00 2001 From: Sudharshan Date: Sat, 31 Aug 2019 12:10:36 +0800 Subject: [PATCH 16/16] feat: implemented full pinning support --- lib/src/resources/conversation_api_provider.dart | 16 ++++++++++++++-- lib/src/ui/widgets/conversation_item.dart | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/src/resources/conversation_api_provider.dart b/lib/src/resources/conversation_api_provider.dart index 08d9c92..ba0ec53 100644 --- a/lib/src/resources/conversation_api_provider.dart +++ b/lib/src/resources/conversation_api_provider.dart @@ -42,6 +42,7 @@ class ConversationApiProvider { HttpHeaders.contentTypeHeader: "application/json", HttpHeaders.authorizationHeader: "Bearer $jwt" }); + print(responseBody); return jsonDecode(responseBody) .map( (conversation) => Conversation.fromJson(conversation)) @@ -69,8 +70,7 @@ class ConversationApiProvider { Future deleteConversation(String id) async { final jwt = await loginManager.getToken(); try { - final responseBody = - await http.delete("$baseUrlCore/user/conversation/$id", headers: { + await http.delete("$baseUrlCore/user/conversation/$id", headers: { HttpHeaders.contentTypeHeader: "application/json", HttpHeaders.authorizationHeader: "Bearer $jwt" }); @@ -79,6 +79,18 @@ class ConversationApiProvider { } } + Future pinConversation(String id) async { + final jwt = await loginManager.getToken(); + try { + await http.post("$baseUrlCore/user/conversation/$id/pin", headers: { + HttpHeaders.contentTypeHeader: " application/json", + HttpHeaders.authorizationHeader: "Bearer $jwt" + }); + } catch (e) { + throw e; + } + } + Future createConversationMember( String conversationId, String userId) async { final jwt = await loginManager.getToken(); diff --git a/lib/src/ui/widgets/conversation_item.dart b/lib/src/ui/widgets/conversation_item.dart index 96d6111..851f222 100644 --- a/lib/src/ui/widgets/conversation_item.dart +++ b/lib/src/ui/widgets/conversation_item.dart @@ -142,7 +142,13 @@ class _ConversationItemState extends State { // onTap: () => print('Pin'))], secondaryActions: [ IconSlideAction( - color: Colors.green, icon: Icons.star, onTap: () => print('Pin')), + color: Colors.green, + icon: Icons.star, + onTap: () async { + await conversationApiProvider + .pinConversation(widget.conversation.id); + await conversationsBloc.fetchConversations(); + }), IconSlideAction( color: Colors.red, icon: Icons.delete,