From 85446962766ea80eebfa9547ca45e2de72fe52c9 Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Fri, 2 Jan 2026 15:03:46 +0100 Subject: [PATCH] instructions UI change --- .../devices/zwift/zwift_clickv2.dart | 18 +-- lib/pages/markdown.dart | 71 ++++----- lib/pages/navigation.dart | 145 +++++++++--------- lib/widgets/apps/mywhoosh_link_tile.dart | 9 +- lib/widgets/menu.dart | 113 +++++++------- lib/widgets/ui/connection_method.dart | 7 +- lib/widgets/ui/help_button.dart | 7 +- 7 files changed, 178 insertions(+), 192 deletions(-) diff --git a/lib/bluetooth/devices/zwift/zwift_clickv2.dart b/lib/bluetooth/devices/zwift/zwift_clickv2.dart index 3c655cbf..b1b13bd2 100644 --- a/lib/bluetooth/devices/zwift/zwift_clickv2.dart +++ b/lib/bluetooth/devices/zwift/zwift_clickv2.dart @@ -99,11 +99,10 @@ class ZwiftClickV2 extends ZwiftRide { Button.secondary( onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), - ), + openDrawer( + context: context, + position: OverlayPosition.bottom, + builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), ); }, leading: const Icon(Icons.help_outline_outlined), @@ -136,11 +135,10 @@ class ZwiftClickV2 extends ZwiftRide { LinkButton( child: Text(context.i18n.troubleshootingGuide), onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), - ), + openDrawer( + context: context, + position: OverlayPosition.bottom, + builder: (_) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), ); }, ), diff --git a/lib/pages/markdown.dart b/lib/pages/markdown.dart index 579f9635..1c7d4411 100644 --- a/lib/pages/markdown.dart +++ b/lib/pages/markdown.dart @@ -1,10 +1,8 @@ -import 'package:dartx/dartx.dart'; -import 'package:flutter/material.dart' show BackButton; +import 'package:bike_control/widgets/ui/gradient_text.dart'; import 'package:flutter/services.dart'; import 'package:flutter_md/flutter_md.dart'; import 'package:http/http.dart' as http; import 'package:shadcn_flutter/shadcn_flutter.dart'; -import 'package:bike_control/widgets/ui/colored_title.dart'; import 'package:url_launcher/url_launcher_string.dart'; class MarkdownPage extends StatefulWidget { @@ -40,51 +38,36 @@ class _ChangelogPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - headers: [ - AppBar( - leading: [ - BackButton(), - ], - title: Text( - widget.assetPath - .replaceAll('.md', '') - .split('_') - .joinToString(separator: ' ', transform: (s) => s.toLowerCase().capitalize()), - ), - ), - ], - child: _error != null - ? Center(child: Text(_error!)) - : _groups == null - ? Center(child: CircularProgressIndicator()) - : SingleChildScrollView( - padding: EdgeInsets.all(16), - child: Accordion( - items: _groups! - .map( - (group) => AccordionItem( - trigger: AccordionTrigger(child: ColoredTitle(text: group.title)), - content: MarkdownWidget( - markdown: group.markdown, - theme: MarkdownThemeData( - textStyle: TextStyle( - fontSize: 14.0, - color: Theme.of(context).colorScheme.brightness == Brightness.dark - ? Colors.white.withAlpha(255 * 70) - : Colors.black.withAlpha(87 * 255), - ), - onLinkTap: (title, url) { - launchUrlString(url); - }, + return _error != null + ? Center(child: Text(_error!)) + : _groups == null + ? Center(child: CircularProgressIndicator()) + : SingleChildScrollView( + padding: EdgeInsets.all(16), + child: Accordion( + items: _groups! + .map( + (group) => AccordionItem( + trigger: AccordionTrigger(child: GradientText(group.title).bold), + content: MarkdownWidget( + markdown: group.markdown, + theme: MarkdownThemeData( + textStyle: TextStyle( + fontSize: 14.0, + color: Theme.of(context).colorScheme.brightness == Brightness.dark + ? Colors.white.withAlpha(255 * 70) + : Colors.black.withAlpha(87 * 255), ), + onLinkTap: (title, url) { + launchUrlString(url); + }, ), ), - ) - .toList(), - ), + ), + ) + .toList(), ), - ); + ); } void _parseMarkdown(String md) { diff --git a/lib/pages/navigation.dart b/lib/pages/navigation.dart index e03667ed..a6843348 100644 --- a/lib/pages/navigation.dart +++ b/lib/pages/navigation.dart @@ -132,10 +132,10 @@ class _NavigationState extends State { @override Widget build(BuildContext context) { - return Stack( - children: [ - Scaffold( - headers: [ + return Scaffold( + headers: [ + Stack( + children: [ AppBar( padding: const EdgeInsets.only(top: 12, bottom: 8, left: 12, right: 12) * @@ -154,78 +154,77 @@ class _NavigationState extends State { : null, ), ), - Divider(), - ], - footers: _isMobile - ? [ - if (_isMobile) Center(child: HelpButton(isMobile: true)), - Divider(), - _buildNavigationBar(), - ] - : [], - floatingFooter: true, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (!_isMobile) ...[ - _buildNavigationMenu(), - VerticalDivider(), - ], - Expanded( - child: AnimatedSwitcher( - duration: Duration(milliseconds: 200), - child: switch (_selectedPage) { - BCPage.devices => Align( - alignment: Alignment.topLeft, - key: _pageKeys[BCPage.devices], - child: DevicePage( - isMobile: _isMobile, - onUpdate: () { - setState(() { - _selectedPage = BCPage.trainer; - }); - }, - ), - ), - BCPage.trainer => Align( - alignment: Alignment.topLeft, - key: _pageKeys[BCPage.trainer], - child: TrainerPage( - onUpdate: () { - setState(() {}); - }, - goToNextPage: () { - setState(() { - _selectedPage = BCPage.customization; - }); - }, - isMobile: _isMobile, - ), - ), - BCPage.customization => Align( - alignment: Alignment.topLeft, - key: _pageKeys[BCPage.customization], - child: CustomizePage(isMobile: _isMobile), - ), - BCPage.logs => Padding( - padding: EdgeInsets.only(bottom: _isMobile ? 146 : 16, left: 16, right: 16, top: 16), - child: LogViewer( - key: _pageKeys[BCPage.logs], - ), - ), - }, - ), + if (!_isMobile) + Container( + alignment: Alignment.topCenter, + child: HelpButton(isMobile: false), ), - ], - ), + ], ), - - if (!_isMobile) - Container( - alignment: Alignment.topCenter, - child: HelpButton(isMobile: false), - ), + Divider(), ], + footers: _isMobile + ? [ + if (_isMobile) Center(child: HelpButton(isMobile: true)), + Divider(), + _buildNavigationBar(), + ] + : [], + floatingFooter: true, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (!_isMobile) ...[ + _buildNavigationMenu(), + VerticalDivider(), + ], + Expanded( + child: AnimatedSwitcher( + duration: Duration(milliseconds: 200), + child: switch (_selectedPage) { + BCPage.devices => Align( + alignment: Alignment.topLeft, + key: _pageKeys[BCPage.devices], + child: DevicePage( + isMobile: _isMobile, + onUpdate: () { + setState(() { + _selectedPage = BCPage.trainer; + }); + }, + ), + ), + BCPage.trainer => Align( + alignment: Alignment.topLeft, + key: _pageKeys[BCPage.trainer], + child: TrainerPage( + onUpdate: () { + setState(() {}); + }, + goToNextPage: () { + setState(() { + _selectedPage = BCPage.customization; + }); + }, + isMobile: _isMobile, + ), + ), + BCPage.customization => Align( + alignment: Alignment.topLeft, + key: _pageKeys[BCPage.customization], + child: CustomizePage(isMobile: _isMobile), + ), + BCPage.logs => Padding( + padding: EdgeInsets.only(bottom: _isMobile ? 146 : 16, left: 16, right: 16, top: 16), + child: LogViewer( + key: _pageKeys[BCPage.logs], + ), + ), + }, + ), + ), + ], + ), ); } diff --git a/lib/widgets/apps/mywhoosh_link_tile.dart b/lib/widgets/apps/mywhoosh_link_tile.dart index abac8d46..79782466 100644 --- a/lib/widgets/apps/mywhoosh_link_tile.dart +++ b/lib/widgets/apps/mywhoosh_link_tile.dart @@ -48,11 +48,10 @@ class _MywhooshLinkTileState extends State { duration: Duration(seconds: 6), closeTitle: 'Open', onClose: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => MarkdownPage(assetPath: 'INSTRUCTIONS_MYWHOOSH_LINK.md'), - ), + openDrawer( + context: context, + position: OverlayPosition.bottom, + builder: (c) => MarkdownPage(assetPath: 'INSTRUCTIONS_MYWHOOSH_LINK.md'), ); }, ); diff --git a/lib/widgets/menu.dart b/lib/widgets/menu.dart index 92f4e90f..ec9e4f72 100644 --- a/lib/widgets/menu.dart +++ b/lib/widgets/menu.dart @@ -20,67 +20,68 @@ import '../utils/iap/iap_manager.dart'; List buildMenuButtons(BuildContext context, BCPage currentPage, VoidCallback? openLogs) { return [ - Builder( - builder: (context) { - return OutlineButton( - density: ButtonDensity.icon, - onPressed: () { - showDropdown( - context: context, - builder: (c) => DropdownMenu( - children: [ - if ((!Platform.isIOS && !Platform.isMacOS)) ...[ - MenuLabel(child: Text(context.i18n.showDonation)), - MenuButton( - child: Text(context.i18n.donateViaCreditCard), - onPressed: (c) { - final currency = NumberFormat.simpleCurrency(locale: kIsWeb ? 'de_DE' : Platform.localeName); - final link = switch (currency.currencyName) { - 'USD' => 'https://donate.stripe.com/8x24gzc5c4ZE3VJdt36J201', - _ => 'https://donate.stripe.com/9B6aEX0muajY8bZ1Kl6J200', - }; - launchUrlString(link); - }, - ), - if (!kIsWeb && Platform.isAndroid && isFromPlayStore == false) + if (IAPManager.instance.isPurchased.value) + Builder( + builder: (context) { + return OutlineButton( + density: ButtonDensity.icon, + onPressed: () { + showDropdown( + context: context, + builder: (c) => DropdownMenu( + children: [ + if ((!Platform.isIOS && !Platform.isMacOS)) ...[ + MenuLabel(child: Text(context.i18n.showDonation)), MenuButton( - child: Text(context.i18n.donateByBuyingFromPlayStore), + child: Text(context.i18n.donateViaCreditCard), onPressed: (c) { - launchUrlString('https://play.google.com/store/apps/details?id=de.jonasbark.swiftcontrol'); + final currency = NumberFormat.simpleCurrency(locale: kIsWeb ? 'de_DE' : Platform.localeName); + final link = switch (currency.currencyName) { + 'USD' => 'https://donate.stripe.com/8x24gzc5c4ZE3VJdt36J201', + _ => 'https://donate.stripe.com/9B6aEX0muajY8bZ1Kl6J200', + }; + launchUrlString(link); }, ), + if (!kIsWeb && Platform.isAndroid && isFromPlayStore == false) + MenuButton( + child: Text(context.i18n.donateByBuyingFromPlayStore), + onPressed: (c) { + launchUrlString('https://play.google.com/store/apps/details?id=de.jonasbark.swiftcontrol'); + }, + ), + MenuButton( + child: Text(context.i18n.donateViaPaypal), + onPressed: (c) { + launchUrlString('https://paypal.me/boni'); + }, + ), + ], MenuButton( - child: Text(context.i18n.donateViaPaypal), - onPressed: (c) { - launchUrlString('https://paypal.me/boni'); + leading: Icon(Icons.star_rate), + child: Text(context.i18n.leaveAReview), + onPressed: (c) async { + final InAppReview inAppReview = InAppReview.instance; + + if (await inAppReview.isAvailable()) { + inAppReview.requestReview(); + } else { + inAppReview.openStoreListing(appStoreId: 'id6753721284', microsoftStoreId: '9NP42GS03Z26'); + } }, ), ], - MenuButton( - leading: Icon(Icons.star_rate), - child: Text(context.i18n.leaveAReview), - onPressed: (c) async { - final InAppReview inAppReview = InAppReview.instance; - - if (await inAppReview.isAvailable()) { - inAppReview.requestReview(); - } else { - inAppReview.openStoreListing(appStoreId: 'id6753721284', microsoftStoreId: '9NP42GS03Z26'); - } - }, - ), - ], - ), - ); - }, - child: Icon( - Icons.favorite, - color: Colors.red, - size: 18, - ), - ); - }, - ), + ), + ); + }, + child: Icon( + Icons.favorite, + color: Colors.red, + size: 18, + ), + ); + }, + ), Gap(4), BKMenuButton(openLogs: openLogs, currentPage: currentPage), @@ -166,7 +167,11 @@ class BKMenuButton extends StatelessWidget { leading: Icon(Icons.update_outlined), child: Text(context.i18n.changelog), onPressed: (c) { - Navigator.push(context, MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: 'CHANGELOG.md'))); + openDrawer( + context: context, + position: OverlayPosition.bottom, + builder: (c) => MarkdownPage(assetPath: 'CHANGELOG.md'), + ); }, ), MenuButton( diff --git a/lib/widgets/ui/connection_method.dart b/lib/widgets/ui/connection_method.dart index 49c6a801..3a5f61b9 100644 --- a/lib/widgets/ui/connection_method.dart +++ b/lib/widgets/ui/connection_method.dart @@ -157,9 +157,10 @@ class _ConnectionMethodState extends State with WidgetsBinding : ButtonStyle.outline(), leading: Icon(Icons.help_outline), onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: widget.instructionLink!)), + openDrawer( + context: context, + position: OverlayPosition.bottom, + builder: (c) => MarkdownPage(assetPath: widget.instructionLink!), ); }, child: Text(AppLocalizations.of(context).instructions), diff --git a/lib/widgets/ui/help_button.dart b/lib/widgets/ui/help_button.dart index 5470397d..e69d075a 100644 --- a/lib/widgets/ui/help_button.dart +++ b/lib/widgets/ui/help_button.dart @@ -138,9 +138,10 @@ class HelpButton extends StatelessWidget { leading: Icon(Icons.help_outline), child: Text(context.i18n.troubleshootingGuide), onPressed: (c) { - Navigator.push( - context, - MaterialPageRoute(builder: (c) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md')), + openDrawer( + context: context, + position: OverlayPosition.bottom, + builder: (c) => MarkdownPage(assetPath: 'TROUBLESHOOTING.md'), ); }, ),