From 10c6487cb080b7bf83732f1b132075f0897e2153 Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 14:46:07 +0200 Subject: [PATCH 1/7] update version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9320f1f..cd32b4b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: vidar description: "Private Communications Application" publish_to: "none" -version: 1.2.0-beta+3 +version: 1.2.1-beta+4 repository: "https://github.com/DrSolidDevil/Vidar" issue_tracker: "https://github.com/DrSolidDevil/Vidar/issues" From 02a152f6b7d0eae646f6040e2cb09191e21e11dc Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 14:59:27 +0200 Subject: [PATCH 2/7] Fixed issue of switch not updating for `BooleanSetting`. This was due to not utilizing `setState`. In addition to this, I gave `BooleanSetting` the ability to utilize a custom `onChanged` action. This custom action does by default not need to include `setState` nor a statement to update the value of the switch. Although if it is not needed to rebuild BooleanSetting after every value change (e.g. a larger rebuild occurs), then it can be turned of by setting `doSetState` to false. These changes make `LightBooleanSetting` redunant and has therefore been removed. --- lib/pages/settings_page.dart | 9 +-- lib/widgets/boolean_setting.dart | 113 ++++++------------------------- 2 files changed, 26 insertions(+), 96 deletions(-) diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 9c26a90..aef36a2 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -21,18 +21,19 @@ class SettingsPage extends StatefulWidget { class _SettingsPageState extends State { _SettingsPageState() { - allowWipeoutTime = LightBooleanSetting( - initValue: allowWipeoutTimeValue, + allowWipeoutTime = BooleanSetting( + setting: allowWipeoutTimeValue, settingText: "Require login every X days", - onChanged: (final bool value) { + customOnChanged: (final bool value) { setState(() { allowWipeoutTimeValue = !allowWipeoutTimeValue; }); }, + doSetState: false, ); } - late final LightBooleanSetting allowWipeoutTime; + late final BooleanSetting allowWipeoutTime; bool allowWipeoutTimeValue = Settings.allowWipeoutTime; diff --git a/lib/widgets/boolean_setting.dart b/lib/widgets/boolean_setting.dart index 981c7a8..41eee9e 100644 --- a/lib/widgets/boolean_setting.dart +++ b/lib/widgets/boolean_setting.dart @@ -9,7 +9,8 @@ class BooleanSetting extends StatefulWidget { BooleanSetting({ required this.setting, required this.settingText, - this.onChanged, + this.customOnChanged, + this.doSetState = true, super.key, }); @@ -19,7 +20,14 @@ class BooleanSetting extends StatefulWidget { /// The text shown to the user explaining the setting. final String settingText; - final Function(bool value)? onChanged; + + /// Allows the implementation of additional actions beyond just changing the value + final Function(bool value)? customOnChanged; + + /// If set to false then the BooleanSetting will not update when its value is changed. + /// To make it update when doSetState is set to false you need to update it in a parent widget or use a builder. + final bool doSetState; + @override _BooleanSettingState createState() => _BooleanSettingState(); } @@ -29,17 +37,22 @@ class _BooleanSettingState extends State { late final String settingText; late final Function(bool value)? onChanged; + late final bool doSetState; @override void initState() { super.initState(); settingText = widget.settingText; - onChanged = - (widget.onChanged ?? - (final bool value) { - widget.setting = value; - }) - as Function(bool value)?; + onChanged = (final bool value) { + (widget.customOnChanged ?? (_){})(value); + if (doSetState) { + setState(() { + widget.setting = value; + }); + } else { + widget.setting = value; + } + }; } @override @@ -88,87 +101,3 @@ class _BooleanSettingState extends State { ); } } - -/// This version does not automate the setting handling -class LightBooleanSetting extends StatefulWidget { - const LightBooleanSetting({ - required this.settingText, - required this.onChanged, - required this.initValue, - super.key, - }); - - /// The text shown to the user explaining the setting. - final String settingText; - final bool initValue; - final Function(bool value) onChanged; - @override - _LightBooleanSettingState createState() => _LightBooleanSettingState(); -} - -class _LightBooleanSettingState extends State { - _LightBooleanSettingState(); - - late final String settingText; - late final Function(bool value) onChanged; - late bool value; - - @override - void initState() { - super.initState(); - settingText = widget.settingText; - onChanged = widget.onChanged; - value = widget.initValue; - } - - @override - Widget build(final BuildContext context) { - return Container( - margin: const EdgeInsets.only(top: 40), - color: Settings.colorSet.primary, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - margin: EdgeInsets.only( - right: MediaQuery.of(context).size.width * 0.1, - ), - child: Material( - color: Colors.transparent, - child: Switch( - activeColor: Settings.colorSet.tertiary, - inactiveThumbColor: Settings.colorSet.secondary, - inactiveTrackColor: Settings.colorSet.inactiveTrack, - trackOutlineColor: WidgetStateProperty.resolveWith( - (final Set states) => - states.contains(WidgetState.selected) - ? null - : Settings.colorSet.secondary, - ), - value: value, - onChanged: (final bool value) { - setState(() { - onChanged(value); - this.value = value; - }); - }, - ), - ), - ), - - SizedBox( - width: MediaQuery.of(context).size.width * 0.6, - child: Text( - settingText, - style: TextStyle( - color: Settings.colorSet.text, - fontSize: SizeConfiguration.settingInfoText, - decoration: TextDecoration.none, - ), - ), - ), - ], - ), - ); - } -} From 17ebb98247eaa861434a68af611128d10ac009f9 Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:02:12 +0200 Subject: [PATCH 3/7] (fix) Forgot to initialize `doSetState` in `_BooleanSettingState`. --- lib/widgets/boolean_setting.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/widgets/boolean_setting.dart b/lib/widgets/boolean_setting.dart index 41eee9e..4553eeb 100644 --- a/lib/widgets/boolean_setting.dart +++ b/lib/widgets/boolean_setting.dart @@ -42,6 +42,7 @@ class _BooleanSettingState extends State { @override void initState() { super.initState(); + doSetState = widget.doSetState; settingText = widget.settingText; onChanged = (final bool value) { (widget.customOnChanged ?? (_){})(value); From 8231b36a4b33913ea5ce77f8da7aed5a8d890193 Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:07:00 +0200 Subject: [PATCH 4/7] Minor change in distance between buttons in settings page --- lib/pages/settings_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index aef36a2..0fe6d54 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -164,7 +164,7 @@ class _SettingsPageState extends State { ], ), Container( - margin: const EdgeInsets.only(top: 60), + margin: const EdgeInsets.only(top: 40), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -187,7 +187,7 @@ class _SettingsPageState extends State { ], ), Padding( - padding: const EdgeInsets.only(top: 100), + padding: const EdgeInsets.only(top: 60), child: Column( spacing: 50, children: [ From 13c969980d8d98fcd67db244cfefba62e54c70b8 Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:09:15 +0200 Subject: [PATCH 5/7] format --- lib/widgets/boolean_setting.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/widgets/boolean_setting.dart b/lib/widgets/boolean_setting.dart index 4553eeb..98eda88 100644 --- a/lib/widgets/boolean_setting.dart +++ b/lib/widgets/boolean_setting.dart @@ -27,7 +27,7 @@ class BooleanSetting extends StatefulWidget { /// If set to false then the BooleanSetting will not update when its value is changed. /// To make it update when doSetState is set to false you need to update it in a parent widget or use a builder. final bool doSetState; - + @override _BooleanSettingState createState() => _BooleanSettingState(); } @@ -45,15 +45,15 @@ class _BooleanSettingState extends State { doSetState = widget.doSetState; settingText = widget.settingText; onChanged = (final bool value) { - (widget.customOnChanged ?? (_){})(value); - if (doSetState) { - setState(() { - widget.setting = value; - }); - } else { + (widget.customOnChanged ?? (_) {})(value); + if (doSetState) { + setState(() { widget.setting = value; - } - }; + }); + } else { + widget.setting = value; + } + }; } @override From f5f74f53aad9008b69d59358da12f4a298b9a66b Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:19:57 +0200 Subject: [PATCH 6/7] Fixed allowWipeoutTime switch not updating. --- lib/pages/settings_page.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 0fe6d54..10fbc7d 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -29,7 +29,6 @@ class _SettingsPageState extends State { allowWipeoutTimeValue = !allowWipeoutTimeValue; }); }, - doSetState: false, ); } From 1d116d532c71c414d838483bd263537b8356ff3d Mon Sep 17 00:00:00 2001 From: DrSolidDevil <51828495+DrSolidDevil@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:23:05 +0200 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5a4c8a..9334dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## [1.2.1-beta](https://github.com/DrSolidDevil/Vidar/compare/v1.2.0-beta...v1.2.1-beta) (2025-07-28) + +> Fixes and minor visual adjustments. + +### Bug Fixes +* Fixed issue of `BooleanSetting` not updating in respose to user input. [`02a152f`](https://github.com/DrSolidDevil/Vidar/commit/02a152f6b7d0eae646f6040e2cb09191e21e11dc) + +### Other Changes +* Minor adjustment for button distances on the settings page. [`8231b36`](https://github.com/DrSolidDevil/Vidar/commit/8231b36a4b33913ea5ce77f8da7aed5a8d890193) +* Removed `LightBooleanSetting` and replaced it with `BooleanSetting` which now has the ability to have custom `onChanged` actions. [`02a152f`](https://github.com/DrSolidDevil/Vidar/commit/02a152f6b7d0eae646f6040e2cb09191e21e11dc) [`17ebb98`](https://github.com/DrSolidDevil/Vidar/commit/17ebb98247eaa861434a68af611128d10ac009f9) [`f5f74f5`](https://github.com/DrSolidDevil/Vidar/commit/f5f74f53aad9008b69d59358da12f4a298b9a66b) + +
+ ## [1.2.0-beta](https://github.com/DrSolidDevil/Vidar/compare/v1.1.0-beta...v1.2.0-beta) (2025-07-20) ### New Features * Added ability have a maximum log-on interval (otherwise keys are wiped) [`8120f1a`](https://github.com/DrSolidDevil/Vidar/commit/8120f1a760ec0dcf887f1ee5aede5205399c7a0b) [`66cf291`](https://github.com/DrSolidDevil/Vidar/commit/66cf291784d87d9a5019561f9cd2ebdc198d36d5)