Add wallpaper
This commit is contained in:
parent
09ca7d817d
commit
771aa6fbe2
12 changed files with 109 additions and 32 deletions
|
|
@ -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