Fix slider possition change from outside

This commit is contained in:
Yegor Vialov 2020-05-14 10:56:52 +00:00
parent 5683ab5158
commit 9b7f7aa380
4 changed files with 15 additions and 4 deletions

View File

@ -28,10 +28,10 @@ class UniversalSliderState extends State<UniversalSlider> {
double _value;
bool _changeStarted = false;
bool _changedHere = false;
@override
void initState() {
_value = widget.value;
super.initState();
}
@ -39,6 +39,11 @@ class UniversalSliderState extends State<UniversalSlider> {
Widget build(BuildContext context) {
List <Widget> row = [];
List <Widget> col = [];
if (!_changedHere) {
_value = widget.value;
} else {
_changedHere = false;
}
if (widget.leading != null) {
row.add(widget.leading);
}
@ -57,6 +62,7 @@ class UniversalSliderState extends State<UniversalSlider> {
onChanged: (value) {
setState(() {
_value = value;
_changedHere = true;
});
widget.onChanged?.call(value);
},
@ -64,6 +70,7 @@ class UniversalSliderState extends State<UniversalSlider> {
_changeStarted = false;
setState(() {
_value = value;
_changedHere = true;
});
Timer(Duration(milliseconds: 500), () {
if (!_changeStarted) {

View File

@ -159,7 +159,7 @@ EventBus eventBus = new EventBus();
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
const String appName = 'HA Client';
const appVersionNumber = '1.0.1';
const appVersionNumber = '1.1.0';
final String appVersionAdd = secrets['version_type'] ?? '';
final String appVersion = '$appVersionNumber${appVersionAdd.isNotEmpty ? '-' : ''}$appVersionAdd';
const whatsNewUrl = 'http://ha-client.app/service/whats_new_1.0.1.md';

View File

@ -36,8 +36,9 @@ class AppSettings {
appTheme = AppTheme.values[prefs.getInt('app-theme') ?? AppTheme.defaultTheme.index];
}
Future load(bool quick) async {
if (!quick) {
Future load(bool full) async {
if (full) {
Logger.d('Loading settings...');
SharedPreferences prefs = await SharedPreferences.getInstance();
_domain = prefs.getString('hassio-domain');
_port = prefs.getString('hassio-port');
@ -53,6 +54,7 @@ class AppSettings {
locationUpdateInterval = Duration(minutes: prefs.getInt("location-interval") ??
defaultLocationUpdateIntervalMinutes);
locationTrackingEnabled = prefs.getBool("location-enabled") ?? false;
Logger.d('Done. $_domain:$_port');
try {
final storage = new FlutterSecureStorage();
longLivedToken = await storage.read(key: "hacl_llt");

View File

@ -27,7 +27,9 @@ class ConnectionManager {
Future init({bool loadSettings, bool forceReconnect: false}) {
Completer completer = Completer();
AppSettings().load(loadSettings).then((_) {
Logger.d('Checking config...');
if (AppSettings().isNotConfigured()) {
Logger.d('This is first start');
completer.completeError(HACNotSetUpException());
} else if (AppSettings().isSomethingMissed()) {
completer.completeError(HACException.checkConnectionSettings());