mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
design: Move chat backup header to settings
This commit is contained in:
parent
8e04f4cc73
commit
c40bdc3a6d
@ -211,19 +211,6 @@ class ChatListController extends State<ChatList>
|
|||||||
}
|
}
|
||||||
|
|
||||||
final selectedRoomIds = <String>{};
|
final selectedRoomIds = <String>{};
|
||||||
bool? crossSigningCached;
|
|
||||||
bool showChatBackupBanner = false;
|
|
||||||
|
|
||||||
void firstRunBootstrapAction() async {
|
|
||||||
setState(() {
|
|
||||||
showChatBackupBanner = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
await BootstrapDialog(
|
|
||||||
client: Matrix.of(context).client,
|
|
||||||
).show(context);
|
|
||||||
VRouter.of(context).to('/rooms');
|
|
||||||
}
|
|
||||||
|
|
||||||
String? get activeChat => VRouter.of(context).pathParameters['roomid'];
|
String? get activeChat => VRouter.of(context).pathParameters['roomid'];
|
||||||
|
|
||||||
@ -314,24 +301,6 @@ class ChatListController extends State<ChatList>
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkBootstrap() async {
|
|
||||||
if (!Matrix.of(context).client.encryptionEnabled) return;
|
|
||||||
await Matrix.of(context).client.accountDataLoading;
|
|
||||||
await Matrix.of(context).client.userDeviceKeysLoading;
|
|
||||||
final crossSigning =
|
|
||||||
await Matrix.of(context).client.encryption?.crossSigning.isCached() ??
|
|
||||||
false;
|
|
||||||
final needsBootstrap =
|
|
||||||
Matrix.of(context).client.encryption?.crossSigning.enabled == false ||
|
|
||||||
crossSigning == false;
|
|
||||||
final isUnknownSession = Matrix.of(context).client.isUnknownSession;
|
|
||||||
if (needsBootstrap || isUnknownSession) {
|
|
||||||
setState(() {
|
|
||||||
showChatBackupBanner = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_intentDataStreamSubscription?.cancel();
|
_intentDataStreamSubscription?.cancel();
|
||||||
@ -538,7 +507,17 @@ class ChatListController extends State<ChatList>
|
|||||||
await client.accountDataLoading;
|
await client.accountDataLoading;
|
||||||
if (client.prevBatch == null) {
|
if (client.prevBatch == null) {
|
||||||
await client.onSync.stream.first;
|
await client.onSync.stream.first;
|
||||||
|
|
||||||
|
// Display first login bootstrap if enabled
|
||||||
|
if (client.encryption?.keyManager.enabled == true) {
|
||||||
|
if (await client.encryption?.keyManager.isCached() == false ||
|
||||||
|
await client.encryption?.crossSigning.isCached() == false ||
|
||||||
|
client.isUnknownSession) {
|
||||||
|
await BootstrapDialog(client: client).show(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load space members to display DM rooms
|
// Load space members to display DM rooms
|
||||||
final spaceId = activeSpaceId;
|
final spaceId = activeSpaceId;
|
||||||
if (spaceId != null) {
|
if (spaceId != null) {
|
||||||
@ -553,7 +532,6 @@ class ChatListController extends State<ChatList>
|
|||||||
setState(() {
|
setState(() {
|
||||||
waitForFirstSync = true;
|
waitForFirstSync = true;
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => checkBootstrap());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,44 +146,6 @@ class _ChatListViewBodyState extends State<ChatListViewBody> {
|
|||||||
StoriesHeader(
|
StoriesHeader(
|
||||||
filter: widget.controller.searchController.text,
|
filter: widget.controller.searchController.text,
|
||||||
),
|
),
|
||||||
AnimatedContainer(
|
|
||||||
height: !widget.controller.isSearchMode &&
|
|
||||||
widget.controller.showChatBackupBanner
|
|
||||||
? 54
|
|
||||||
: 0,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
curve: Curves.bounceInOut,
|
|
||||||
decoration: const BoxDecoration(),
|
|
||||||
child: Material(
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
child: ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
radius: Avatar.defaultSize / 2,
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.surfaceVariant,
|
|
||||||
foregroundColor:
|
|
||||||
Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
child: const Icon(Icons.enhanced_encryption_outlined),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
(Matrix.of(context)
|
|
||||||
.client
|
|
||||||
.encryption
|
|
||||||
?.keyManager
|
|
||||||
.enabled ==
|
|
||||||
true)
|
|
||||||
? L10n.of(context)!.unlockOldMessages
|
|
||||||
: L10n.of(context)!.enableAutoBackups,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: const Icon(Icons.chevron_right_outlined),
|
|
||||||
onTap: widget.controller.firstRunBootstrapAction,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
height: widget.controller.isTorBrowser ? 64 : 0,
|
height: widget.controller.isTorBrowser ? 64 : 0,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
|
@ -11,6 +11,7 @@ import 'package:matrix/matrix.dart';
|
|||||||
|
|
||||||
import 'package:fluffychat/utils/platform_infos.dart';
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import '../../widgets/matrix.dart';
|
import '../../widgets/matrix.dart';
|
||||||
|
import '../bootstrap/bootstrap_dialog.dart';
|
||||||
import 'settings_view.dart';
|
import 'settings_view.dart';
|
||||||
|
|
||||||
class Settings extends StatefulWidget {
|
class Settings extends StatefulWidget {
|
||||||
@ -21,10 +22,6 @@ class Settings extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SettingsController extends State<Settings> {
|
class SettingsController extends State<Settings> {
|
||||||
Future<bool>? crossSigningCachedFuture;
|
|
||||||
bool? crossSigningCached;
|
|
||||||
Future<bool>? megolmBackupCachedFuture;
|
|
||||||
bool? megolmBackupCached;
|
|
||||||
Future<dynamic>? profileFuture;
|
Future<dynamic>? profileFuture;
|
||||||
Profile? profile;
|
Profile? profile;
|
||||||
bool profileUpdated = false;
|
bool profileUpdated = false;
|
||||||
@ -106,6 +103,43 @@ class SettingsController extends State<Settings> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) => checkBootstrap());
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkBootstrap() async {
|
||||||
|
final client = Matrix.of(context).client;
|
||||||
|
if (!client.encryptionEnabled) return;
|
||||||
|
await client.accountDataLoading;
|
||||||
|
await client.userDeviceKeysLoading;
|
||||||
|
if (client.prevBatch == null) {
|
||||||
|
await client.onSync.stream.first;
|
||||||
|
}
|
||||||
|
final crossSigning =
|
||||||
|
await client.encryption?.crossSigning.isCached() ?? false;
|
||||||
|
final needsBootstrap =
|
||||||
|
await client.encryption?.keyManager.isCached() == false ||
|
||||||
|
client.encryption?.crossSigning.enabled == false ||
|
||||||
|
crossSigning == false;
|
||||||
|
final isUnknownSession = client.isUnknownSession;
|
||||||
|
setState(() {
|
||||||
|
showChatBackupBanner = needsBootstrap || isUnknownSession;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool? crossSigningCached;
|
||||||
|
bool showChatBackupBanner = false;
|
||||||
|
|
||||||
|
void firstRunBootstrapAction() async {
|
||||||
|
await BootstrapDialog(
|
||||||
|
client: Matrix.of(context).client,
|
||||||
|
).show(context);
|
||||||
|
checkBootstrap();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
@ -119,18 +153,6 @@ class SettingsController extends State<Settings> {
|
|||||||
if (mounted) setState(() => profile = p);
|
if (mounted) setState(() => profile = p);
|
||||||
return p;
|
return p;
|
||||||
});
|
});
|
||||||
if (client.encryption != null) {
|
|
||||||
crossSigningCachedFuture ??=
|
|
||||||
client.encryption?.crossSigning.isCached().then((c) {
|
|
||||||
if (mounted) setState(() => crossSigningCached = c);
|
|
||||||
return c;
|
|
||||||
});
|
|
||||||
megolmBackupCachedFuture ??=
|
|
||||||
client.encryption?.keyManager.isCached().then((c) {
|
|
||||||
if (mounted) setState(() => megolmBackupCached = c);
|
|
||||||
return c;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return SettingsView(this);
|
return SettingsView(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,23 @@ class SettingsView extends StatelessWidget {
|
|||||||
iconColor: Theme.of(context).colorScheme.onBackground,
|
iconColor: Theme.of(context).colorScheme.onBackground,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
AnimatedContainer(
|
||||||
|
height: controller.showChatBackupBanner ? 54 : 0,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
curve: Curves.bounceInOut,
|
||||||
|
decoration: const BoxDecoration(),
|
||||||
|
child: ListTile(
|
||||||
|
leading: const Icon(Icons.backup_outlined),
|
||||||
|
title: Text(L10n.of(context)!.enableAutoBackups),
|
||||||
|
trailing: const Icon(
|
||||||
|
Icons.warning_outlined,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
onTap: controller.firstRunBootstrapAction,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(thickness: 1),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.format_paint_outlined),
|
leading: const Icon(Icons.format_paint_outlined),
|
||||||
title: Text(L10n.of(context)!.changeTheme),
|
title: Text(L10n.of(context)!.changeTheme),
|
||||||
|
Loading…
Reference in New Issue
Block a user