Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

<br>

## [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)
Expand Down
12 changes: 6 additions & 6 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class SettingsPage extends StatefulWidget {

class _SettingsPageState extends State<SettingsPage> {
_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;
});
},
);
}

late final LightBooleanSetting allowWipeoutTime;
late final BooleanSetting allowWipeoutTime;

bool allowWipeoutTimeValue = Settings.allowWipeoutTime;

Expand Down Expand Up @@ -163,7 +163,7 @@ class _SettingsPageState extends State<SettingsPage> {
],
),
Container(
margin: const EdgeInsets.only(top: 60),
margin: const EdgeInsets.only(top: 40),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expand All @@ -186,7 +186,7 @@ class _SettingsPageState extends State<SettingsPage> {
],
),
Padding(
padding: const EdgeInsets.only(top: 100),
padding: const EdgeInsets.only(top: 60),
child: Column(
spacing: 50,
children: <Widget>[
Expand Down
114 changes: 22 additions & 92 deletions lib/widgets/boolean_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class BooleanSetting extends StatefulWidget {
BooleanSetting({
required this.setting,
required this.settingText,
this.onChanged,
this.customOnChanged,
this.doSetState = true,
super.key,
});

Expand All @@ -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();
}
Expand All @@ -29,17 +37,23 @@ class _BooleanSettingState extends State<BooleanSetting> {

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
Expand Down Expand Up @@ -88,87 +102,3 @@ class _BooleanSettingState extends State<BooleanSetting> {
);
}
}

/// 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<LightBooleanSetting> {
_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: <Widget>[
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<WidgetState> 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,
),
),
),
],
),
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down