mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* feat: use common modal widget for repeated picker logic and display * refactor: rename widget * refactor: clear wrapper logic from picker widget and move title to hasTitle * Minor code readability enhancements [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
62 lines
1.8 KiB
Dart
62 lines
1.8 KiB
Dart
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
|
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
|
|
|
|
class PickerWrapperWidget extends StatelessWidget {
|
|
PickerWrapperWidget({required this.children, this.hasTitle = false});
|
|
|
|
final List<Widget> children;
|
|
final bool hasTitle;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final double padding = 24;
|
|
|
|
final mq = MediaQuery.of(context);
|
|
final bottom = mq.viewInsets.bottom;
|
|
final height = mq.size.height - bottom;
|
|
final screenCenter = height / 2;
|
|
|
|
double closeButtonBottom = 60;
|
|
double containerHeight = height * 0.65;
|
|
if (bottom > 0) {
|
|
// increase a bit or it gets too squished in the top
|
|
containerHeight = height * 0.75;
|
|
|
|
final containerCenter = containerHeight / 2;
|
|
final containerBottom = screenCenter - containerCenter;
|
|
|
|
// position the close button right below the search container
|
|
closeButtonBottom = closeButtonBottom -
|
|
containerBottom + (!hasTitle ? padding : padding / 1.5);
|
|
}
|
|
|
|
return AlertBackground(
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: <Widget>[
|
|
Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: children,
|
|
),
|
|
SizedBox(height: ResponsiveLayoutUtil.kPopupSpaceHeight),
|
|
AlertCloseButton(bottom: closeButtonBottom),
|
|
],
|
|
),
|
|
),
|
|
// gives the extra spacing using MediaQuery.viewInsets.bottom
|
|
// to simulate a keyboard area
|
|
SizedBox(
|
|
height: bottom,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|