Add wallpaper

This commit is contained in:
Christian Pauly 2020-04-03 20:24:25 +02:00
parent 948e5839c4
commit bfa04e45eb
12 changed files with 109 additions and 32 deletions

View file

@ -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

View file

@ -50,6 +50,7 @@ class MatrixState extends State<Matrix> {
Map<String, dynamic> shareContent;
String activeRoomId;
File wallpaper;
void clean() async {
if (!kIsWeb) return;
@ -365,6 +366,14 @@ class MatrixState extends State<Matrix> {
} 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();
}

View file

@ -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!");

View file

@ -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",

View file

@ -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",

View file

@ -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 ..."),

View file

@ -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..."),

View file

@ -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: <Widget>[
if (!kIsWeb)
SvgPicture.asset(
"assets/chat.svg",
if (Matrix.of(context).wallpaper != null)
Opacity(
opacity: 0.66,
child: Image.file(
Matrix.of(context).wallpaper,
height: double.infinity,
color: Theme.of(context).primaryColor.withOpacity(0.05),
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,

View file

@ -350,7 +350,7 @@ class _ChatListState extends State<ChatList> {
title: Text(I18n.of(context).publicRooms),
),
)
: Divider(indent: 70, height: 1),
: Container(),
itemCount: totalCount,
itemBuilder: (BuildContext context, int i) => i < rooms.length
? ChatListItem(

View file

@ -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<Settings> {
}
}
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<Settings> {
),
),
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(

View file

@ -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:

View file

@ -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