Add wallpaper
This commit is contained in:
parent
09ca7d817d
commit
771aa6fbe2
12 changed files with 109 additions and 32 deletions
|
|
@ -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",
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue