fbmobile/lib/core/viewmodels/startup_model.dart

28 lines
911 B
Dart
Raw Normal View History

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 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-01-04 20:17:54 +00:00
await Future.delayed(const Duration(milliseconds: 150));
2021-02-02 14:33:23 +00:00
setStateMessage(translate('startup.start_services'));
await _sessionService.start();
2023-01-04 20:17:54 +00:00
await Future.delayed(const Duration(milliseconds: 150));
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
}
}