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) diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 9c26a90..10fbc7d 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -21,10 +21,10 @@ 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; }); @@ -32,7 +32,7 @@ class _SettingsPageState extends State { ); } - late final LightBooleanSetting allowWipeoutTime; + late final BooleanSetting allowWipeoutTime; bool allowWipeoutTimeValue = Settings.allowWipeoutTime; @@ -163,7 +163,7 @@ class _SettingsPageState extends State { ], ), Container( - margin: const EdgeInsets.only(top: 60), + margin: const EdgeInsets.only(top: 40), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -186,7 +186,7 @@ class _SettingsPageState extends State { ], ), Padding( - padding: const EdgeInsets.only(top: 100), + padding: const EdgeInsets.only(top: 60), child: Column( spacing: 50, children: [ diff --git a/lib/widgets/boolean_setting.dart b/lib/widgets/boolean_setting.dart index 981c7a8..98eda88 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,23 @@ class _BooleanSettingState extends State { late final String settingText; late final Function(bool value)? onChanged; + late final bool doSetState; @override void initState() { super.initState(); + doSetState = widget.doSetState; 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 +102,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, - ), - ), - ), - ], - ), - ); - } -} 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"