Skip to content

Commit

Permalink
Merge pull request #124 from MXCzkEVM/big_upgrade
Browse files Browse the repository at this point in the history
Big upgrade
  • Loading branch information
reasje authored Dec 11, 2024
2 parents ac3f54b + 090ab6b commit f1c4cc6
Show file tree
Hide file tree
Showing 34 changed files with 829 additions and 1,146 deletions.
43 changes: 24 additions & 19 deletions lib/common/bottom_sheets/base_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ Future<T?> showBaseBottomSheet<T>({
required BuildContext context,
bool hasCloseButton = true,
bool? closeButtonReturnValue,

/// Has translation so just pass the key
String? bottomSheetTitle,
List<Widget>? widgets,
Widget? content,
bool isDismissible = true,
bool enableDrag = true,
Color? bottomSheetBackgroundColor,
}) {
assert(
((widgets != null && bottomSheetTitle != null) || content != null) &&
Expand All @@ -22,11 +24,13 @@ Future<T?> showBaseBottomSheet<T>({
context: context,
useRootNavigator: true,
isScrollControlled: true,
isDismissible: isDismissible,
enableDrag: enableDrag,
backgroundColor: Colors.transparent,
useSafeArea: true,
builder: (BuildContext context) => ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.95,
maxHeight: MediaQuery.of(context).size.height * 0.9,
),
child: Container(
padding: const EdgeInsets.only(
Expand All @@ -35,39 +39,40 @@ Future<T?> showBaseBottomSheet<T>({
right: Sizes.spaceNormal,
left: Sizes.spaceNormal),
decoration: BoxDecoration(
color: ColorsTheme.of(context).layerSheetBackground,
color: bottomSheetBackgroundColor ??
ColorsTheme.of(context).layerSheetBackground,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: content ??
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(
start: Sizes.spaceNormal,
end: Sizes.spaceNormal,
bottom: Sizes.space2XLarge),
child: MxcAppBarEvenly.title(
child: Container(
padding: const EdgeInsetsDirectional.only(
start: Sizes.spaceSmall,
end: Sizes.spaceSmall,
bottom: Sizes.space2XLarge),
child: content ??
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MxcAppBarEvenly.title(
titleText: translate(bottomSheetTitle!),
action: hasCloseButton
? Container(
alignment: Alignment.centerRight,
child: InkWell(
child: const Icon(Icons.close, size: 30),
child: const Icon(Icons.close, size: 24),
onTap: () => Navigator.of(context)
.pop(closeButtonReturnValue),
),
)
: null,
),
),
...widgets!
],
),
...widgets!
],
),
),
),
),
);
Expand Down
31 changes: 6 additions & 25 deletions lib/common/bottom_sheets/blueberry_rings_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,11 @@ Future<ScanResult?> showBlueberryRingsBottomSheet(
) {
return showBaseBottomSheet<ScanResult>(
context: context,
content: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.9,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
MxcAppBarEvenly.title(
titleText: FlutterI18n.translate(
context,
'nearby_blueberry_rings',
),
action: Container(
alignment: Alignment.centerRight,
child: InkWell(
child: const Icon(Icons.close),
onTap: () => Navigator.of(context).pop(null),
),
),
),
const BlueberryDeviceInfo(),
const SizedBox(height: 10),
],
),
),
bottomSheetTitle: 'nearby_blueberry_rings',
closeButtonReturnValue: null,
widgets: [
const BlueberryDeviceInfo(),
const SizedBox(height: 10),
],
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@ Future<bool?> showCancelDialog(BuildContext context,
required String symbol}) =>
showBaseBottomSheet<bool>(
context: context,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
MxcAppBarEvenly.title(
titleText: FlutterI18n.translate(context, 'cancel'),
action: Container(
alignment: Alignment.centerRight,
child: InkWell(
child: const Icon(Icons.close),
onTap: () => Navigator.of(context).pop(false),
),
),
),
SpeedUpCancelBottomSheetInfo(
estimatedFee: estimatedFee,
maxFee: maxFee,
symbol: symbol,
),
const SizedBox(height: 10),
],
),
bottomSheetTitle: 'cancel',
closeButtonReturnValue: false,
widgets: [
SpeedUpCancelBottomSheetInfo(
estimatedFee: estimatedFee,
maxFee: maxFee,
symbol: symbol,
),
const SizedBox(height: 10),
],
);
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@ Future<bool?> showSpeedUpDialog(BuildContext context,
required String symbol}) =>
showBaseBottomSheet<bool>(
context: context,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
MxcAppBarEvenly.title(
titleText: FlutterI18n.translate(context, 'speed_up'),
action: Container(
alignment: Alignment.centerRight,
child: InkWell(
child: const Icon(Icons.close),
onTap: () => Navigator.of(context).pop(false),
),
),
),
SpeedUpCancelBottomSheetInfo(
estimatedFee: estimatedFee,
maxFee: maxFee,
symbol: symbol,
),
const SizedBox(height: 10),
],
),
bottomSheetTitle: 'speed_up',
closeButtonReturnValue: false,
widgets: [
SpeedUpCancelBottomSheetInfo(
estimatedFee: estimatedFee,
maxFee: maxFee,
symbol: symbol,
),
const SizedBox(height: 10),
],
);
170 changes: 78 additions & 92 deletions lib/common/dialogs/add_network/add_network_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,99 +14,85 @@ Future<bool?> showAddNetworkDialog(

return showBaseBottomSheet<bool>(
context: context,
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(
start: Sizes.spaceNormal,
end: Sizes.spaceNormal,
bottom: Sizes.space2XLarge),
child: MxcAppBarEvenly.title(
titleText: network.label ?? network.web3RpcHttpUrl,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
translate(
'want_to_add_this_network',
),
style: FontTheme.of(context, listen: false)
.body2
.primary()
.copyWith(fontWeight: FontWeight.w600),
),
const SizedBox(
height: Sizes.spaceXSmall,
bottomSheetTitle: network.label ?? network.web3RpcHttpUrl,
hasCloseButton: false,
widgets: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
translate(
'want_to_add_this_network',
),
Text(
translate(
'network_adding_usage_notice',
),
style: FontTheme.of(context, listen: false).body2.primary(),
textAlign: TextAlign.center,
),
const SizedBox(
height: Sizes.spaceXSmall,
style: FontTheme.of(context, listen: false)
.body2
.primary()
.copyWith(fontWeight: FontWeight.w600),
),
const SizedBox(
height: Sizes.spaceXSmall,
),
Text(
translate(
'network_adding_usage_notice',
),
network.networkType == NetworkType.custom
? Text(
translate(
'custom_network_security_alert',
),
style: FontTheme.of(context, listen: false)
.body1()
.copyWith(
color: ColorsTheme.of(context, listen: false)
.textCritical),
textAlign: TextAlign.center,
)
: Container()
],
),
const SizedBox(
height: Sizes.spaceXSmall,
),
PropertyItem(
title: translate('network_name'),
value: network.label ?? network.web3RpcHttpUrl),
PropertyItem(
title: translate('rpc_url'), value: network.web3RpcHttpUrl),
PropertyItem(
title: translate('chain_id'), value: network.chainId.toString()),
PropertyItem(title: translate('symbol'), value: network.symbol),
network.explorerUrl != null
? PropertyItem(
title: translate('block_explorer_url'),
value: network.explorerUrl!)
: Container(),
const SizedBox(
height: Sizes.spaceXSmall,
),
MxcButton.secondary(
key: const ValueKey('cancelButton'),
title: translate('cancel'),
onTap: () => Navigator.of(context).pop(false),
size: MXCWalletButtonSize.xl,
edgeType: MXCWalletButtonEdgeType.hard,
),
const SizedBox(
height: Sizes.spaceNormal,
),
MxcButton.primary(
key: const ValueKey('approveButton'),
title: translate('approve'),
onTap: () {
final updatedNetwork = approveFunction(network);
Navigator.of(context).pop(updatedNetwork != null);
},
size: MXCWalletButtonSize.xl,
edgeType: MXCWalletButtonEdgeType.hard,
),
],
),
style: FontTheme.of(context, listen: false).body2.primary(),
textAlign: TextAlign.center,
),
const SizedBox(
height: Sizes.spaceXSmall,
),
network.networkType == NetworkType.custom
? Text(
translate(
'custom_network_security_alert',
),
style: FontTheme.of(context, listen: false).body1().copyWith(
color:
ColorsTheme.of(context, listen: false).textCritical),
textAlign: TextAlign.center,
)
: Container()
],
),
const SizedBox(
height: Sizes.spaceXSmall,
),
PropertyItem(
title: translate('network_name'),
value: network.label ?? network.web3RpcHttpUrl),
PropertyItem(title: translate('rpc_url'), value: network.web3RpcHttpUrl),
PropertyItem(
title: translate('chain_id'), value: network.chainId.toString()),
PropertyItem(title: translate('symbol'), value: network.symbol),
network.explorerUrl != null
? PropertyItem(
title: translate('block_explorer_url'),
value: network.explorerUrl!)
: Container(),
const SizedBox(
height: Sizes.spaceXSmall,
),
MxcButton.secondary(
key: const ValueKey('cancelButton'),
title: translate('cancel'),
onTap: () => Navigator.of(context).pop(false),
size: MXCWalletButtonSize.xl,
edgeType: MXCWalletButtonEdgeType.hard,
),
const SizedBox(
height: Sizes.spaceNormal,
),
MxcButton.primary(
key: const ValueKey('approveButton'),
title: translate('approve'),
onTap: () {
final updatedNetwork = approveFunction(network);
Navigator.of(context).pop(updatedNetwork != null);
},
size: MXCWalletButtonSize.xl,
edgeType: MXCWalletButtonEdgeType.hard,
),
],
);
}
Loading

0 comments on commit f1c4cc6

Please sign in to comment.