Clean up design

This commit is contained in:
Christian Pauly 2020-02-23 08:49:58 +01:00
parent 5c4d9cc12f
commit 7dbb603ef2
16 changed files with 144 additions and 204 deletions

View File

@ -2,9 +2,7 @@ import 'package:bubble/bubble.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/event_extension.dart'; import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/views/content_web_view.dart';
import 'package:fluffychat/views/image_viewer.dart'; import 'package:fluffychat/views/image_viewer.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -77,12 +75,8 @@ class MessageContent extends StatelessWidget {
), ),
], ],
), ),
onPressed: () => Navigator.of(context).push( onPressed: () => launch(MxContent(event.content["url"])
AppRoute.defaultRoute( .getDownloadLink(event.room.client)),
context,
ContentWebView(MxContent(event.content["url"])),
),
),
), ),
); );
case MessageTypes.Video: case MessageTypes.Video:
@ -102,11 +96,9 @@ class MessageContent extends StatelessWidget {
), ),
], ],
), ),
onPressed: () => Navigator.of(context).push( onPressed: () => launch(
AppRoute.defaultRoute( MxContent(event.content["url"])
context, .getDownloadLink(event.room.client),
ContentWebView(MxContent(event.content["url"])),
),
), ),
), ),
); );

View File

@ -0,0 +1,86 @@
import 'package:flutter/material.dart';
import '../components/theme_switcher.dart';
import '../components/matrix.dart';
import '../i18n/i18n.dart';
class ThemesSettings extends StatefulWidget {
@override
ThemesSettingsState createState() => ThemesSettingsState();
}
class ThemesSettingsState extends State<ThemesSettings> {
Themes _selectedTheme;
bool _amoledEnabled;
@override
Widget build(BuildContext context) {
final MatrixState matrix = Matrix.of(context);
final ThemeSwitcherWidgetState themeEngine =
ThemeSwitcherWidget.of(context);
_selectedTheme = themeEngine.selectedTheme;
_amoledEnabled = themeEngine.amoledEnabled;
return Column(
children: <Widget>[
RadioListTile<Themes>(
title: Text(
I18n.of(context).systemTheme,
),
value: Themes.system,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
RadioListTile<Themes>(
title: Text(
I18n.of(context).lightTheme,
),
value: Themes.light,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
RadioListTile<Themes>(
title: Text(
I18n.of(context).darkTheme,
),
value: Themes.dark,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
ListTile(
title: Text(
I18n.of(context).useAmoledTheme,
),
trailing: Switch(
value: _amoledEnabled,
activeColor: Theme.of(context).primaryColor,
onChanged: (bool value) {
setState(() {
_amoledEnabled = value;
themeEngine.switchTheme(matrix, _selectedTheme, value);
});
},
),
),
],
);
}
}

View File

@ -967,7 +967,7 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"Change your style": "Change your style", "Change your style": "Ändere Deinen Style",
"@Change your style": { "@Change your style": {
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}

View File

@ -151,7 +151,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Banned" : MessageLookupByLibrary.simpleMessage("Banned"), "Banned" : MessageLookupByLibrary.simpleMessage("Banned"),
"Change the name of the group" : MessageLookupByLibrary.simpleMessage("Gruppenname ändern"), "Change the name of the group" : MessageLookupByLibrary.simpleMessage("Gruppenname ändern"),
"Change the server" : MessageLookupByLibrary.simpleMessage("Ändere den Server"), "Change the server" : MessageLookupByLibrary.simpleMessage("Ändere den Server"),
"Change your style" : MessageLookupByLibrary.simpleMessage("Change your style"), "Change your style" : MessageLookupByLibrary.simpleMessage("Ändere Deinen Style"),
"Changelog" : MessageLookupByLibrary.simpleMessage("Changelog"), "Changelog" : MessageLookupByLibrary.simpleMessage("Changelog"),
"Chat details" : MessageLookupByLibrary.simpleMessage("Gruppeninfo"), "Chat details" : MessageLookupByLibrary.simpleMessage("Gruppeninfo"),
"Choose a username" : MessageLookupByLibrary.simpleMessage("Wähle einen Benutzernamen"), "Choose a username" : MessageLookupByLibrary.simpleMessage("Wähle einen Benutzernamen"),

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -19,7 +21,7 @@ class App extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Matrix( return Matrix(
clientName: "FluffyChat", clientName: "FluffyChat ${Platform.operatingSystem}",
child: Builder( child: Builder(
builder: (BuildContext context) => ThemeSwitcherWidget( builder: (BuildContext context) => ThemeSwitcherWidget(
child: Builder( child: Builder(

View File

@ -230,9 +230,7 @@ extension LocalizedBody on Event {
// Hide reply fallback // Hide reply fallback
if (hideReply) { if (hideReply) {
localizedBody = localizedBody.replaceFirst( localizedBody = localizedBody.replaceFirst(
RegExp( RegExp(r'^>( \*)? <[^>]+>[^\n\r]+\r?\n(> [^\n]*\r?\n)*\r?\n'), "");
r'^>( \*)? <@[a-zA-Z0-9-.=_\/]+:[^>]+>[^\n]+\r?\n(> [^\n]+\r?\n)*\r?\n'),
"");
} }
// Add the sender name prefix // Add the sender name prefix

View File

@ -24,7 +24,7 @@ class AppInfo extends StatelessWidget {
Client client = Matrix.of(context).client; Client client = Matrix.of(context).client;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("About FluffyChat"), title: Text(I18n.of(context).accountInformations),
), ),
body: ListView( body: ListView(
children: <Widget>[ children: <Widget>[

View File

@ -419,7 +419,6 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
), ),
), ),
Divider(height: 1),
widget.room.canInvite widget.room.canInvite
? ListTile( ? ListTile(
title: Text(I18n.of(context).inviteContact), title: Text(I18n.of(context).inviteContact),

View File

@ -315,7 +315,7 @@ class _ChatListState extends State<ChatList> {
? Material( ? Material(
elevation: 2, elevation: 2,
child: ListTile( child: ListTile(
title: Text("Public Rooms:"), title: Text(I18n.of(context).publicRooms),
), ),
) )
: Divider(indent: 70, height: 1), : Divider(indent: 70, height: 1),

View File

@ -1,35 +0,0 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart';
class ContentWebView extends StatelessWidget {
final MxContent content;
const ContentWebView(this.content);
@override
Widget build(BuildContext context) {
final String url = content.getDownloadLink(Matrix.of(context).client);
return Scaffold(
appBar: AppBar(
title: Text(
I18n.of(context).contentViewer,
),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.file_download,
),
onPressed: () => launch(url),
),
],
),
body: WebView(
initialUrl: url,
),
);
}
}

View File

@ -2,7 +2,6 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -13,22 +12,21 @@ class ImageViewer extends StatelessWidget {
const ImageViewer(this.mxContent); const ImageViewer(this.mxContent);
static show(BuildContext context, MxContent content) { static show(BuildContext context, MxContent content) {
if (kIsWeb) {
launch(content.getDownloadLink(Matrix.of(context).client));
} else {
Navigator.of(context).push( Navigator.of(context).push(
AppRoute( AppRoute(
ImageViewer(content), ImageViewer(content),
), ),
); );
} }
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String url = mxContent.getDownloadLink(Matrix.of(context).client); final String url = mxContent.getDownloadLink(Matrix.of(context).client);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
brightness: Brightness.dark,
backgroundColor: Colors.black,
iconTheme: IconThemeData(color: Colors.white),
actions: <Widget>[ actions: <Widget>[
IconButton( IconButton(
icon: Icon(Icons.file_download), icon: Icon(Icons.file_download),

View File

@ -123,7 +123,7 @@ class _InvitationSelectionState extends State<InvitationSelection> {
appBar: AppBar( appBar: AppBar(
title: Text(I18n.of(context).inviteContact), title: Text(I18n.of(context).inviteContact),
bottom: PreferredSize( bottom: PreferredSize(
preferredSize: Size.fromHeight(68), preferredSize: Size.fromHeight(92),
child: Padding( child: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: TextField( child: TextField(

View File

@ -1,6 +1,7 @@
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pedantic/pedantic.dart'; import 'package:pedantic/pedantic.dart';
@ -47,11 +48,11 @@ class _NewGroupState extends State<_NewGroup> {
Navigator.of(context).pop(); Navigator.of(context).pop();
if (roomID != null) { if (roomID != null) {
unawaited( unawaited(
Navigator.push( Navigator.of(context).push(
AppRoute.defaultRoute(
context, context,
MaterialPageRoute(builder: (context) { ChatView(roomID),
return ChatView(roomID); ),
}),
), ),
); );
await Navigator.push( await Navigator.push(

View File

@ -5,6 +5,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/avatar.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:share/share.dart'; import 'package:share/share.dart';
@ -58,9 +59,11 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
Navigator.of(context).pop(); Navigator.of(context).pop();
if (roomID != null) { if (roomID != null) {
await Navigator.push( await Navigator.of(context).push(
AppRoute.defaultRoute(
context, context,
MaterialPageRoute(builder: (context) => ChatView(roomID)), ChatView(roomID),
),
); );
} }
} }

View File

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/settings_themes.dart';
import 'package:fluffychat/views/settings_devices.dart'; import 'package:fluffychat/views/settings_devices.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
@ -9,10 +10,9 @@ import 'package:url_launcher/url_launcher.dart';
import 'app_info.dart'; import 'app_info.dart';
import 'chat_list.dart'; import 'chat_list.dart';
import 'settings_themes.dart'; import '../components/adaptive_page_layout.dart';
import 'sign_up.dart'; import 'sign_up.dart';
import '../components/dialogs/simple_dialogs.dart'; import '../components/dialogs/simple_dialogs.dart';
import '../components/adaptive_page_layout.dart';
import '../components/content_banner.dart'; import '../components/content_banner.dart';
import '../components/matrix.dart'; import '../components/matrix.dart';
import '../i18n/i18n.dart'; import '../i18n/i18n.dart';
@ -132,6 +132,17 @@ class _SettingsState extends State<Settings> {
], ],
body: ListView( body: ListView(
children: <Widget>[ children: <Widget>[
ListTile(
title: Text(
I18n.of(context).changeTheme,
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
),
),
ThemesSettings(),
Divider(thickness: 1),
ListTile( ListTile(
title: Text( title: Text(
I18n.of(context).account, I18n.of(context).account,
@ -147,16 +158,6 @@ class _SettingsState extends State<Settings> {
subtitle: Text(profile?.displayname ?? client.userID.localpart), subtitle: Text(profile?.displayname ?? client.userID.localpart),
onTap: () => setDisplaynameAction(context), onTap: () => setDisplaynameAction(context),
), ),
ListTile(
trailing: Icon(Icons.color_lens),
title: Text(I18n.of(context).changeTheme),
onTap: () async => await Navigator.of(context).push(
AppRoute.defaultRoute(
context,
ThemesSettingsView(),
),
),
),
ListTile( ListTile(
trailing: Icon(Icons.devices_other), trailing: Icon(Icons.devices_other),
title: Text(I18n.of(context).devices), title: Text(I18n.of(context).devices),
@ -167,6 +168,16 @@ class _SettingsState extends State<Settings> {
), ),
), ),
), ),
ListTile(
trailing: Icon(Icons.account_circle),
title: Text(I18n.of(context).accountInformations),
onTap: () => Navigator.of(context).push(
AppRoute.defaultRoute(
context,
AppInfoView(),
),
),
),
ListTile( ListTile(
trailing: Icon(Icons.exit_to_app), trailing: Icon(Icons.exit_to_app),
title: Text(I18n.of(context).logout), title: Text(I18n.of(context).logout),
@ -190,7 +201,7 @@ class _SettingsState extends State<Settings> {
onTap: () => launch("https://ko-fi.com/V7V315112"), onTap: () => launch("https://ko-fi.com/V7V315112"),
), ),
ListTile( ListTile(
leading: Icon(Icons.donut_large), leading: Icon(Icons.local_atm),
title: Text("Liberapay " + I18n.of(context).donate), title: Text("Liberapay " + I18n.of(context).donate),
onTap: () => onTap: () =>
launch("https://liberapay.com/KrilleChritzelius/donate"), launch("https://liberapay.com/KrilleChritzelius/donate"),
@ -201,16 +212,6 @@ class _SettingsState extends State<Settings> {
onTap: () => launch( onTap: () => launch(
"https://gitlab.com/ChristianPauly/fluffychat-flutter/issues"), "https://gitlab.com/ChristianPauly/fluffychat-flutter/issues"),
), ),
ListTile(
leading: Icon(Icons.account_circle),
title: Text(I18n.of(context).accountInformations),
onTap: () => Navigator.of(context).push(
AppRoute.defaultRoute(
context,
AppInfoView(),
),
),
),
ListTile( ListTile(
leading: Icon(Icons.list), leading: Icon(Icons.list),
title: Text(I18n.of(context).changelog), title: Text(I18n.of(context).changelog),

View File

@ -1,105 +0,0 @@
import 'package:flutter/material.dart';
import '../components/theme_switcher.dart';
import '../components/adaptive_page_layout.dart';
import '../components/matrix.dart';
import '../i18n/i18n.dart';
import 'chat_list.dart';
class ThemesSettingsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AdaptivePageLayout(
primaryPage: FocusPage.SECOND,
firstScaffold: ChatList(),
secondScaffold: ThemesSettings(),
);
}
}
class ThemesSettings extends StatefulWidget {
@override
ThemesSettingsState createState() => ThemesSettingsState();
}
class ThemesSettingsState extends State<ThemesSettings> {
Themes _selectedTheme;
bool _amoledEnabled;
@override
Widget build(BuildContext context) {
final MatrixState matrix = Matrix.of(context);
final ThemeSwitcherWidgetState themeEngine =
ThemeSwitcherWidget.of(context);
_selectedTheme = themeEngine.selectedTheme;
_amoledEnabled = themeEngine.amoledEnabled;
return Scaffold(
appBar: AppBar(
title: Text(I18n.of(context).changeTheme),
),
body: Column(
children: <Widget>[
RadioListTile<Themes>(
title: Text(
I18n.of(context).systemTheme,
),
value: Themes.system,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
RadioListTile<Themes>(
title: Text(
I18n.of(context).lightTheme,
),
value: Themes.light,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
RadioListTile<Themes>(
title: Text(
I18n.of(context).darkTheme,
),
value: Themes.dark,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
Divider(thickness: 1),
ListTile(
title: Text(
I18n.of(context).useAmoledTheme,
),
trailing: Switch(
value: _amoledEnabled,
activeColor: Theme.of(context).primaryColor,
onChanged: (bool value) {
setState(() {
_amoledEnabled = value;
themeEngine.switchTheme(matrix, _selectedTheme, value);
});
},
),
),
],
),
);
}
}