import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'core/router.dart'; import 'core/theme.dart'; import 'state/session_controller.dart'; import 'widgets/phone_frame.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); final prefs = await SharedPreferences.getInstance(); SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.light, ), ); runApp( ProviderScope( overrides: [prefsProvider.overrideWithValue(prefs)], child: const KrowApp(), ), ); } class KrowApp extends StatelessWidget { const KrowApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp.router( title: 'KROW Worker', debugShowCheckedModeBanner: false, theme: buildKrowTheme(), scrollBehavior: const KrowScrollBehavior(), routerConfig: router, builder: (context, child) => PhoneFrame(child: child ?? const SizedBox()), ); } } /// Scrolling feel, applied everywhere. class KrowScrollBehavior extends MaterialScrollBehavior { const KrowScrollBehavior(); // Scroll physics is deliberately left to the platform. // // Forcing BouncingScrollPhysics everywhere looked smoother on a long list // and broke every short one: ScrollView's constructor hands any vertical // list without a controller an AlwaysScrollableScrollPhysics, which is // applied over whatever the behaviour returns and answers // shouldAcceptUserOffset true regardless of content. Bouncing then let // content that already fits be dragged away from the header, leaving a gap // down the screen. Android's clamping accepts the same drag and pins it to // the boundary, so nothing moves; iOS bounces, which is its own convention. /// Let the web and desktop builds be dragged with a mouse or trackpad, not /// only scrolled with a wheel. @override Set get dragDevices => { PointerDeviceKind.touch, PointerDeviceKind.mouse, PointerDeviceKind.trackpad, PointerDeviceKind.stylus, }; }