diff --git a/lib/components/message_content.dart b/lib/components/message_content.dart index 80a2bbd..60d9f99 100644 --- a/lib/components/message_content.dart +++ b/lib/components/message_content.dart @@ -2,9 +2,7 @@ import 'package:bubble/bubble.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/i18n/i18n.dart'; -import 'package:fluffychat/utils/app_route.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:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -77,12 +75,8 @@ class MessageContent extends StatelessWidget { ), ], ), - onPressed: () => Navigator.of(context).push( - AppRoute.defaultRoute( - context, - ContentWebView(MxContent(event.content["url"])), - ), - ), + onPressed: () => launch(MxContent(event.content["url"]) + .getDownloadLink(event.room.client)), ), ); case MessageTypes.Video: @@ -102,11 +96,9 @@ class MessageContent extends StatelessWidget { ), ], ), - onPressed: () => Navigator.of(context).push( - AppRoute.defaultRoute( - context, - ContentWebView(MxContent(event.content["url"])), - ), + onPressed: () => launch( + MxContent(event.content["url"]) + .getDownloadLink(event.room.client), ), ), ); diff --git a/lib/components/settings_themes.dart b/lib/components/settings_themes.dart new file mode 100644 index 0000000..d0eeb1a --- /dev/null +++ b/lib/components/settings_themes.dart @@ -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 { + 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: [ + RadioListTile( + 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( + 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( + 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); + }); + }, + ), + ), + ], + ); + } +} diff --git a/lib/i18n/intl_de.arb b/lib/i18n/intl_de.arb index 780b6fb..1a6c12f 100644 --- a/lib/i18n/intl_de.arb +++ b/lib/i18n/intl_de.arb @@ -967,7 +967,7 @@ "type": "text", "placeholders": {} }, - "Change your style": "Change your style", + "Change your style": "Ändere Deinen Style", "@Change your style": { "type": "text", "placeholders": {} diff --git a/lib/i18n/messages_de.dart b/lib/i18n/messages_de.dart index f3fd13b..a212860 100644 --- a/lib/i18n/messages_de.dart +++ b/lib/i18n/messages_de.dart @@ -151,7 +151,7 @@ class MessageLookup extends MessageLookupByLibrary { "Banned" : MessageLookupByLibrary.simpleMessage("Banned"), "Change the name of the group" : MessageLookupByLibrary.simpleMessage("Gruppenname ändern"), "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"), "Chat details" : MessageLookupByLibrary.simpleMessage("Gruppeninfo"), "Choose a username" : MessageLookupByLibrary.simpleMessage("Wähle einen Benutzernamen"), diff --git a/lib/main.dart b/lib/main.dart index ed4d557..1564c69 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:famedlysdk/famedlysdk.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -19,7 +21,7 @@ class App extends StatelessWidget { @override Widget build(BuildContext context) { return Matrix( - clientName: "FluffyChat", + clientName: "FluffyChat ${Platform.operatingSystem}", child: Builder( builder: (BuildContext context) => ThemeSwitcherWidget( child: Builder( diff --git a/lib/utils/event_extension.dart b/lib/utils/event_extension.dart index 2830bb3..dcbe3c3 100644 --- a/lib/utils/event_extension.dart +++ b/lib/utils/event_extension.dart @@ -230,9 +230,7 @@ extension LocalizedBody on Event { // Hide reply fallback if (hideReply) { localizedBody = localizedBody.replaceFirst( - RegExp( - r'^>( \*)? <@[a-zA-Z0-9-.=_\/]+:[^>]+>[^\n]+\r?\n(> [^\n]+\r?\n)*\r?\n'), - ""); + RegExp(r'^>( \*)? <[^>]+>[^\n\r]+\r?\n(> [^\n]*\r?\n)*\r?\n'), ""); } // Add the sender name prefix diff --git a/lib/views/app_info.dart b/lib/views/app_info.dart index 1b46ef7..b2a0787 100644 --- a/lib/views/app_info.dart +++ b/lib/views/app_info.dart @@ -24,7 +24,7 @@ class AppInfo extends StatelessWidget { Client client = Matrix.of(context).client; return Scaffold( appBar: AppBar( - title: Text("About FluffyChat"), + title: Text(I18n.of(context).accountInformations), ), body: ListView( children: [ diff --git a/lib/views/chat_details.dart b/lib/views/chat_details.dart index 0aa0f49..1e4700c 100644 --- a/lib/views/chat_details.dart +++ b/lib/views/chat_details.dart @@ -419,7 +419,6 @@ class _ChatDetailsState extends State { ), ), ), - Divider(height: 1), widget.room.canInvite ? ListTile( title: Text(I18n.of(context).inviteContact), diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart index ccaaa2a..ccea0e8 100644 --- a/lib/views/chat_list.dart +++ b/lib/views/chat_list.dart @@ -315,7 +315,7 @@ class _ChatListState extends State { ? Material( elevation: 2, child: ListTile( - title: Text("Public Rooms:"), + title: Text(I18n.of(context).publicRooms), ), ) : Divider(indent: 70, height: 1), diff --git a/lib/views/content_web_view.dart b/lib/views/content_web_view.dart deleted file mode 100644 index fc9f1e3..0000000 --- a/lib/views/content_web_view.dart +++ /dev/null @@ -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: [ - IconButton( - icon: Icon( - Icons.file_download, - ), - onPressed: () => launch(url), - ), - ], - ), - body: WebView( - initialUrl: url, - ), - ); - } -} diff --git a/lib/views/image_viewer.dart b/lib/views/image_viewer.dart index ffff429..b7c905e 100644 --- a/lib/views/image_viewer.dart +++ b/lib/views/image_viewer.dart @@ -2,7 +2,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/utils/app_route.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -13,15 +12,11 @@ class ImageViewer extends StatelessWidget { const ImageViewer(this.mxContent); static show(BuildContext context, MxContent content) { - if (kIsWeb) { - launch(content.getDownloadLink(Matrix.of(context).client)); - } else { - Navigator.of(context).push( - AppRoute( - ImageViewer(content), - ), - ); - } + Navigator.of(context).push( + AppRoute( + ImageViewer(content), + ), + ); } @override @@ -29,6 +24,9 @@ class ImageViewer extends StatelessWidget { final String url = mxContent.getDownloadLink(Matrix.of(context).client); return Scaffold( appBar: AppBar( + brightness: Brightness.dark, + backgroundColor: Colors.black, + iconTheme: IconThemeData(color: Colors.white), actions: [ IconButton( icon: Icon(Icons.file_download), diff --git a/lib/views/invitation_selection.dart b/lib/views/invitation_selection.dart index c89e9e0..aaef397 100644 --- a/lib/views/invitation_selection.dart +++ b/lib/views/invitation_selection.dart @@ -123,7 +123,7 @@ class _InvitationSelectionState extends State { appBar: AppBar( title: Text(I18n.of(context).inviteContact), bottom: PreferredSize( - preferredSize: Size.fromHeight(68), + preferredSize: Size.fromHeight(92), child: Padding( padding: const EdgeInsets.all(16.0), child: TextField( diff --git a/lib/views/new_group.dart b/lib/views/new_group.dart index 3207d56..67285f6 100644 --- a/lib/views/new_group.dart +++ b/lib/views/new_group.dart @@ -1,6 +1,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/i18n/i18n.dart'; +import 'package:fluffychat/utils/app_route.dart'; import 'package:flutter/material.dart'; import 'package:pedantic/pedantic.dart'; @@ -47,11 +48,11 @@ class _NewGroupState extends State<_NewGroup> { Navigator.of(context).pop(); if (roomID != null) { unawaited( - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return ChatView(roomID); - }), + Navigator.of(context).push( + AppRoute.defaultRoute( + context, + ChatView(roomID), + ), ), ); await Navigator.push( diff --git a/lib/views/new_private_chat.dart b/lib/views/new_private_chat.dart index 2df395d..dffc9eb 100644 --- a/lib/views/new_private_chat.dart +++ b/lib/views/new_private_chat.dart @@ -5,6 +5,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/i18n/i18n.dart'; +import 'package:fluffychat/utils/app_route.dart'; import 'package:flutter/material.dart'; import 'package:share/share.dart'; @@ -58,9 +59,11 @@ class _NewPrivateChatState extends State<_NewPrivateChat> { Navigator.of(context).pop(); if (roomID != null) { - await Navigator.push( - context, - MaterialPageRoute(builder: (context) => ChatView(roomID)), + await Navigator.of(context).push( + AppRoute.defaultRoute( + context, + ChatView(roomID), + ), ); } } diff --git a/lib/views/settings.dart b/lib/views/settings.dart index 99b5776..731f392 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:famedlysdk/famedlysdk.dart'; +import 'package:fluffychat/components/settings_themes.dart'; import 'package:fluffychat/views/settings_devices.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; @@ -9,10 +10,9 @@ import 'package:url_launcher/url_launcher.dart'; import 'app_info.dart'; import 'chat_list.dart'; -import 'settings_themes.dart'; +import '../components/adaptive_page_layout.dart'; import 'sign_up.dart'; import '../components/dialogs/simple_dialogs.dart'; -import '../components/adaptive_page_layout.dart'; import '../components/content_banner.dart'; import '../components/matrix.dart'; import '../i18n/i18n.dart'; @@ -132,6 +132,17 @@ class _SettingsState extends State { ], body: ListView( children: [ + ListTile( + title: Text( + I18n.of(context).changeTheme, + style: TextStyle( + color: Theme.of(context).primaryColor, + fontWeight: FontWeight.bold, + ), + ), + ), + ThemesSettings(), + Divider(thickness: 1), ListTile( title: Text( I18n.of(context).account, @@ -147,16 +158,6 @@ class _SettingsState extends State { subtitle: Text(profile?.displayname ?? client.userID.localpart), 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( trailing: Icon(Icons.devices_other), title: Text(I18n.of(context).devices), @@ -167,6 +168,16 @@ class _SettingsState extends State { ), ), ), + ListTile( + trailing: Icon(Icons.account_circle), + title: Text(I18n.of(context).accountInformations), + onTap: () => Navigator.of(context).push( + AppRoute.defaultRoute( + context, + AppInfoView(), + ), + ), + ), ListTile( trailing: Icon(Icons.exit_to_app), title: Text(I18n.of(context).logout), @@ -190,7 +201,7 @@ class _SettingsState extends State { onTap: () => launch("https://ko-fi.com/V7V315112"), ), ListTile( - leading: Icon(Icons.donut_large), + leading: Icon(Icons.local_atm), title: Text("Liberapay " + I18n.of(context).donate), onTap: () => launch("https://liberapay.com/KrilleChritzelius/donate"), @@ -201,16 +212,6 @@ class _SettingsState extends State { onTap: () => launch( "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( leading: Icon(Icons.list), title: Text(I18n.of(context).changelog), diff --git a/lib/views/settings_themes.dart b/lib/views/settings_themes.dart deleted file mode 100644 index c8cb7bf..0000000 --- a/lib/views/settings_themes.dart +++ /dev/null @@ -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 { - 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: [ - RadioListTile( - 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( - 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( - 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); - }); - }, - ), - ), - ], - ), - ); - } -}