70 lines
2.2 KiB
Dart
70 lines
2.2 KiB
Dart
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';
|
|
|
|
Future<void> 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,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 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<PointerDeviceKind> get dragDevices => {
|
|
PointerDeviceKind.touch,
|
|
PointerDeviceKind.mouse,
|
|
PointerDeviceKind.trackpad,
|
|
PointerDeviceKind.stylus,
|
|
};
|
|
}
|