diff --git a/lib/src/ui/sec_modal.dart b/lib/src/ui/sec_modal.dart index 0f6ba28..50717f0 100644 --- a/lib/src/ui/sec_modal.dart +++ b/lib/src/ui/sec_modal.dart @@ -13,7 +13,7 @@ import 'package:mtrust_sec_kit/src/ui/sec_result.dart'; /// Provide a [builder] that renders some UI with a callback to open the sheet. class SecModalBuilder extends StatelessWidget { /// Creates a new instance of [SecModalBuilder] - const SecModalBuilder({ + const SecModalBuilder({ required this.strategy, required this.payload, required this.onVerificationDone, @@ -23,6 +23,8 @@ class SecModalBuilder extends StatelessWidget { this.disconnectOnClose = true, this.turnOffOnClose = true, this.canDismiss = true, + this.fixedDialogSize = const Size(400, 400), + this.tokenAmount, super.key, }); @@ -50,9 +52,15 @@ class SecModalBuilder extends StatelessWidget { /// The builder that opens the sheet. final Widget Function(BuildContext context, Function openSheet) builder; - /// Whether the modal can be dissmissed by the user + /// Whether the modal can be dissmissed by the user. final bool canDismiss; + /// Size of the modal. + final Size fixedDialogSize; + + /// Amount of tokens to be requested on token refresh. + final int? tokenAmount; + @override Widget build(BuildContext context) { var topRadius = LdTheme.of(context).sizingConfig.radiusM; @@ -101,6 +109,8 @@ class SecModalBuilder extends StatelessWidget { useSafeArea: useSafeArea, strategy: strategy, payload: payload, + fixedDialogSize: fixedDialogSize, + tokenAmount: tokenAmount, ), ); } @@ -146,15 +156,21 @@ LdModal secModal({ /// Whether to use safe area inside the modal required bool useSafeArea, + + /// Size of the modal + Size fixedDialogSize = const Size(400, 400), + + /// Amount of token to be requested on token refresh + int? tokenAmount, }) { return LdModal( disableScrolling: true, padding: EdgeInsets.zero, noHeader: true, - showDismissButton: false, + showDismissButton: canDismiss, userCanDismiss: canDismiss, topRadius: topRadius, - fixedDialogSize: const Size(400, 400), + fixedDialogSize: fixedDialogSize, bottomRadius: bottomRadius, useSafeArea: useSafeArea, insets: insets, @@ -170,6 +186,7 @@ LdModal secModal({ onVerificationFailed: () async { Navigator.of(context).pop(SecResultFailed()); }, + tokenAmount: tokenAmount, ), ).padL(), ); diff --git a/lib/src/ui/sec_widget.dart b/lib/src/ui/sec_widget.dart index 2c47f58..ff93360 100644 --- a/lib/src/ui/sec_widget.dart +++ b/lib/src/ui/sec_widget.dart @@ -16,6 +16,7 @@ class SecWidget extends StatelessWidget { required this.onVerificationDone, required this.onVerificationFailed, this.storageAdapter, + this.tokenAmount, super.key, }); @@ -35,6 +36,9 @@ class SecWidget extends StatelessWidget { /// Will be called if a verification failed. final Future Function() onVerificationFailed; + /// Amount of token to be requested on token refresh. + final int? tokenAmount; + @override Widget build(BuildContext context) { return DeviceConnector( @@ -49,6 +53,9 @@ class SecWidget extends StatelessWidget { final reader = SECReader( connectionStrategy: strategy, ); + if(tokenAmount != null) { + reader.setTokenAmount(tokenAmount!); + } return reader.prime(payload); }, ),