Merge pull request #709 from celsoazevedo/progress-bars

Progress bars: one shared 4px top bar in the theme colour
This commit is contained in:
zjs81 authored and GitHub committed 2026-11-23 23:16:19 -07:00
commit 7152b2da8c
7 files changed
+112 -48

No files matched your search

+2 -6
View File
@@ -7,6 +7,7 @@ import '../../../theme/mesh_theme.dart';
import '../../../utils/radio_guard.dart';
import '../../../widgets/mesh_nav_tile.dart';
import '../../../widgets/mesh_ui.dart';
import '../../../widgets/sync_progress_overlay.dart';
import '../chess_game.dart';
import '../chess_service.dart';
import 'chess_board.dart';
@@ -106,12 +107,7 @@ class _ChessGameScreenState extends State<ChessGameScreen> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
bottom: busy
? const PreferredSize(
preferredSize: Size.fromHeight(3),
child: LinearProgressIndicator(minHeight: 3),
)
: null,
bottom: MeshProgressAppBarBottom(active: busy),
),
body: SafeArea(
child: LayoutBuilder(
+2 -4
View File
@@ -21,6 +21,7 @@ import '../widgets/app_bar.dart';
import '../widgets/mesh_ui.dart';
import '../widgets/path_map_scaffold.dart';
import '../widgets/quick_switch_bar.dart';
import '../widgets/sync_progress_overlay.dart';
import '../icons/los_icon.dart';
import '../theme/mesh_theme.dart';
@@ -440,10 +441,7 @@ class _LineOfSightMapScreenState extends State<LineOfSightMapScreen> {
left: 0,
right: 0,
top: 0,
child: LinearProgressIndicator(
color: LosPalette.selected,
backgroundColor: LosPalette.chartBackground,
),
child: const MeshProgressBar(),
),
],
),
+5 -6
View File
@@ -17,6 +17,7 @@ import '../widgets/mesh_nav_tile.dart';
import '../widgets/mesh_ui.dart';
import '../widgets/radio_disconnected_banner.dart';
import '../widgets/routing_sheet.dart';
import '../widgets/sync_progress_overlay.dart';
import '../utils/keys.dart';
import '../helpers/snack_bar_builder.dart';
@@ -889,12 +890,10 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
label: Text(l10n.common_save),
),
],
bottom: _loadingAll
? PreferredSize(
preferredSize: const Size.fromHeight(4),
child: LinearProgressIndicator(value: _loadAllProgress),
)
: null,
bottom: MeshProgressAppBarBottom(
active: _loadingAll,
value: _loadAllProgress,
),
),
body: MeshSettingsTileTheme(
child: SafeArea(
+2 -4
View File
@@ -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),
+47 -25
View File
@@ -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;
}