From bfa04e45eb6dd8738d78d44011647945550fa92e Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 3 Apr 2020 20:24:25 +0200 Subject: [PATCH] Add wallpaper --- CHANGELOG.md | 4 +++ lib/components/matrix.dart | 9 ++++++ lib/i18n/i18n.dart | 4 +++ lib/i18n/intl_de.arb | 10 +++++++ lib/i18n/intl_messages.arb | 12 +++++++- lib/i18n/messages_de.dart | 2 ++ lib/i18n/messages_messages.dart | 2 ++ lib/views/chat.dart | 19 +++++++----- lib/views/chat_list.dart | 2 +- lib/views/settings.dart | 53 +++++++++++++++++++++++++++++++++ pubspec.lock | 21 ------------- pubspec.yaml | 3 +- 12 files changed, 109 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2062910..731ca19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 0.12.0 - 2020-04-?? +### Features: +- Implement custom wallpapers + # Version 0.11.0 - 2020-04-02 ### Features: - Share content with FluffyChat diff --git a/lib/components/matrix.dart b/lib/components/matrix.dart index f210f9a..0840c8e 100644 --- a/lib/components/matrix.dart +++ b/lib/components/matrix.dart @@ -50,6 +50,7 @@ class MatrixState extends State { Map shareContent; String activeRoomId; + File wallpaper; void clean() async { if (!kIsWeb) return; @@ -365,6 +366,14 @@ class MatrixState extends State { } else { client = widget.client; } + if (client.storeAPI != null) { + client.storeAPI.getItem("chat.fluffy.wallpaper").then((final path) async { + final file = File(path); + if (await file.exists()) { + wallpaper = file; + } + }); + } super.initState(); } diff --git a/lib/i18n/i18n.dart b/lib/i18n/i18n.dart index 09b8983..dd3b9fd 100644 --- a/lib/i18n/i18n.dart +++ b/lib/i18n/i18n.dart @@ -190,6 +190,8 @@ class I18n { String get changeTheNameOfTheGroup => Intl.message("Change the name of the group"); + String get changeWallpaper => Intl.message("Change wallpaper"); + String get changeTheServer => Intl.message("Change the server"); String get channelCorruptedDecryptError => @@ -722,6 +724,8 @@ class I18n { String get voiceMessage => Intl.message("Voice message"); + String get wallpaper => Intl.message("Wallpaper"); + String get warningEncryptionInBeta => Intl.message( "End to end encryption is currently in Beta! Use at your own risk!"); diff --git a/lib/i18n/intl_de.arb b/lib/i18n/intl_de.arb index f5157d0..eaa51c7 100644 --- a/lib/i18n/intl_de.arb +++ b/lib/i18n/intl_de.arb @@ -221,6 +221,11 @@ "type": "text", "placeholders": {} }, + "Change wallpaper": "Hintergrund ändern", + "@Change wallpaper": { + "type": "text", + "placeholders": {} + }, "Change the server": "Ändere den Server", "@Change the server": { "type": "text", @@ -1182,6 +1187,11 @@ "type": "text", "placeholders": {} }, + "Wallpaper": "Hintergrund", + "@Wallpaper": { + "type": "text", + "placeholders": {} + }, "Voice message": "Sprachnachricht", "@Voice message": { "type": "text", diff --git a/lib/i18n/intl_messages.arb b/lib/i18n/intl_messages.arb index 3232a6b..9167412 100644 --- a/lib/i18n/intl_messages.arb +++ b/lib/i18n/intl_messages.arb @@ -1,5 +1,5 @@ { - "@@last_modified": "2020-03-15T12:01:07.169209", + "@@last_modified": "2020-04-03T20:17:02.102828", "About": "About", "@About": { "type": "text", @@ -221,6 +221,11 @@ "type": "text", "placeholders": {} }, + "Change wallpaper": "Change wallpaper", + "@Change wallpaper": { + "type": "text", + "placeholders": {} + }, "Change the server": "Change the server", "@Change the server": { "type": "text", @@ -1182,6 +1187,11 @@ "type": "text", "placeholders": {} }, + "Wallpaper": "Wallpaper", + "@Wallpaper": { + "type": "text", + "placeholders": {} + }, "End to end encryption is currently in Beta! Use at your own risk!": "End to end encryption is currently in Beta! Use at your own risk!", "@End to end encryption is currently in Beta! Use at your own risk!": { "type": "text", diff --git a/lib/i18n/messages_de.dart b/lib/i18n/messages_de.dart index 432a204..428f2eb 100644 --- a/lib/i18n/messages_de.dart +++ b/lib/i18n/messages_de.dart @@ -150,6 +150,7 @@ class MessageLookup extends MessageLookupByLibrary { "Cancel" : MessageLookupByLibrary.simpleMessage("Abbrechen"), "Change the name of the group" : MessageLookupByLibrary.simpleMessage("Gruppenname ändern"), "Change the server" : MessageLookupByLibrary.simpleMessage("Ändere den Server"), + "Change wallpaper" : MessageLookupByLibrary.simpleMessage("Hintergrund ändern"), "Change your style" : MessageLookupByLibrary.simpleMessage("Ändere Deinen Style"), "Changelog" : MessageLookupByLibrary.simpleMessage("Changelog"), "Chat details" : MessageLookupByLibrary.simpleMessage("Gruppeninfo"), @@ -282,6 +283,7 @@ class MessageLookup extends MessageLookupByLibrary { "Visible for all participants" : MessageLookupByLibrary.simpleMessage("Sichtbar für alle Teilnehmer"), "Visible for everyone" : MessageLookupByLibrary.simpleMessage("Für jeden sichtbar"), "Voice message" : MessageLookupByLibrary.simpleMessage("Sprachnachricht"), + "Wallpaper" : MessageLookupByLibrary.simpleMessage("Hintergrund"), "Wednesday" : MessageLookupByLibrary.simpleMessage("Mittwoch"), "Who is allowed to join this group" : MessageLookupByLibrary.simpleMessage("Wer darf der Gruppe beitreten"), "Write a message..." : MessageLookupByLibrary.simpleMessage("Schreibe eine Nachricht ..."), diff --git a/lib/i18n/messages_messages.dart b/lib/i18n/messages_messages.dart index a7b5327..ce3ded3 100644 --- a/lib/i18n/messages_messages.dart +++ b/lib/i18n/messages_messages.dart @@ -150,6 +150,7 @@ class MessageLookup extends MessageLookupByLibrary { "Cancel" : MessageLookupByLibrary.simpleMessage("Cancel"), "Change the name of the group" : MessageLookupByLibrary.simpleMessage("Change the name of the group"), "Change the server" : MessageLookupByLibrary.simpleMessage("Change the server"), + "Change wallpaper" : MessageLookupByLibrary.simpleMessage("Change wallpaper"), "Change your style" : MessageLookupByLibrary.simpleMessage("Change your style"), "Changelog" : MessageLookupByLibrary.simpleMessage("Changelog"), "Chat details" : MessageLookupByLibrary.simpleMessage("Chat details"), @@ -282,6 +283,7 @@ class MessageLookup extends MessageLookupByLibrary { "Visible for all participants" : MessageLookupByLibrary.simpleMessage("Visible for all participants"), "Visible for everyone" : MessageLookupByLibrary.simpleMessage("Visible for everyone"), "Voice message" : MessageLookupByLibrary.simpleMessage("Voice message"), + "Wallpaper" : MessageLookupByLibrary.simpleMessage("Wallpaper"), "Wednesday" : MessageLookupByLibrary.simpleMessage("Wednesday"), "Who is allowed to join this group" : MessageLookupByLibrary.simpleMessage("Who is allowed to join this group"), "Write a message..." : MessageLookupByLibrary.simpleMessage("Write a message..."), diff --git a/lib/views/chat.dart b/lib/views/chat.dart index d7ef9bf..c651cda 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -17,7 +17,6 @@ import 'package:fluffychat/utils/room_extension.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:image_picker/image_picker.dart'; import 'package:pedantic/pedantic.dart'; @@ -432,11 +431,15 @@ class _ChatState extends State<_Chat> { : null, body: Stack( children: [ - if (!kIsWeb) - SvgPicture.asset( - "assets/chat.svg", - height: double.infinity, - color: Theme.of(context).primaryColor.withOpacity(0.05), + if (Matrix.of(context).wallpaper != null) + Opacity( + opacity: 0.66, + child: Image.file( + Matrix.of(context).wallpaper, + height: double.infinity, + width: double.infinity, + fit: BoxFit.cover, + ), ), SafeArea( child: Column( @@ -544,7 +547,9 @@ class _ChatState extends State<_Chat> { room.membership == Membership.join ? Container( decoration: BoxDecoration( - color: Theme.of(context).backgroundColor, + color: Theme.of(context) + .backgroundColor + .withOpacity(0.8), ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart index 9c0b4f0..48156ee 100644 --- a/lib/views/chat_list.dart +++ b/lib/views/chat_list.dart @@ -350,7 +350,7 @@ class _ChatListState extends State { title: Text(I18n.of(context).publicRooms), ), ) - : Divider(indent: 70, height: 1), + : Container(), itemCount: totalCount, itemBuilder: (BuildContext context, int i) => i < rooms.length ? ChatListItem( diff --git a/lib/views/settings.dart b/lib/views/settings.dart index 2c76f37..b242cca 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -3,6 +3,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/foundation.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -92,6 +93,26 @@ class _SettingsState extends State { } } + void setWallpaperAction(BuildContext context) async { + final wallpaper = await ImagePicker.pickImage(source: ImageSource.gallery); + if (wallpaper == null) return; + Matrix.of(context).wallpaper = wallpaper; + await Matrix.of(context) + .client + .storeAPI + .setItem("chat.fluffy.wallpaper", wallpaper.path); + setState(() => null); + } + + void deleteWallpaperAction(BuildContext context) async { + Matrix.of(context).wallpaper = null; + await Matrix.of(context) + .client + .storeAPI + .setItem("chat.fluffy.wallpaper", null); + setState(() => null); + } + @override Widget build(BuildContext context) { final Client client = Matrix.of(context).client; @@ -136,6 +157,38 @@ class _SettingsState extends State { ), ), ThemesSettings(), + if (!kIsWeb && client.storeAPI != null) Divider(thickness: 1), + if (!kIsWeb && client.storeAPI != null) + ListTile( + title: Text( + I18n.of(context).wallpaper, + style: TextStyle( + color: Theme.of(context).primaryColor, + fontWeight: FontWeight.bold, + ), + ), + ), + if (Matrix.of(context).wallpaper != null) + ListTile( + title: Image.file( + Matrix.of(context).wallpaper, + height: 38, + fit: BoxFit.cover, + ), + trailing: Icon( + Icons.delete_forever, + color: Colors.red, + ), + onTap: () => deleteWallpaperAction(context), + ), + if (!kIsWeb && client.storeAPI != null) + Builder(builder: (context) { + return ListTile( + title: Text(I18n.of(context).changeWallpaper), + trailing: Icon(Icons.wallpaper), + onTap: () => setWallpaperAction(context), + ); + }), Divider(thickness: 1), ListTile( title: Text( diff --git a/pubspec.lock b/pubspec.lock index be2e695..8a8b40c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -209,13 +209,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.5" - flutter_svg: - dependency: "direct main" - description: - name: flutter_svg - url: "https://pub.dartlang.org" - source: hosted - version: "0.17.1" flutter_test: dependency: "direct dev" description: flutter @@ -426,20 +419,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.4" - path_drawing: - dependency: transitive - description: - name: path_drawing - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.1" - path_parsing: - dependency: transitive - description: - name: path_parsing - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.4" path_provider: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b3db367..b6d7af6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Chat with your friends. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.11.0+31 +version: 0.12.0+32 environment: sdk: ">=2.6.0 <3.0.0" @@ -48,7 +48,6 @@ dependencies: http: ^0.12.0+4 universal_html: ^1.1.12 receive_sharing_intent: ^1.3.3 - flutter_svg: ^0.17.1 flutter_slidable: ^0.5.4 photo_view: ^0.9.2 flutter_sound: ^2.1.1