fix(zipcode): cap table width in dialog to half screen via optional maxWidthCap; pass 0.5 fraction when used in Company/Warehouse dialogs
- ZipcodeTable: add maxWidthCap and use min(viewport, cap) to compute width - ZipcodeSearchScreen: allow tableMaxWidthFraction and forward to table - Apply 0.5 in CompanyForm and WarehouseLocationForm dialogs flutter analyze: 0 errors, warnings unaffected
This commit is contained in:
@@ -109,6 +109,7 @@ _controller = CompanyFormController(
|
|||||||
GetIt.instance<ZipcodeUseCase>(),
|
GetIt.instance<ZipcodeUseCase>(),
|
||||||
),
|
),
|
||||||
child: ZipcodeSearchScreen(
|
child: ZipcodeSearchScreen(
|
||||||
|
tableMaxWidthFraction: 0.5,
|
||||||
onSelect: (zipcode) {
|
onSelect: (zipcode) {
|
||||||
Navigator.of(dialogContext).pop(zipcode);
|
Navigator.of(dialogContext).pop(zipcode);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class _WarehouseLocationFormScreenState
|
|||||||
GetIt.instance<ZipcodeUseCase>(),
|
GetIt.instance<ZipcodeUseCase>(),
|
||||||
),
|
),
|
||||||
child: ZipcodeSearchScreen(
|
child: ZipcodeSearchScreen(
|
||||||
|
tableMaxWidthFraction: 0.5,
|
||||||
onSelect: (zipcode) {
|
onSelect: (zipcode) {
|
||||||
Navigator.of(dialogContext).pop(zipcode);
|
Navigator.of(dialogContext).pop(zipcode);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'dart:math' as math;
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||||
import 'package:superport/data/models/zipcode_dto.dart';
|
import 'package:superport/data/models/zipcode_dto.dart';
|
||||||
@@ -9,6 +10,8 @@ class ZipcodeTable extends StatelessWidget {
|
|||||||
final int totalPages;
|
final int totalPages;
|
||||||
final Function(int) onPageChanged;
|
final Function(int) onPageChanged;
|
||||||
final Function(ZipcodeDto) onSelect;
|
final Function(ZipcodeDto) onSelect;
|
||||||
|
// Optional: cap the effective viewport width used by the table
|
||||||
|
final double? maxWidthCap;
|
||||||
|
|
||||||
const ZipcodeTable({
|
const ZipcodeTable({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -17,6 +20,7 @@ class ZipcodeTable extends StatelessWidget {
|
|||||||
required this.totalPages,
|
required this.totalPages,
|
||||||
required this.onPageChanged,
|
required this.onPageChanged,
|
||||||
required this.onSelect,
|
required this.onSelect,
|
||||||
|
this.maxWidthCap,
|
||||||
});
|
});
|
||||||
|
|
||||||
void _copyToClipboard(BuildContext context, String text, String label) {
|
void _copyToClipboard(BuildContext context, String text, String label) {
|
||||||
@@ -43,7 +47,13 @@ class ZipcodeTable extends StatelessWidget {
|
|||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
// 고정폭 + 마지막 filler
|
// 고정폭 + 마지막 filler
|
||||||
const double minW = 160 + 180 + 180 + 320 + 140 + 24;
|
const double minW = 160 + 180 + 180 + 320 + 140 + 24;
|
||||||
final double tableW = constraints.maxWidth >= minW ? constraints.maxWidth : minW;
|
final double viewportW = constraints.maxWidth.isFinite
|
||||||
|
? constraints.maxWidth
|
||||||
|
: MediaQuery.sizeOf(context).width;
|
||||||
|
final double cappedW = maxWidthCap != null
|
||||||
|
? math.min(viewportW, maxWidthCap!)
|
||||||
|
: viewportW;
|
||||||
|
final double tableW = cappedW >= minW ? cappedW : minW;
|
||||||
const double etcW = 320.0;
|
const double etcW = 320.0;
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import 'package:superport/screens/zipcode/components/zipcode_table.dart';
|
|||||||
|
|
||||||
class ZipcodeSearchScreen extends StatefulWidget {
|
class ZipcodeSearchScreen extends StatefulWidget {
|
||||||
final Function(ZipcodeDto)? onSelect;
|
final Function(ZipcodeDto)? onSelect;
|
||||||
const ZipcodeSearchScreen({super.key, this.onSelect});
|
// When used in a dialog/popup, you can cap the table width
|
||||||
|
// by setting this fraction (0.0–1.0) of the screen width.
|
||||||
|
final double? tableMaxWidthFraction;
|
||||||
|
const ZipcodeSearchScreen({super.key, this.onSelect, this.tableMaxWidthFraction});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ZipcodeSearchScreen> createState() => _ZipcodeSearchScreenState();
|
State<ZipcodeSearchScreen> createState() => _ZipcodeSearchScreenState();
|
||||||
@@ -236,6 +239,9 @@ class _ZipcodeSearchScreenState extends State<ZipcodeSearchScreen> {
|
|||||||
_showSuccessToast('우편번호 ${zipcode.zipcode}를 선택했습니다');
|
_showSuccessToast('우편번호 ${zipcode.zipcode}를 선택했습니다');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
maxWidthCap: widget.tableMaxWidthFraction != null
|
||||||
|
? MediaQuery.sizeOf(context).width * widget.tableMaxWidthFraction!
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user