mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-06 18:59:24 +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 {
|
||||
const MultisigCoordinatorView({
|
||||
super.key,
|
||||
required this.walletId,
|
||||
required this.totalCosigners,
|
||||
required this.threshold,
|
||||
});
|
||||
|
||||
final String walletId;
|
||||
final int totalCosigners;
|
||||
final int threshold;
|
||||
|
||||
|
@ -254,13 +256,100 @@ class _MultisigSetupViewState extends ConsumerState<MultisigCoordinatorView> {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Enter the extended public key (xpub) for each cosigner. "
|
||||
"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(
|
||||
"Enter the extended public key (xpub) for each cosigner. "
|
||||
"These can be obtained from each participant's wallet.",
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Generate input fields for each cosigner
|
||||
// Generate input fields for each cosigner.
|
||||
for (int i = 0; i < widget.totalCosigners; i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
|
|
|
@ -111,10 +111,12 @@ class MultisigSetupState extends StateNotifier<MultisigSetupData> {
|
|||
class MultisigSetupView extends ConsumerStatefulWidget {
|
||||
const MultisigSetupView({
|
||||
super.key,
|
||||
required this.walletId,
|
||||
this.totalCosigners,
|
||||
this.threshold,
|
||||
});
|
||||
|
||||
final String walletId;
|
||||
final int? totalCosigners;
|
||||
final int? threshold;
|
||||
|
||||
|
@ -528,6 +530,7 @@ class _MultisigSetupViewState extends ConsumerState<MultisigSetupView> {
|
|||
await Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (context) => MultisigCoordinatorView(
|
||||
walletId: widget.walletId,
|
||||
totalCosigners:
|
||||
int.parse(_participantsController.text),
|
||||
threshold: int.parse(_thresholdController.text),
|
||||
|
|
|
@ -2158,21 +2158,24 @@ class RouteGenerator {
|
|||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case MultisigSetupView.routeName:
|
||||
if (args is Tuple2<int?, int?>) {
|
||||
if (args is Tuple3<String, int?, int?>) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => MultisigSetupView(
|
||||
totalCosigners: args.item1,
|
||||
threshold: args.item2,
|
||||
walletId: args.item1,
|
||||
totalCosigners: args.item2,
|
||||
threshold: args.item3,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
} else if (args is String) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => const MultisigSetupView(),
|
||||
builder: (_) => MultisigSetupView(
|
||||
walletId: args,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
|
@ -2181,12 +2184,13 @@ class RouteGenerator {
|
|||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case MultisigCoordinatorView.routeName:
|
||||
if (args is Tuple2<int, int>) {
|
||||
if (args is Tuple3<String, int, int>) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => MultisigCoordinatorView(
|
||||
totalCosigners: args.item1,
|
||||
threshold: args.item2,
|
||||
walletId: args.item1,
|
||||
totalCosigners: args.item2,
|
||||
threshold: args.item3,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
|
|
Loading…
Reference in a new issue