Merge origin/dev into feat/bookmarks-ux-improvements
This commit is contained in:
commit
faa9bf3752
16 files changed
+408
-316
No files matched your search
@@ -8,6 +8,7 @@ import '../helpers/snack_bar_builder.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import 'chat_day_separator.dart';
|
||||
import 'empty_state.dart';
|
||||
import 'sync_progress_overlay.dart';
|
||||
|
||||
/// Results list for "search in this chat". Loads the full history through
|
||||
/// [loadEntries] (once, cached) and re-filters on each debounced [query].
|
||||
@@ -86,10 +87,7 @@ class _ChatSearchResultsState extends State<ChatSearchResults> {
|
||||
final showEmpty = !_loading && _results.isEmpty;
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 3,
|
||||
child: _loading ? const LinearProgressIndicator() : null,
|
||||
),
|
||||
MeshProgressBar(active: _loading),
|
||||
if (!_loading && _results.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 10, 16, 6),
|
||||
|
||||
@@ -2,34 +2,40 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../l10n/l10n.dart';
|
||||
|
||||
/// Asks the user to confirm clearing a log or history. Resolves to true only
|
||||
/// when the user taps Clear.
|
||||
/// Asks the user to confirm a destructive action (Clear by default). Resolves
|
||||
/// to true only when the user taps the confirm button. [warning] uses the
|
||||
/// amber warning colour instead of red.
|
||||
Future<bool> showConfirmClearDialog(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String message,
|
||||
String? confirmLabel,
|
||||
bool warning = false,
|
||||
}) async {
|
||||
final l10n = context.l10n;
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: Text(l10n.common_cancel),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(dialogContext).colorScheme.error,
|
||||
foregroundColor: Theme.of(dialogContext).colorScheme.onError,
|
||||
builder: (dialogContext) {
|
||||
final scheme = Theme.of(dialogContext).colorScheme;
|
||||
return AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: Text(l10n.common_cancel),
|
||||
),
|
||||
child: Text(l10n.common_clear),
|
||||
),
|
||||
],
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: warning ? scheme.tertiary : scheme.error,
|
||||
foregroundColor: warning ? scheme.onTertiary : scheme.onError,
|
||||
),
|
||||
child: Text(confirmLabel ?? l10n.common_clear),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return confirmed == true;
|
||||
}
|
||||
@@ -3,57 +3,79 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../connector/meshcore_connector.dart';
|
||||
|
||||
/// The thin progress bar at the top of a screen or list: 4px, in the theme's
|
||||
/// progress colour and track. Fills when [value] is known, moves when it is
|
||||
/// null. While inactive it keeps its height, so the content doesn't jump.
|
||||
class MeshProgressBar extends StatelessWidget {
|
||||
static const double height = 4;
|
||||
|
||||
final bool active;
|
||||
final double? value;
|
||||
|
||||
const MeshProgressBar({super.key, this.active = true, this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: active
|
||||
? LinearProgressIndicator(value: value, minHeight: height)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// [MeshProgressBar] as an app bar's `bottom`, for a screen's own task.
|
||||
class MeshProgressAppBarBottom extends StatelessWidget
|
||||
implements PreferredSizeWidget {
|
||||
final bool active;
|
||||
final double? value;
|
||||
|
||||
const MeshProgressAppBarBottom({super.key, this.active = true, this.value});
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(MeshProgressBar.height);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
MeshProgressBar(active: active, value: value);
|
||||
}
|
||||
|
||||
/// [MeshProgressBar] as an app bar's `bottom` for the app-wide syncs:
|
||||
/// contacts, channels and queued messages, one at a time.
|
||||
class SyncProgressAppBarBottom extends StatelessWidget
|
||||
implements PreferredSizeWidget {
|
||||
static const double height = 3;
|
||||
|
||||
const SyncProgressAppBarBottom({super.key});
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(height);
|
||||
Size get preferredSize => const Size.fromHeight(MeshProgressBar.height);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<MeshCoreConnector>(
|
||||
builder: (context, connector, _) {
|
||||
final state = _SyncProgressState.fromConnector(connector);
|
||||
if (state == null) return const SizedBox(height: height);
|
||||
|
||||
return SizedBox(
|
||||
height: height,
|
||||
child: LinearProgressIndicator(
|
||||
value: state.value,
|
||||
minHeight: height,
|
||||
color: state.color,
|
||||
backgroundColor: state.color.withValues(alpha: 0.18),
|
||||
),
|
||||
);
|
||||
return MeshProgressBar(active: state != null, value: state?.value);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SyncProgressState {
|
||||
/// Null while the progress is unknown.
|
||||
final double? value;
|
||||
final Color color;
|
||||
|
||||
const _SyncProgressState({required this.value, required this.color});
|
||||
const _SyncProgressState({required this.value});
|
||||
|
||||
static _SyncProgressState? fromConnector(MeshCoreConnector connector) {
|
||||
if (connector.isLoadingContacts) {
|
||||
return _SyncProgressState(
|
||||
value: connector.contactSyncProgress,
|
||||
color: Colors.red,
|
||||
);
|
||||
return _SyncProgressState(value: connector.contactSyncProgress);
|
||||
}
|
||||
if (connector.isSyncingChannels) {
|
||||
return _SyncProgressState(
|
||||
value: connector.channelSyncProgress / 100,
|
||||
color: Colors.blue,
|
||||
);
|
||||
return _SyncProgressState(value: connector.channelSyncProgress / 100);
|
||||
}
|
||||
if (connector.isShowingQueuedMessageSyncProgress) {
|
||||
return const _SyncProgressState(value: null, color: Colors.green);
|
||||
return const _SyncProgressState(value: null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user