add initial value property in ToggleSwitchWidget for setting the initial value of toggle
This commit is contained in:
parent
bf0971f8ce
commit
02479a9955
|
@ -68,6 +68,8 @@ class BackupSettingsScreen extends StatelessWidget {
|
|||
.shouldBackupOverMobileData(),
|
||||
);
|
||||
},
|
||||
initialValue: Configuration.instance
|
||||
.shouldBackupOverMobileData(),
|
||||
),
|
||||
borderRadius: 8,
|
||||
alignCaptionedTextToLeft: true,
|
||||
|
@ -91,6 +93,8 @@ class BackupSettingsScreen extends StatelessWidget {
|
|||
.setShouldBackupVideos(
|
||||
!Configuration.instance.shouldBackupVideos(),
|
||||
),
|
||||
initialValue:
|
||||
Configuration.instance.shouldBackupVideos(),
|
||||
),
|
||||
borderRadius: 8,
|
||||
alignCaptionedTextToLeft: true,
|
||||
|
@ -121,6 +125,8 @@ class BackupSettingsScreen extends StatelessWidget {
|
|||
.shouldKeepDeviceAwake(),
|
||||
);
|
||||
},
|
||||
initialValue: Configuration.instance
|
||||
.shouldKeepDeviceAwake(),
|
||||
),
|
||||
borderRadius: 8,
|
||||
alignCaptionedTextToLeft: true,
|
||||
|
|
|
@ -15,9 +15,11 @@ typedef FutureValueCallBack = Future<bool> Function();
|
|||
class ToggleSwitchWidget extends StatefulWidget {
|
||||
final FutureValueCallBack value;
|
||||
final OnChangedCallBack onChanged;
|
||||
final bool initialValue;
|
||||
const ToggleSwitchWidget({
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
required this.initialValue,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
|
@ -33,8 +35,7 @@ class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {
|
|||
@override
|
||||
void initState() {
|
||||
futureToggleValue = widget.value.call();
|
||||
//need to assign correct intiial value of toggleValue here
|
||||
toggleValue = true;
|
||||
toggleValue = widget.initialValue;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
|||
),
|
||||
trailingSwitch: ToggleSwitchWidget(
|
||||
value: () => UserService.instance.fetchTwoFactorStatus(),
|
||||
initialValue: false,
|
||||
onChanged: () async {
|
||||
final hasAuthenticated = await LocalAuthenticationService
|
||||
.instance
|
||||
|
@ -108,6 +109,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
|||
"To enable lockscreen, please setup device passcode or screen lock in your system settings.",
|
||||
);
|
||||
},
|
||||
initialValue: _config.shouldShowLockScreen(),
|
||||
),
|
||||
),
|
||||
sectionOptionSpacing,
|
||||
|
@ -122,6 +124,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
|||
trailingSwitch: ToggleSwitchWidget(
|
||||
value: () => Future.value(_config.shouldHideFromRecents()),
|
||||
onChanged: _hideFromRecentsOnChanged,
|
||||
initialValue: _config.shouldHideFromRecents(),
|
||||
),
|
||||
),
|
||||
sectionOptionSpacing,
|
||||
|
|
Loading…
Reference in a new issue