Implement profile page

parent aefe6584
......@@ -33,6 +33,8 @@ import 'package:pattle/src/ui/start/phase/key/password_page.dart';
import 'package:pattle/src/ui/start/start_page.dart';
import 'package:pattle/src/ui/main/overview/create/group/create_group_members_page.dart';
import 'ui/main/overview/create/group/create_group_details_page.dart';
import 'ui/main/settings/name_page.dart';
import 'ui/main/settings/profile_page.dart';
import 'ui/main/settings/settings_page.dart';
final routes = {
......@@ -44,6 +46,14 @@ final routes = {
settings: RouteSettings(name: Routes.settings),
builder: (context) => SettingsPage(),
),
Routes.settingsProfile: (Object params) => MaterialPageRoute(
settings: RouteSettings(name: Routes.settingsProfile),
builder: (context) => ProfilePage(),
),
Routes.settingsProfileName: (Object params) => MaterialPageRoute(
settings: RouteSettings(name: Routes.settingsProfileName),
builder: (context) => NamePage(),
),
Routes.settingsAppearance: (Object params) => MaterialPageRoute(
settings: RouteSettings(name: Routes.settingsAppearance),
builder: (context) => AppearancePage(),
......@@ -91,6 +101,8 @@ class Routes {
static const root = '/';
static const settings = '/settings';
static const settingsProfile = '/settings/profile';
static const settingsProfileName = '/settings/profile/name';
static const settingsAppearance = '/settings/appearance';
static const chats = '/chats';
static const chatsSettings = '/chats/settings';
......
......@@ -19,6 +19,8 @@ import 'package:flutter/material.dart';
import 'package:pattle/src/ui/main/settings/settings_bloc.dart';
import 'package:pattle/src/ui/resources/theme.dart';
import 'package:pattle/src/ui/main/settings/widgets/header.dart';
class AppearancePageState extends State<AppearancePage> {
final bloc = SettingsBloc();
......
// Copyright (C) 2019 Wilko Manger
//
// This file is part of Pattle.
//
// Pattle is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pattle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pattle/src/ui/main/settings/settings_bloc.dart';
import 'package:pattle/src/ui/resources/theme.dart';
import 'package:pattle/src/ui/util/user.dart';
class NamePageState extends State<NamePage> {
final bloc = SettingsBloc();
final textController = TextEditingController();
@override
void initState() {
super.initState();
final name = displayNameOf(bloc.me);
textController.value = TextEditingValue(
text: name,
selection: TextSelection(baseOffset: 0, extentOffset: name.length),
);
}
@override
void dispose() {
super.dispose();
}
Future<void> setName() async {
await bloc.setDisplayName(textController.text);
Navigator.pop(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Name',
style: TextStyle(
color: redOnBackground(context),
),
),
brightness: Theme.of(context).brightness,
iconTheme: IconThemeData(
color: redOnBackground(context),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.check),
onPressed: setName,
)
],
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
),
body: Column(
children: <Widget>[
TextField(
autofocus: true,
controller: textController,
autocorrect: false,
cursorColor: Colors.white,
style: TextStyle(
color: Colors.white,
),
textCapitalization: TextCapitalization.words,
decoration: InputDecoration(
filled: true,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.zero,
),
fillColor: LightColors.red,
focusColor: Colors.white,
),
onSubmitted: (_) => setName(),
),
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(16),
child: Icon(
Icons.info_outline,
size: 28,
color: Theme.of(context).textTheme.caption.color,
),
),
Text(
'This is how you will display to others',
style: TextStyle(
color: Theme.of(context).textTheme.caption.color,
),
)
],
)
],
),
);
}
}
class NamePage extends StatefulWidget {
@override
State<StatefulWidget> createState() => NamePageState();
}
......@@ -14,11 +14,14 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:dynamic_theme/dynamic_theme.dart';
import 'package:flutter/material.dart';
import 'package:pattle/src/ui/main/settings/settings_bloc.dart';
import 'package:pattle/src/ui/main/widgets/user_avatar.dart';
import 'package:pattle/src/ui/resources/theme.dart';
import 'package:pattle/src/ui/util/user.dart';
import '../../../app.dart';
class ProfilePageState extends State<ProfilePage> {
final bloc = SettingsBloc();
......@@ -43,13 +46,61 @@ class ProfilePageState extends State<ProfilePage> {
appBar: AppBar(
title: Text('Profile'),
),
body: Column(
children: <Widget>[
UserAvatar(
user: bloc.me,
radius: 48,
)
],
body: Center(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(16),
child: Stack(
overflow: Overflow.visible,
children: <Widget>[
Hero(
tag: bloc.me.id,
child: UserAvatar(
user: bloc.me,
radius: 96,
),
),
Positioned(
right: -1,
bottom: -1,
child: FloatingActionButton(
child: Icon(Icons.photo_camera),
onPressed: () {},
),
)
],
),
),
Expanded(
child: ListView(
children: <Widget>[
ListTile(
leading: Icon(
Icons.person,
color: redOnBackground(context),
),
title: Text('Name'),
subtitle: Text(displayNameOf(bloc.me)),
trailing: Icon(Icons.edit),
onTap: () => Navigator.pushNamed(
context,
Routes.settingsProfileName,
),
),
ListTile(
leading: Icon(
Icons.alternate_email,
color: redOnBackground(context),
),
title: Text('Username'),
subtitle: Text(bloc.me.id.toString()),
)
],
),
)
],
),
),
);
}
......
......@@ -28,5 +28,7 @@ class SettingsBloc extends Bloc {
factory SettingsBloc() => _instance;
void useDarkTheme() {}
Future<void> setDisplayName(String name) async {
await me.setName(name);
}
}
......@@ -47,15 +47,20 @@ class SettingsPageState extends State<SettingsPage> {
children: <Widget>[
Material(
child: InkWell(
onTap: () {},
onTap: () {
Navigator.pushNamed(context, Routes.settingsProfile);
},
child: Padding(
padding: EdgeInsets.all(16),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
UserAvatar(
user: bloc.me,
radius: 36,
Hero(
tag: bloc.me.id,
child: UserAvatar(
user: bloc.me,
radius: 36,
),
),
Padding(
padding: EdgeInsets.only(left: 16),
......
......@@ -220,7 +220,7 @@ packages:
name: matrix_sdk
url: "https://pub.dartlang.org"
source: hosted
version: "0.24.0"
version: "0.24.2"
matrix_sdk_sqflite:
dependency: "direct main"
description:
......
......@@ -12,7 +12,7 @@ dependencies:
injector: ^1.0.8
matrix_sdk: ^0.24.0
matrix_sdk: ^0.24.2
matrix_sdk_sqflite: ^0.18.0
sqflite: ^1.1.6
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment