frost checkbox widget

This commit is contained in:
julian 2024-05-01 17:15:04 -06:00
parent b2087c1f1d
commit 72069bd070
13 changed files with 174 additions and 228 deletions

View file

@ -10,6 +10,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -209,40 +210,13 @@ class _FrostCreateStep1aState extends ConsumerState<FrostCreateStep1a> {
const SizedBox(
height: 16,
),
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have verified that everyone has joined the group",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have verified that everyone has joined the group",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
const SizedBox(
height: 16,

View file

@ -5,6 +5,7 @@ import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart';
import 'package:stackwallet/services/frost.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/frost_step_user_steps.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -117,40 +118,13 @@ class _FrostCreateStep1bState extends ConsumerState<FrostCreateStep1b> {
const SizedBox(
height: 16,
),
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have verified that everyone has joined the group",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have verified that everyone has joined the group",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
const SizedBox(
height: 16,

View file

@ -8,8 +8,8 @@ import 'package:stackwallet/services/frost.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -145,40 +145,13 @@ class _FrostCreateStep2State extends ConsumerState<FrostCreateStep2> {
),
if (!Util.isDesktop) const Spacer(),
const SizedBox(height: 12),
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have verified that everyone has my commitment",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have verified that everyone has all commitments",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
const SizedBox(height: 12),
PrimaryButton(

View file

@ -9,6 +9,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -34,6 +35,8 @@ class _FrostCreateStep3State extends ConsumerState<FrostCreateStep3> {
"Enter their shares into the corresponding fields.",
];
bool _userVerifyContinue = false;
final List<TextEditingController> controllers = [];
final List<FocusNode> focusNodes = [];
@ -141,9 +144,21 @@ class _FrostCreateStep3State extends ConsumerState<FrostCreateStep3> {
),
if (!Util.isDesktop) const Spacer(),
const SizedBox(height: 12),
CheckboxTextButton(
label: "I have verified that everyone has my share",
onChanged: (value) {
setState(() {
_userVerifyContinue = value;
});
},
),
const SizedBox(
height: 16,
),
PrimaryButton(
label: "Generate",
enabled: !fieldIsEmptyFlags.reduce((v, e) => v |= e),
enabled: _userVerifyContinue &&
!fieldIsEmptyFlags.reduce((v, e) => v |= e),
onPressed: () async {
// check for empty commitments
if (controllers

View file

@ -19,6 +19,7 @@ import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/detail_item.dart';
@ -104,40 +105,13 @@ class _FrostCreateStep5State extends ConsumerState<FrostCreateStep5> {
),
if (!Util.isDesktop) const Spacer(),
const SizedBox(height: 12),
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have backed up my keys and the config",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have backed up my keys and the config",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
const SizedBox(height: 12),
PrimaryButton(

View file

@ -15,6 +15,7 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -283,40 +284,13 @@ class _FrostReshareStep1aState extends ConsumerState<FrostReshareStep1a> {
height: 16,
),
if (iAmInvolved)
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have verified that everyone has imported the config",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have verified that everyone has imported the config",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
if (iAmInvolved)
const SizedBox(

View file

@ -8,9 +8,9 @@ import 'package:stackwallet/providers/global/secure_store_provider.dart';
import 'package:stackwallet/services/frost.dart';
import 'package:stackwallet/utilities/format.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/frost_step_user_steps.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
@ -182,40 +182,13 @@ class _FrostReshareStep1bState extends ConsumerState<FrostReshareStep1b> {
const SizedBox(
height: 16,
),
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have verified that everyone has imported the config",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have verified that everyone has imported the config",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
const SizedBox(
height: 16,

View file

@ -6,10 +6,10 @@ import 'package:stackwallet/frost_route_generator.dart';
import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/show_loading.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/models/incomplete_frost_wallet.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/frost_step_user_steps.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
@ -122,40 +122,13 @@ class _FrostReshareStep1cState extends ConsumerState<FrostReshareStep1c> {
const SizedBox(
height: 16,
),
GestureDetector(
onTap: () {
CheckboxTextButton(
label: "I have verified that everyone has joined the group",
onChanged: (value) {
setState(() {
_userVerifyContinue = !_userVerifyContinue;
_userVerifyContinue = value;
});
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _userVerifyContinue,
onChanged: (value) => setState(
() => _userVerifyContinue = value == true,
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"I have verified that everyone has joined the group",
style: STextStyles.w500_14(context),
),
),
],
),
),
),
const SizedBox(
height: 16,

View file

@ -12,6 +12,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/detail_item.dart';
@ -42,6 +43,8 @@ class _FrostReshareStep2abdState extends ConsumerState<FrostReshareStep2abd> {
bool _buttonLock = false;
bool _userVerifyContinue = false;
Future<void> _onPressed() async {
if (_buttonLock) {
return;
@ -207,10 +210,22 @@ class _FrostReshareStep2abdState extends ConsumerState<FrostReshareStep2abd> {
const SizedBox(
height: 12,
),
CheckboxTextButton(
label: "I have verified that everyone has my resharer",
onChanged: (value) {
setState(() {
_userVerifyContinue = value;
});
},
),
const SizedBox(
height: 16,
),
PrimaryButton(
label: "Continue",
enabled: amOutgoingParticipant ||
!fieldIsEmptyFlags.reduce((v, e) => v |= e),
enabled: _userVerifyContinue &&
(amOutgoingParticipant ||
!fieldIsEmptyFlags.reduce((v, e) => v |= e)),
onPressed: _onPressed,
),
],

View file

@ -10,6 +10,7 @@ import 'package:stackwallet/services/frost.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/detail_item.dart';
@ -38,6 +39,8 @@ class _FrostReshareStep3abdState extends ConsumerState<FrostReshareStep3abd> {
final List<bool> fieldIsEmptyFlags = [];
bool _userVerifyContinue = false;
bool _buttonLock = false;
Future<void> _onPressed() async {
if (_buttonLock) {
@ -197,9 +200,21 @@ class _FrostReshareStep3abdState extends ConsumerState<FrostReshareStep3abd> {
const SizedBox(
height: 12,
),
CheckboxTextButton(
label: "I have verified that everyone has my encryption key",
onChanged: (value) {
setState(() {
_userVerifyContinue = value;
});
},
),
const SizedBox(
height: 16,
),
PrimaryButton(
label: "Continue",
enabled: !fieldIsEmptyFlags.reduce((v, e) => v |= e),
enabled: _userVerifyContinue &&
!fieldIsEmptyFlags.reduce((v, e) => v |= e),
onPressed: _onPressed,
),
],

View file

@ -6,6 +6,7 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_deta
import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/detail_item.dart';
@ -17,10 +18,12 @@ class FrostReshareStep3c extends ConsumerStatefulWidget {
static const String title = "Encryption keys";
@override
ConsumerState<FrostReshareStep3c> createState() => _FrostReshareStep3bState();
ConsumerState<FrostReshareStep3c> createState() => _FrostReshareStep3cState();
}
class _FrostReshareStep3bState extends ConsumerState<FrostReshareStep3c> {
class _FrostReshareStep3cState extends ConsumerState<FrostReshareStep3c> {
bool _userVerifyContinue = false;
@override
Widget build(BuildContext context) {
return Padding(
@ -72,8 +75,20 @@ class _FrostReshareStep3bState extends ConsumerState<FrostReshareStep3c> {
const SizedBox(
height: 16,
),
CheckboxTextButton(
label: "I have verified that everyone has my encryption key",
onChanged: (value) {
setState(() {
_userVerifyContinue = value;
});
},
),
const SizedBox(
height: 16,
),
PrimaryButton(
label: "Continue",
enabled: _userVerifyContinue,
onPressed: () {
ref.read(pFrostCreateCurrentStep.state).state = 4;
Navigator.of(context).pushNamed(

View file

@ -14,6 +14,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart';
import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart';
import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/detail_item.dart';
@ -43,6 +44,8 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
final List<bool> fieldIsEmptyFlags = [];
bool _userVerifyContinue = false;
bool _buttonLock = false;
Future<void> _onPressed() async {
if (_buttonLock) {
@ -232,10 +235,22 @@ class _FrostReshareStep4State extends ConsumerState<FrostReshareStep4> {
const SizedBox(
height: 16,
),
CheckboxTextButton(
label: "I have verified that everyone has my resharer complete",
onChanged: (value) {
setState(() {
_userVerifyContinue = value;
});
},
),
const SizedBox(
height: 16,
),
PrimaryButton(
label: amOutgoingParticipant ? "Exit" : "Complete",
enabled: amOutgoingParticipant ||
!fieldIsEmptyFlags.reduce((v, e) => v |= e),
enabled: _userVerifyContinue &&
(amOutgoingParticipant ||
!fieldIsEmptyFlags.reduce((v, e) => v |= e)),
onPressed: _onPressed,
),
],

View file

@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:stackwallet/utilities/text_styles.dart';
class CheckboxTextButton extends StatefulWidget {
const CheckboxTextButton({super.key, required this.label, this.onChanged});
final String label;
final void Function(bool)? onChanged;
@override
State<CheckboxTextButton> createState() => _CheckboxTextButtonState();
}
class _CheckboxTextButtonState extends State<CheckboxTextButton> {
bool _value = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
setState(() {
_value = !_value;
});
widget.onChanged?.call(_value);
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 26,
child: IgnorePointer(
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: _value,
onChanged: (_) {},
),
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
widget.label,
style: STextStyles.w500_14(context),
),
),
],
),
),
);
}
}