From 5bbc699353ef7ce7e58e7b837096a9a0cd3c287e Mon Sep 17 00:00:00 2001 From: FernTheDev <15272073+Fernthedev@users.noreply.github.com> Date: Sun, 17 Dec 2023 20:16:32 -0400 Subject: [PATCH] Improve contrast and hide leading when possible --- lib/pages/main/browser.dart | 13 ++++-- lib/pages/main/logger.dart | 92 ++++++++++++++++++++----------------- 2 files changed, 59 insertions(+), 46 deletions(-) diff --git a/lib/pages/main/browser.dart b/lib/pages/main/browser.dart index 0cd58ff..ae0f257 100644 --- a/lib/pages/main/browser.dart +++ b/lib/pages/main/browser.dart @@ -111,6 +111,9 @@ class _DeviceBrowserPageState extends State { ), ); + var conditionalExitButton = + Routemaster.of(context).history.canGoBack ? exitButton : null; + return Focus( autofocus: true, canRequestFocus: false, @@ -122,7 +125,7 @@ class _DeviceBrowserPageState extends State { length: 2, child: Scaffold( appBar: AppBar( - elevation: 0.8, + elevation: 2.8, // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: _AppBarActions( @@ -131,7 +134,8 @@ class _DeviceBrowserPageState extends State { serial: widget.serial, onUpload: _uploadFiles, ), - leading: exitButton, + leading: conditionalExitButton, + automaticallyImplyLeading: true, actions: [listViewButton], ), body: _buildBody(context), @@ -226,8 +230,9 @@ class _DeviceBrowserPageState extends State { files: list, key: ValueKey(list), filterController: _filterController, - builder: (context, filteredFiles) => - _viewAsListMode ? _viewAsList(filteredFiles) : _viewAsGrid(filteredFiles), + builder: (context, filteredFiles) => _viewAsListMode + ? _viewAsList(filteredFiles) + : _viewAsGrid(filteredFiles), ); } diff --git a/lib/pages/main/logger.dart b/lib/pages/main/logger.dart index e161542..20dad6b 100644 --- a/lib/pages/main/logger.dart +++ b/lib/pages/main/logger.dart @@ -39,45 +39,47 @@ class _LogPageState extends State { @override void initState() { super.initState(); - _logFuture.then((values) { - final (process, stream) = values; - try { - _streamSubscription = stream.listen((event) { - setState(() { - var newLogs = event - .split(PlatformUtils.platformFileEnding) - .where((element) => element.trim().isNotEmpty); - _logs.addAll(newLogs); - - if (waitForSave) { - var timeSinceSend = DateTime.now().difference(lastStreamSend); - if (timeSinceSend.inMilliseconds > 30) { - _saveLog(); - waitForSave = false; - } - } - - lastStreamSend = DateTime.now(); - }); - }); - _streamSubscription?.onError((e) { - Trace.verbose(e); - _showError(e); - }); - _streamSubscription?.onDone(() { - Trace.verbose("Done"); - }); - } catch (e) { - Trace.verbose(e.toString()); - _showError(e.toString()); - } - }).onError((error, stackTrace) { + _logFuture.then(_handleLogFuture).onError((error, stackTrace) { Trace.verbose("Error $error"); Trace.verbose(stackTrace.toString()); _showError(error.toString()); }); } + FutureOr _handleLogFuture(values) { + final (process, stream) = values; + try { + _streamSubscription = stream.listen((event) { + setState(() { + var newLogs = event + .split(PlatformUtils.platformFileEnding) + .where((element) => element.trim().isNotEmpty); + _logs.addAll(newLogs); + + if (waitForSave) { + var timeSinceSend = DateTime.now().difference(lastStreamSend); + if (timeSinceSend.inMilliseconds > 30) { + _saveLog(); + waitForSave = false; + } + } + + lastStreamSend = DateTime.now(); + }); + }); + _streamSubscription?.onError((e) { + Trace.verbose(e); + _showError(e); + }); + _streamSubscription?.onDone(() { + Trace.verbose("Done"); + }); + } catch (e) { + Trace.verbose(e.toString()); + _showError(e.toString()); + } + } + @override void dispose() { super.dispose(); @@ -90,18 +92,24 @@ class _LogPageState extends State { @override Widget build(BuildContext context) { + var exitButton = IconButton( + icon: const Icon( + FluentIcons.arrow_left_24_filled, + size: 24, + ), + onPressed: () { + Routemaster.of(context).history.back(); + }, + ); + + + var conditionalExitButton = Routemaster.of(context).history.canGoBack ? exitButton : null; + return Scaffold( appBar: AppBar( title: const Text("Logcat"), - leading: IconButton( - icon: const Icon( - FluentIcons.arrow_left_24_filled, - size: 24, - ), - onPressed: () { - Routemaster.of(context).history.back(); - }, - ), + leading: conditionalExitButton, + automaticallyImplyLeading: true, actions: [ Padding( padding: const EdgeInsets.all(8.0),