From 6ce6e7cf94a678d104769d1c4729a9354a011ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?th=E1=BB=8Bnh?= Date: Thu, 26 Dec 2024 09:44:40 +0700 Subject: [PATCH] Simplify local syncs --- app/lib/pages/conversation_detail/page.dart | 78 +++++++++---------- .../conversations/conversations_page.dart | 2 +- .../conversations/widgets/local_sync.dart | 30 +++---- .../widgets/processing_capture.dart | 14 ++-- 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/app/lib/pages/conversation_detail/page.dart b/app/lib/pages/conversation_detail/page.dart index 650e936c9..c7e3c1cee 100644 --- a/app/lib/pages/conversation_detail/page.dart +++ b/app/lib/pages/conversation_detail/page.dart @@ -510,45 +510,45 @@ class EditSegmentWidget extends StatelessWidget { ], ), ), - !provider.hasAudioRecording ? const SizedBox(height: 12) : const SizedBox(), - !provider.hasAudioRecording - ? GestureDetector( - onTap: () { - showDialog( - context: context, - builder: (c) => getDialog( - context, - () => Navigator.pop(context), - () { - Navigator.pop(context); - routeToPage(context, const RecordingsStoragePermission()); - }, - 'Can\'t be used for speech training', - 'This segment can\'t be used for speech training as there is no audio recording available. Check if you have the required permissions for future memories.', - okButtonText: 'View', - ), - ); - }, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text('Can\'t be used for speech training', - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith(decoration: TextDecoration.underline)), - const Padding( - padding: EdgeInsets.only(right: 12), - child: Icon(Icons.info, color: Colors.grey, size: 20), - ), - ], - ), - ), - ) - : const SizedBox(), + // !provider.hasAudioRecording ? const SizedBox(height: 12) : const SizedBox(), + // !provider.hasAudioRecording + // ? GestureDetector( + // onTap: () { + // showDialog( + // context: context, + // builder: (c) => getDialog( + // context, + // () => Navigator.pop(context), + // () { + // Navigator.pop(context); + // routeToPage(context, const RecordingsStoragePermission()); + // }, + // 'Can\'t be used for speech training', + // 'This segment can\'t be used for speech training as there is no audio recording available. Check if you have the required permissions for future memories.', + // okButtonText: 'View', + // ), + // ); + // }, + // child: Padding( + // padding: const EdgeInsets.symmetric(horizontal: 16.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Text('Can\'t be used for speech training', + // style: Theme.of(context) + // .textTheme + // .bodyMedium! + // .copyWith(decoration: TextDecoration.underline)), + // const Padding( + // padding: EdgeInsets.only(right: 12), + // child: Icon(Icons.info, color: Colors.grey, size: 20), + // ), + // ], + // ), + // ), + // ) + // : const SizedBox(), const SizedBox(height: 12), CheckboxListTile( title: const Text('Yours'), diff --git a/app/lib/pages/conversations/conversations_page.dart b/app/lib/pages/conversations/conversations_page.dart index 1f4691d55..3a6972140 100644 --- a/app/lib/pages/conversations/conversations_page.dart +++ b/app/lib/pages/conversations/conversations_page.dart @@ -49,8 +49,8 @@ class _ConversationsPageState extends State with AutomaticKee const SliverToBoxAdapter(child: SizedBox(height: 26)), const SliverToBoxAdapter(child: SpeechProfileCardWidget()), const SliverToBoxAdapter(child: UpdateFirmwareCardWidget()), - const SliverToBoxAdapter(child: LocalSyncWidget()), const SliverToBoxAdapter(child: ConversationCaptureWidget()), + const SliverToBoxAdapter(child: LocalSyncWidget()), getProcessingConversationsWidget(convoProvider.processingConversations), if (convoProvider.groupedConversations.isEmpty && !convoProvider.isLoadingConversations) const SliverToBoxAdapter( diff --git a/app/lib/pages/conversations/widgets/local_sync.dart b/app/lib/pages/conversations/widgets/local_sync.dart index ae4499b2e..8adbb4677 100644 --- a/app/lib/pages/conversations/widgets/local_sync.dart +++ b/app/lib/pages/conversations/widgets/local_sync.dart @@ -86,8 +86,8 @@ class _LocalSyncWidgetState extends State { margin: const EdgeInsets.fromLTRB(16, 16, 16, 16), padding: const EdgeInsets.all(16), child: Text( - '${convertToHHMMSS(_missSeconds)} of conversation locally', - style: const TextStyle(color: Colors.white, fontSize: 16), + '${secondsToHumanReadable(_missSeconds.toString())} On-Device Conversations', + style: Theme.of(context).textTheme.bodyMedium!.copyWith(fontSize: 16), textAlign: TextAlign.center, ), ); @@ -104,22 +104,24 @@ class _LocalSyncWidgetState extends State { color: Colors.grey.shade900, borderRadius: const BorderRadius.all(Radius.circular(12)), ), - margin: const EdgeInsets.fromLTRB(16, 16, 16, 16), padding: const EdgeInsets.all(16), + margin: const EdgeInsets.fromLTRB(16, 16, 16, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - child: Row( - children: [ - const Icon(Icons.download_rounded), - const SizedBox(width: 16), - Text( - '${secondsToHumanReadable(_missSeconds.toString())} available. Sync now?', - style: const TextStyle(color: Colors.white, fontSize: 16), - ), - ], - ), + const Row( + children: [ + Text( + 'Stay in Sync', + style: TextStyle(color: Colors.white, fontSize: 16), + textAlign: TextAlign.center, + ), + ], + ), + Text( + '${secondsToHumanReadable(_missSeconds.toString())} available', + style: Theme.of(context).textTheme.bodyMedium!.copyWith(decoration: TextDecoration.underline), ), ], ), diff --git a/app/lib/pages/conversations/widgets/processing_capture.dart b/app/lib/pages/conversations/widgets/processing_capture.dart index 73e15ad6a..226ebceb8 100644 --- a/app/lib/pages/conversations/widgets/processing_capture.dart +++ b/app/lib/pages/conversations/widgets/processing_capture.dart @@ -24,19 +24,19 @@ class ConversationCaptureWidget extends StatefulWidget { } class _ConversationCaptureWidgetState extends State { - bool _isReady = false; + bool _isReady = true; Timer? _readyStateTimer; @override void initState() { super.initState(); - // Warn: Should ensure every deps has started before set ready - _readyStateTimer = Timer(const Duration(seconds: 3), () { - setState(() { - _isReady = true; - }); - }); + //// Warn: Should ensure every deps has started before set ready + //_readyStateTimer = Timer(const Duration(seconds: 3), () { + // setState(() { + // _isReady = true; + // }); + //}); } @override