syncing pref options show on button press + shows card w current syncing prefs

This commit is contained in:
ryleedavis 2022-11-18 11:26:27 -07:00
parent 9508afbd5b
commit 792b91b7c4

View file

@ -3,9 +3,13 @@ import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/rounded_container.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
class SyncingPreferencesSettings extends ConsumerStatefulWidget { class SyncingPreferencesSettings extends ConsumerStatefulWidget {
@ -20,6 +24,19 @@ class SyncingPreferencesSettings extends ConsumerStatefulWidget {
class _SyncingPreferencesSettings class _SyncingPreferencesSettings
extends ConsumerState<SyncingPreferencesSettings> { extends ConsumerState<SyncingPreferencesSettings> {
String _currentTypeDescription(SyncingType type) {
switch (type) {
case SyncingType.currentWalletOnly:
return "Sync only currently open wallet";
case SyncingType.selectedWalletsAtStartup:
return "Sync only selected wallets at startup";
case SyncingType.allWalletsOnStartup:
return "Sync all wallets at startup";
}
}
late bool changePrefs = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType"); debugPrint("BUILD: $runtimeType");
@ -34,13 +51,40 @@ class _SyncingPreferencesSettings
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Padding( Row(
padding: const EdgeInsets.all(8.0), mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: SvgPicture.asset( children: [
Assets.svg.circleArrowRotate, Padding(
width: 48, padding: const EdgeInsets.all(8.0),
height: 48, child: SvgPicture.asset(
), Assets.svg.circleArrowRotate,
width: 48,
height: 48,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.buttonBackSecondaryDisabled,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
_currentTypeDescription(ref.watch(
prefsChangeNotifierProvider
.select((value) => value.syncType))),
style: STextStyles.desktopTextExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark2),
textAlign: TextAlign.left,
),
),
),
),
],
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -67,28 +111,50 @@ class _SyncingPreferencesSettings
), ),
], ],
), ),
///TODO: ONLY SHOW SYNC OPTIONS ON BUTTON PRESS
Column(
children: const [
SyncingOptionsView(),
],
),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all( padding: const EdgeInsets.all(
10, 10,
), ),
child: PrimaryButton( child: changePrefs
width: 210, ? SizedBox(
buttonHeight: ButtonHeight.m, width: 512,
enabled: true, child: Column(
label: "Change preferences", crossAxisAlignment: CrossAxisAlignment.start,
onPressed: () {}, children: [
), const SyncingOptionsView(),
), PrimaryButton(
width: 200,
buttonHeight: ButtonHeight.m,
enabled: true,
label: "Save",
onPressed: () {
setState(() {
changePrefs = false;
});
},
),
],
),
)
: Column(
children: [
const SizedBox(height: 10),
PrimaryButton(
width: 200,
buttonHeight: ButtonHeight.m,
enabled: true,
label: "Change preferences",
onPressed: () {
setState(() {
changePrefs = true;
});
},
),
],
)),
], ],
), ),
], ],