This commit is contained in:
+51
-26
@@ -5,7 +5,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../features/mapflow/application/place_cubit.dart';
|
||||
import '../features/mapflow/data/mapflow_api.dart';
|
||||
import '../features/mapflow/data/auth_repository.dart';
|
||||
import '../features/mapflow/data/mapflow_graphql_client.dart';
|
||||
import '../features/mapflow/data/places_repository.dart';
|
||||
import '../features/mapflow/data/voice_experiences_repository.dart';
|
||||
import '../shared/location/current_location.dart';
|
||||
import 'router/app_router.dart';
|
||||
import 'theme/mapflow_theme.dart';
|
||||
@@ -18,14 +21,28 @@ class MapflowApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MapflowAppState extends State<MapflowApp> {
|
||||
late final MapflowGraphqlClient _graphqlClient;
|
||||
late final AuthRepository _authRepository;
|
||||
late final PlacesRepository _placesRepository;
|
||||
late final VoiceExperiencesRepository _voiceExperiencesRepository;
|
||||
late final PlaceCubit _placeCubit;
|
||||
late final GoRouter _router;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_placeCubit = PlaceCubit(api: MapflowApi(), location: CurrentLocation())
|
||||
..load();
|
||||
_graphqlClient = MapflowGraphqlClient();
|
||||
_authRepository = AuthRepository(client: _graphqlClient);
|
||||
_placesRepository = PlacesRepository(client: _graphqlClient);
|
||||
_voiceExperiencesRepository = VoiceExperiencesRepository(
|
||||
client: _graphqlClient,
|
||||
);
|
||||
_placeCubit = PlaceCubit(
|
||||
authRepository: _authRepository,
|
||||
placesRepository: _placesRepository,
|
||||
voiceExperiencesRepository: _voiceExperiencesRepository,
|
||||
location: CurrentLocation(),
|
||||
)..load();
|
||||
_router = createAppRouter();
|
||||
}
|
||||
|
||||
@@ -33,6 +50,7 @@ class _MapflowAppState extends State<MapflowApp> {
|
||||
void dispose() {
|
||||
_router.dispose();
|
||||
_placeCubit.close();
|
||||
_graphqlClient.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -45,31 +63,38 @@ class _MapflowAppState extends State<MapflowApp> {
|
||||
..[const SingleActivator(LogicalKeyboardKey.tab, shift: true)] =
|
||||
const PreviousFocusIntent();
|
||||
|
||||
return BlocProvider.value(
|
||||
value: _placeCubit,
|
||||
child: MaterialApp.router(
|
||||
title: 'MapFlow',
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: _router,
|
||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
||||
scrollbars: true,
|
||||
dragDevices: {
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
return MultiRepositoryProvider(
|
||||
providers: [
|
||||
RepositoryProvider.value(value: _authRepository),
|
||||
RepositoryProvider.value(value: _placesRepository),
|
||||
RepositoryProvider.value(value: _voiceExperiencesRepository),
|
||||
],
|
||||
child: BlocProvider.value(
|
||||
value: _placeCubit,
|
||||
child: MaterialApp.router(
|
||||
title: 'MapFlow',
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: _router,
|
||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
||||
scrollbars: true,
|
||||
dragDevices: {
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
},
|
||||
),
|
||||
theme: MapflowTheme.light(),
|
||||
builder: (context, child) {
|
||||
return Shortcuts(
|
||||
shortcuts: shortcuts,
|
||||
child: FocusTraversalGroup(
|
||||
policy: ReadingOrderTraversalPolicy(),
|
||||
child: child ?? const SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
theme: MapflowTheme.light(),
|
||||
builder: (context, child) {
|
||||
return Shortcuts(
|
||||
shortcuts: shortcuts,
|
||||
child: FocusTraversalGroup(
|
||||
policy: ReadingOrderTraversalPolicy(),
|
||||
child: child ?? const SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user