Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-4397: Country Dropdown - Fixes #1388

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ class EntityActionsMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ArDriveDropdown(
width: item is DriveDataItem ? 240 : 160,
height: isMobile(context) ? 44 : 60,
anchor: alignment,
items: _getItems(item, context, withInfo),
Expand Down
2 changes: 0 additions & 2 deletions lib/pages/drive_detail/drive_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ class _DriveDetailPageState extends State<DriveDetailPage> {
tooltip:
appLocalizationsOf(context).showMenu,
child: ArDriveDropdown(
width: 260,
anchor: const Aligned(
follower: Alignment.topRight,
target: Alignment.bottomRight,
Expand Down Expand Up @@ -774,7 +773,6 @@ class MobileFolderNavigation extends StatelessWidget {
state.currentDrive.ownerAddress);

return ArDriveDropdown(
width: 240,
anchor: const Aligned(
follower: Alignment.topRight,
target: Alignment.bottomRight,
Expand Down
36 changes: 27 additions & 9 deletions lib/turbo/topup/views/topup_payment_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,6 @@ class TurboPaymentFormViewState extends State<TurboPaymentFormView> {
nameOnCardTextField(),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
countryTextField(theme),
],
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.only(bottom: 4, right: 16),
child: Align(
Expand Down Expand Up @@ -492,6 +485,13 @@ class TurboPaymentFormViewState extends State<TurboPaymentFormView> {
),
),
const SizedBox(height: 16),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
countryTextField(theme),
],
),
const SizedBox(height: 16),
Row(children: [promoCodeLabel()]),
ScreenTypeLayout.builder(
mobile: (context) => Row(children: [
Expand Down Expand Up @@ -1017,11 +1017,29 @@ class InputDropdownMenu<T extends InputDropdownItem> extends StatefulWidget {
class _InputDropdownMenuState<T extends InputDropdownItem>
extends State<InputDropdownMenu<T>> {
T? _selectedItem;
final GlobalKey _childKey = GlobalKey();
double? _childWidth;
double get childWidth => _childWidth ?? 200;

void _refreshChildWidth() {
final currentContext = _childKey.currentContext;
if (currentContext == null) {
return;
}

final RenderBox renderBox =
_childKey.currentContext!.findRenderObject() as RenderBox;

setState(() {
_childWidth = renderBox.size.width;
});
}
Comment on lines +1024 to +1036
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked it


@override
initState() {
super.initState();
_selectedItem = widget.selectedItem;
WidgetsBinding.instance.addPostFrameCallback((_) => _refreshChildWidth());
}

@override
Expand All @@ -1031,13 +1049,12 @@ class _InputDropdownMenuState<T extends InputDropdownItem>
showScrollbars: true,
onClick: widget.onClick,
maxHeight: 275,
width: 200,
anchor: widget.anchor,
items: widget.items
.map(
(e) => ArDriveDropdownItem(
content: Container(
width: 200,
width: _childWidth,
alignment: Alignment.center,
height: 44,
color: widget.backgroundColor ??
Expand Down Expand Up @@ -1071,6 +1088,7 @@ class _InputDropdownMenuState<T extends InputDropdownItem>
)
.toList(),
child: Column(
key: _childKey,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.10.0"
resolved-ref: "72cd21de7cbd52067924cefac579cdb9d7ef39b7"
ref: "v1.11.0"
resolved-ref: "357ce9113b6c90eb00d3ae4528112a8228d9d11f"
url: "https://github.com/ar-io/ardrive_ui.git"
source: git
version: "1.10.0"
version: "1.11.0"
args:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
ardrive_ui:
git:
url: https://github.com/ar-io/ardrive_ui.git
ref: v1.10.0
ref: v1.11.0
artemis: ^7.0.0-beta.13
arweave:
git:
Expand Down
Loading