mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Can generate a random logo for the group
This commit is contained in:
parent
1a53a26f39
commit
4cb672cb16
@ -16,6 +16,8 @@ import 'package:comunic/utils/input_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:identicon/identicon.dart';
|
||||
import 'package:random_string/random_string.dart';
|
||||
import 'package:settings_ui/settings_ui.dart';
|
||||
|
||||
/// Groups settings screen
|
||||
@ -254,11 +256,17 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
|
||||
title: tr("Upload a new logo"),
|
||||
onTap: _uploadNewLogo,
|
||||
),
|
||||
|
||||
// Generate a new random logo
|
||||
SettingsTile(
|
||||
title: tr("Generate a new random logo"),
|
||||
onTap: _generateRandomLogo,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Upload a new logo for the group
|
||||
/// Upload a new logo for the group
|
||||
void _uploadNewLogo() async {
|
||||
try {
|
||||
final logo = await pickImage(context);
|
||||
@ -270,6 +278,18 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a new random logo for the group
|
||||
void _generateRandomLogo() async {
|
||||
try {
|
||||
final newLogo =
|
||||
Identicon(rows: 10, cols: 10).generate(randomString(20), size: 100);
|
||||
await _doUploadLogo(newLogo);
|
||||
} catch (e, stack) {
|
||||
print("Could not generate new logo! $e\n$stack");
|
||||
showSimpleSnack(context, tr("Could not generate new random logo!"));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _doUploadLogo(Uint8List bytes) async {
|
||||
await GroupsHelper.uploadNewLogo(_groupSettings.id, bytes);
|
||||
_key.currentState.refresh();
|
||||
|
Loading…
Reference in New Issue
Block a user