mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-08 19:59:29 +00:00
chore: pass walletId to views
This commit is contained in:
parent
53901ef6a5
commit
b8105215e2
3 changed files with 106 additions and 10 deletions
|
@ -108,10 +108,12 @@ class MultisigCoordinatorState extends StateNotifier<MultisigCoordinatorData> {
|
||||||
class MultisigCoordinatorView extends ConsumerStatefulWidget {
|
class MultisigCoordinatorView extends ConsumerStatefulWidget {
|
||||||
const MultisigCoordinatorView({
|
const MultisigCoordinatorView({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.walletId,
|
||||||
required this.totalCosigners,
|
required this.totalCosigners,
|
||||||
required this.threshold,
|
required this.threshold,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final String walletId;
|
||||||
final int totalCosigners;
|
final int totalCosigners;
|
||||||
final int threshold;
|
final int threshold;
|
||||||
|
|
||||||
|
@ -253,6 +255,93 @@ class _MultisigSetupViewState extends ConsumerState<MultisigCoordinatorView> {
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
Text(
|
||||||
|
"This is your extended public key (xpub) for each cosigner. "
|
||||||
|
"Share it with each participant.",
|
||||||
|
style: STextStyles.itemSubtitle(context),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Your xpub",
|
||||||
|
style: STextStyles.w500_14(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textDark3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: xpubControllers[0],
|
||||||
|
enabled:
|
||||||
|
false, // Make field non-interactive
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "xpub...",
|
||||||
|
hintStyle:
|
||||||
|
STextStyles.fieldLabel(context),
|
||||||
|
filled:
|
||||||
|
true, // Add background to show disabled state
|
||||||
|
fillColor: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldDefaultBG,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
SecondaryButton(
|
||||||
|
width: 44,
|
||||||
|
buttonHeight: ButtonHeight.xl,
|
||||||
|
icon: QrCodeIcon(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// TODO: Implement QR code scanning
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
SecondaryButton(
|
||||||
|
width: 44,
|
||||||
|
buttonHeight: ButtonHeight.xl,
|
||||||
|
icon: CopyIcon(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextSecondary,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final data = await Clipboard.getData(
|
||||||
|
'text/plain');
|
||||||
|
if (data?.text != null) {
|
||||||
|
xpubControllers[0].text = data!.text!;
|
||||||
|
ref
|
||||||
|
.read(
|
||||||
|
multisigCoordinatorStateProvider
|
||||||
|
.notifier)
|
||||||
|
.addCosignerXpub(data.text!);
|
||||||
|
setState(
|
||||||
|
() {}); // Trigger rebuild to update button state.
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
"Enter the extended public key (xpub) for each cosigner. "
|
"Enter the extended public key (xpub) for each cosigner. "
|
||||||
"These can be obtained from each participant's wallet.",
|
"These can be obtained from each participant's wallet.",
|
||||||
|
@ -260,7 +349,7 @@ class _MultisigSetupViewState extends ConsumerState<MultisigCoordinatorView> {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// Generate input fields for each cosigner
|
// Generate input fields for each cosigner.
|
||||||
for (int i = 0; i < widget.totalCosigners; i++)
|
for (int i = 0; i < widget.totalCosigners; i++)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
|
|
|
@ -111,10 +111,12 @@ class MultisigSetupState extends StateNotifier<MultisigSetupData> {
|
||||||
class MultisigSetupView extends ConsumerStatefulWidget {
|
class MultisigSetupView extends ConsumerStatefulWidget {
|
||||||
const MultisigSetupView({
|
const MultisigSetupView({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.walletId,
|
||||||
this.totalCosigners,
|
this.totalCosigners,
|
||||||
this.threshold,
|
this.threshold,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final String walletId;
|
||||||
final int? totalCosigners;
|
final int? totalCosigners;
|
||||||
final int? threshold;
|
final int? threshold;
|
||||||
|
|
||||||
|
@ -528,6 +530,7 @@ class _MultisigSetupViewState extends ConsumerState<MultisigSetupView> {
|
||||||
await Navigator.of(context).push(
|
await Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
MaterialPageRoute<void>(
|
||||||
builder: (context) => MultisigCoordinatorView(
|
builder: (context) => MultisigCoordinatorView(
|
||||||
|
walletId: widget.walletId,
|
||||||
totalCosigners:
|
totalCosigners:
|
||||||
int.parse(_participantsController.text),
|
int.parse(_participantsController.text),
|
||||||
threshold: int.parse(_thresholdController.text),
|
threshold: int.parse(_thresholdController.text),
|
||||||
|
|
|
@ -2158,21 +2158,24 @@ class RouteGenerator {
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
case MultisigSetupView.routeName:
|
case MultisigSetupView.routeName:
|
||||||
if (args is Tuple2<int?, int?>) {
|
if (args is Tuple3<String, int?, int?>) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => MultisigSetupView(
|
builder: (_) => MultisigSetupView(
|
||||||
totalCosigners: args.item1,
|
walletId: args.item1,
|
||||||
threshold: args.item2,
|
totalCosigners: args.item2,
|
||||||
|
threshold: args.item3,
|
||||||
),
|
),
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else if (args is String) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => const MultisigSetupView(),
|
builder: (_) => MultisigSetupView(
|
||||||
|
walletId: args,
|
||||||
|
),
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
),
|
),
|
||||||
|
@ -2181,12 +2184,13 @@ class RouteGenerator {
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
case MultisigCoordinatorView.routeName:
|
case MultisigCoordinatorView.routeName:
|
||||||
if (args is Tuple2<int, int>) {
|
if (args is Tuple3<String, int, int>) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => MultisigCoordinatorView(
|
builder: (_) => MultisigCoordinatorView(
|
||||||
totalCosigners: args.item1,
|
walletId: args.item1,
|
||||||
threshold: args.item2,
|
totalCosigners: args.item2,
|
||||||
|
threshold: args.item3,
|
||||||
),
|
),
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
|
|
Loading…
Reference in a new issue