|
|
@ -2,8 +2,8 @@ import 'dart:async'; |
|
|
|
|
|
|
|
|
|
|
|
import 'package:meta/meta.dart'; |
|
|
|
import 'package:meta/meta.dart'; |
|
|
|
import 'package:neon/src/bloc/bloc.dart'; |
|
|
|
import 'package:neon/src/bloc/bloc.dart'; |
|
|
|
|
|
|
|
import 'package:neon/src/settings/models/storage.dart'; |
|
|
|
import 'package:rxdart/rxdart.dart'; |
|
|
|
import 'package:rxdart/rxdart.dart'; |
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class FirstLaunchBlocEvents {} |
|
|
|
abstract class FirstLaunchBlocEvents {} |
|
|
|
|
|
|
|
|
|
|
@ -11,20 +11,20 @@ abstract class FirstLaunchBlocStates { |
|
|
|
BehaviorSubject get onFirstLaunch; |
|
|
|
BehaviorSubject get onFirstLaunch; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@immutable |
|
|
|
@internal |
|
|
|
@internal |
|
|
|
class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunchBlocStates { |
|
|
|
class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunchBlocStates { |
|
|
|
FirstLaunchBloc( |
|
|
|
FirstLaunchBloc({ |
|
|
|
this._sharedPreferences, { |
|
|
|
|
|
|
|
final bool disabled = false, |
|
|
|
final bool disabled = false, |
|
|
|
}) { |
|
|
|
}) : _storage = AppStorage(_keyFirstLaunch) { |
|
|
|
if (!disabled && !_sharedPreferences.containsKey(_keyFirstLaunch)) { |
|
|
|
if (!disabled && !_storage.containsKey(_keyFirstLaunch)) { |
|
|
|
onFirstLaunch.add(null); |
|
|
|
onFirstLaunch.add(null); |
|
|
|
unawaited(_sharedPreferences.setBool(_keyFirstLaunch, false)); |
|
|
|
unawaited(_storage.setBool(_keyFirstLaunch, false)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final SharedPreferences _sharedPreferences; |
|
|
|
final AppStorage _storage; |
|
|
|
final _keyFirstLaunch = 'first-launch'; |
|
|
|
static const _keyFirstLaunch = 'first-launch'; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
void dispose() { |
|
|
@ -32,5 +32,5 @@ class FirstLaunchBloc extends Bloc implements FirstLaunchBlocEvents, FirstLaunch |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
BehaviorSubject onFirstLaunch = BehaviorSubject(); |
|
|
|
final BehaviorSubject onFirstLaunch = BehaviorSubject(); |
|
|
|
} |
|
|
|
} |
|
|
|