fbmobile/lib/core/viewmodels/startup_model.dart

31 lines
1.1 KiB
Dart
Raw Permalink Normal View History

import 'package:fbmobile/core/services/permission_service.dart';
2021-02-02 14:33:23 +00:00
import 'package:flutter_translate/flutter_translate.dart';
import '../../locator.dart';
import '../../ui/views/home_view.dart';
import '../enums/viewstate.dart';
import '../services/navigation_service.dart';
import '../services/session_service.dart';
import 'base_model.dart';
class StartUpViewModel extends BaseModel {
final SessionService _sessionService = locator<SessionService>();
final PermissionService _permissionService = locator<PermissionService>();
2021-02-02 14:33:23 +00:00
final NavigationService _navigationService = locator<NavigationService>();
Future handleStartUpLogic() async {
2023-01-04 20:17:54 +00:00
setStateView(ViewState.busy);
2021-02-02 14:33:23 +00:00
setStateMessage(translate('startup.init'));
await Future.delayed(const Duration(milliseconds: 100));
2021-02-02 14:33:23 +00:00
setStateMessage(translate('startup.start_services'));
await _sessionService.start();
await _permissionService.start();
await Future.delayed(const Duration(milliseconds: 100));
2021-02-02 14:33:23 +00:00
_navigationService.navigateAndReplaceTo(HomeView.routeName);
2023-01-04 20:17:54 +00:00
setStateView(ViewState.idle);
2021-02-02 14:33:23 +00:00
}
}