Cw 567 cant swipe through menus on desktop builds (#1563)

* MaterialApp scrollBehavior * accessibility improvements

Serhii committed Aug 10, 2024 at 01:21 UTC b412d45f0e3a97758aa5b438c90979f2a39bb324
7 files changed +75 -37
lib/app_scroll_behavior.dart new
+9
@@ -0,0 +1,9 @@
1 +import 'dart:ui';
2 +
3 +import 'package:flutter/material.dart';
4 +
5 +class AppScrollBehavior extends MaterialScrollBehavior {
6 + @override
7 + Set<PointerDeviceKind> get dragDevices =>
8 + {PointerDeviceKind.touch, PointerDeviceKind.mouse, PointerDeviceKind.trackpad};
9 +}
lib/main.dart
+3
@@ -1,5 +1,6 @@
1 import 'dart:async';
2 import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
3 +import 'package:cake_wallet/app_scroll_behavior.dart';
4 import 'package:cake_wallet/buy/order.dart';
5 import 'package:cake_wallet/core/auth_service.dart';
6 import 'package:cake_wallet/di.dart';
@@ -75,6 +76,7 @@ Future<void> main() async {
76 runApp(
77 MaterialApp(
78 debugShowCheckedModeBanner: false,
79 + scrollBehavior: AppScrollBehavior(),
80 home: Scaffold(
81 body: SingleChildScrollView(
82 child: Container(
@@ -297,6 +299,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
299 locale: Locale(settingsStore.languageCode),
300 onGenerateRoute: (settings) => Router.createRoute(settings),
301 initialRoute: initialRoute,
302 + scrollBehavior: AppScrollBehavior(),
303 home: _Home(),
304 ));
305 });
lib/src/screens/dashboard/dashboard_page.dart
+5 -1
@@ -237,7 +237,11 @@ class _DashboardPageView extends BasePage {
237 padding: EdgeInsets.only(bottom: 24, top: 10),
238 child: Observer(
239 builder: (context) {
240 - return ExcludeSemantics(
240 + return Semantics(
241 + button: false,
242 + label: 'Page Indicator',
243 + hint: 'Swipe to change page',
244 + excludeSemantics: true,
245 child: SmoothPageIndicator(
246 controller: controller,
247 count: pages.length,
lib/src/screens/dashboard/pages/balance_page.dart
+14 -9
@@ -23,6 +23,7 @@ import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
23 import 'package:cake_wallet/view_model/dashboard/nft_view_model.dart';
24 import 'package:cw_core/crypto_currency.dart';
25 import 'package:flutter/material.dart';
26 +import 'package:flutter/widgets.dart';
27 import 'package:flutter_mobx/flutter_mobx.dart';
28 import 'package:url_launcher/url_launcher.dart';
29
@@ -469,15 +470,19 @@ class BalanceRowWidget extends StatelessWidget {
470 children: [
471 Row(
472 children: [
472 - Text('${availableBalanceLabel}',
473 - style: TextStyle(
474 - fontSize: 12,
475 - fontFamily: 'Lato',
476 - fontWeight: FontWeight.w400,
477 - color: Theme.of(context)
478 - .extension<BalancePageTheme>()!
479 - .labelTextColor,
480 - height: 1)),
473 + Semantics(
474 + hint: 'Double tap to see more information',
475 + container: true,
476 + child: Text('${availableBalanceLabel}',
477 + style: TextStyle(
478 + fontSize: 12,
479 + fontFamily: 'Lato',
480 + fontWeight: FontWeight.w400,
481 + color: Theme.of(context)
482 + .extension<BalancePageTheme>()!
483 + .labelTextColor,
484 + height: 1)),
485 + ),
486 if (hasAdditionalBalance)
487 Padding(
488 padding: const EdgeInsets.symmetric(horizontal: 4),
lib/src/screens/restore/wallet_restore_page.dart
+16 -10
@@ -177,16 +177,22 @@ class WalletRestorePage extends BasePage {
177 if (_pages.length > 1)
178 Padding(
179 padding: EdgeInsets.only(top: 10),
180 - child: SmoothPageIndicator(
181 - controller: _controller,
182 - count: _pages.length,
183 - effect: ColorTransitionEffect(
184 - spacing: 6.0,
185 - radius: 6.0,
186 - dotWidth: 6.0,
187 - dotHeight: 6.0,
188 - dotColor: Theme.of(context).hintColor.withOpacity(0.5),
189 - activeDotColor: Theme.of(context).hintColor,
180 + child: Semantics(
181 + button: false,
182 + label: 'Page Indicator',
183 + hint: 'Swipe to change restore mode',
184 + excludeSemantics: true,
185 + child: SmoothPageIndicator(
186 + controller: _controller,
187 + count: _pages.length,
188 + effect: ColorTransitionEffect(
189 + spacing: 6.0,
190 + radius: 6.0,
191 + dotWidth: 6.0,
192 + dotHeight: 6.0,
193 + dotColor: Theme.of(context).hintColor.withOpacity(0.5),
194 + activeDotColor: Theme.of(context).hintColor,
195 + ),
196 ),
197 ),
198 ),
lib/src/screens/send/send_page.dart
+7 -2
@@ -212,7 +212,12 @@ class SendPage extends BasePage {
212 final count = sendViewModel.outputs.length;
213
214 return count > 1
215 - ? SmoothPageIndicator(
215 + ? Semantics (
216 + label: 'Page Indicator',
217 + hint: 'Swipe to change receiver',
218 + excludeSemantics: true,
219 + child:
220 + SmoothPageIndicator(
221 controller: controller,
222 count: count,
223 effect: ScrollingDotsEffect(
@@ -226,7 +231,7 @@ class SendPage extends BasePage {
231 activeDotColor: Theme.of(context)
232 .extension<SendPageTheme>()!
233 .templateBackgroundColor),
229 - )
234 + ))
235 : Offstage();
236 },
237 ),
lib/src/screens/send/send_template_page.dart
+21 -15
@@ -94,21 +94,27 @@ class SendTemplatePage extends BasePage {
94 final count = sendTemplateViewModel.recipients.length;
95
96 return count > 1
97 - ? SmoothPageIndicator(
98 - controller: controller,
99 - count: count,
100 - effect: ScrollingDotsEffect(
101 - spacing: 6.0,
102 - radius: 6.0,
103 - dotWidth: 6.0,
104 - dotHeight: 6.0,
105 - dotColor: Theme.of(context)
106 - .extension<SendPageTheme>()!
107 - .indicatorDotColor,
108 - activeDotColor: Theme.of(context)
109 - .extension<DashboardPageTheme>()!
110 - .indicatorDotTheme
111 - .activeIndicatorColor))
97 + ? Semantics(
98 + button: false,
99 + label: 'Page Indicator',
100 + hint: 'Swipe to change receiver',
101 + excludeSemantics: true,
102 + child: SmoothPageIndicator(
103 + controller: controller,
104 + count: count,
105 + effect: ScrollingDotsEffect(
106 + spacing: 6.0,
107 + radius: 6.0,
108 + dotWidth: 6.0,
109 + dotHeight: 6.0,
110 + dotColor: Theme.of(context)
111 + .extension<SendPageTheme>()!
112 + .indicatorDotColor,
113 + activeDotColor: Theme.of(context)
114 + .extension<DashboardPageTheme>()!
115 + .indicatorDotTheme
116 + .activeIndicatorColor)),
117 + )
118 : Offstage();
119 },
120 ),