2023-11-26 22:52:52 +00:00
|
|
|
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>();
|
2023-11-26 22:52:52 +00:00
|
|
|
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'));
|
2023-11-26 22:52:52 +00:00
|
|
|
await Future.delayed(const Duration(milliseconds: 100));
|
2021-02-02 14:33:23 +00:00
|
|
|
|
|
|
|
setStateMessage(translate('startup.start_services'));
|
|
|
|
await _sessionService.start();
|
2023-11-26 22:52:52 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|