重整多余的UI组件和未定功能的逻辑链路的修正
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
class NoDeviceCrosshairHint extends StatefulWidget {
|
||||
const NoDeviceCrosshairHint({super.key, required this.hasDevice});
|
||||
@@ -8,6 +9,8 @@ class NoDeviceCrosshairHint extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NoDeviceCrosshairHintState extends State<NoDeviceCrosshairHint> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
bool _dismissed = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,9 +30,9 @@ class _NoDeviceCrosshairHintState extends State<NoDeviceCrosshairHint> {
|
||||
color: Color(0xFF9B6500),
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Text(
|
||||
'未选择设备,请使用「准星打点」:移动地图,将准星对准目标位置后点「+」。',
|
||||
_l10n.translate('region_editor.no_device_crosshair_hint'),
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: Color(0xFF9B6500),
|
||||
@@ -40,8 +43,8 @@ class _NoDeviceCrosshairHintState extends State<NoDeviceCrosshairHint> {
|
||||
InkWell(
|
||||
key: const ValueKey('dismiss_crosshair_hint'),
|
||||
onTap: () => setState(() => _dismissed = true),
|
||||
child: const Tooltip(
|
||||
message: '关闭提示',
|
||||
child: Tooltip(
|
||||
message: _l10n.translate('region_editor.dismiss_tip'),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: Icon(
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/regions/presentation/region_error_text.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../domain/entities/region_draft.dart';
|
||||
import '../cubit/region_editor_cubit.dart';
|
||||
@@ -29,6 +31,8 @@ class RegionFormDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
final _form = GlobalKey<FormState>();
|
||||
late final TextEditingController _name;
|
||||
late final TextEditingController _code;
|
||||
@@ -61,7 +65,10 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
final state = widget.cubit.state;
|
||||
if (state.isSaving || !_form.currentState!.validate()) return;
|
||||
if (!widget.isScopeCurrent()) {
|
||||
setState(() => _scopeError = '场站或账号已切换,请重新进入编辑器后保存');
|
||||
setState(
|
||||
() =>
|
||||
_scopeError = _l10n.translate('region_editor.scope_changed_reopen'),
|
||||
);
|
||||
return;
|
||||
}
|
||||
setState(() => _scopeError = null);
|
||||
@@ -86,7 +93,10 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
Map<int, String> _options(RegionEditorState state) {
|
||||
final result = {for (final route in state.routes) route.id: route.name};
|
||||
for (final id in [..._bound, ?_defaultRoute]) {
|
||||
result.putIfAbsent(id, () => '路线 #$id');
|
||||
result.putIfAbsent(
|
||||
id,
|
||||
() => _l10n.translate('autonomous_work.route_number', {'id': id}),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -98,7 +108,7 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
context: context,
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (_, update) => AlertDialog(
|
||||
title: const Text('绑定路线'),
|
||||
title: Text(_l10n.translate('region_editor.bind_routes')),
|
||||
content: SizedBox(
|
||||
width: 420,
|
||||
height: (MediaQuery.sizeOf(dialogContext).height * 0.5).clamp(
|
||||
@@ -106,7 +116,11 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
300.0,
|
||||
),
|
||||
child: options.isEmpty
|
||||
? const Center(child: Text('当前场站暂无可绑定路线'))
|
||||
? Center(
|
||||
child: Text(
|
||||
_l10n.translate('region_editor.no_routes_to_bind'),
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
children: [
|
||||
for (final route in options.entries)
|
||||
@@ -129,11 +143,11 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('取消'),
|
||||
child: Text(_l10n.translate('common.cancel')),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(selected),
|
||||
child: const Text('确定'),
|
||||
child: Text(_l10n.translate('common.ok')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -181,7 +195,9 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.draft.id == null ? '新建分区' : '编辑分区',
|
||||
state.draft.id == null
|
||||
? _l10n.translate('region_editor.new_region')
|
||||
: _l10n.translate('region_editor.edit_region'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w800,
|
||||
@@ -210,17 +226,25 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
TextFormField(
|
||||
key: const ValueKey('region_name'),
|
||||
controller: _name,
|
||||
decoration: _decoration('分区名称 *'),
|
||||
decoration: _decoration(
|
||||
_l10n.translate(
|
||||
'region_editor.region_name_field',
|
||||
),
|
||||
),
|
||||
validator: (value) =>
|
||||
value == null || value.trim().isEmpty
|
||||
? '请填写分区名称'
|
||||
? _l10n.translate(
|
||||
'region_editor.region_name_required',
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
key: const ValueKey('region_code'),
|
||||
controller: _code,
|
||||
decoration: _decoration('分区编码'),
|
||||
decoration: _decoration(
|
||||
_l10n.translate('region_editor.region_code'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (loading) ...[
|
||||
@@ -233,7 +257,14 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.routesError ?? '路线加载失败',
|
||||
state.routesError == null
|
||||
? _l10n.translate(
|
||||
'region_editor.route_load_failed',
|
||||
)
|
||||
: regionErrorText(
|
||||
state.routesError!,
|
||||
_l10n,
|
||||
),
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 12,
|
||||
@@ -242,12 +273,18 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: widget.cubit.loadRoutes,
|
||||
child: const Text('重新加载路线'),
|
||||
child: Text(
|
||||
_l10n.translate(
|
||||
'region_editor.reload_routes',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
InputDecorator(
|
||||
decoration: _decoration('默认路线'),
|
||||
decoration: _decoration(
|
||||
_l10n.translate('region_editor.default_route'),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -261,7 +298,13 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
isDense: true,
|
||||
menuMaxHeight: 260,
|
||||
hint: Text(
|
||||
loading ? '路线加载中' : '请选择默认路线(可选)',
|
||||
loading
|
||||
? _l10n.translate(
|
||||
'region_editor.routes_loading',
|
||||
)
|
||||
: _l10n.translate(
|
||||
'region_editor.pick_default_route',
|
||||
),
|
||||
style: const TextStyle(fontSize: 13),
|
||||
),
|
||||
items: [
|
||||
@@ -308,18 +351,22 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
? null
|
||||
: () => _pickBoundRoutes(options),
|
||||
child: InputDecorator(
|
||||
decoration: _decoration('绑定路线'),
|
||||
decoration: _decoration(
|
||||
_l10n.translate('region_editor.bind_routes'),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
if (_bound.isEmpty)
|
||||
const Padding(
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 4,
|
||||
),
|
||||
child: Text(
|
||||
'请选择绑定路线(可多选)',
|
||||
_l10n.translate(
|
||||
'region_editor.pick_linked_routes',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey,
|
||||
@@ -329,7 +376,11 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
for (final id in _bound)
|
||||
InputChip(
|
||||
label: Text(
|
||||
options[id] ?? '路线 #$id',
|
||||
options[id] ??
|
||||
_l10n.translate(
|
||||
'autonomous_work.route_number',
|
||||
{'id': id},
|
||||
),
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
onDeleted: () =>
|
||||
@@ -345,11 +396,15 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
controller: _remark,
|
||||
minLines: 2,
|
||||
maxLines: 3,
|
||||
decoration: _decoration('备注'),
|
||||
decoration: _decoration(
|
||||
_l10n.translate('work_v2.record.remark'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'当前区域范围点数:${state.draft.scope.length}/4',
|
||||
_l10n.translate('region_editor.boundary_count', {
|
||||
'count': state.draft.scope.length,
|
||||
}),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: state.draft.scopeError == null
|
||||
@@ -359,7 +414,7 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
),
|
||||
if (state.draft.scopeError != null)
|
||||
Text(
|
||||
state.draft.scopeError!,
|
||||
regionErrorText(state.draft.scopeError!, _l10n),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.red,
|
||||
@@ -369,7 +424,8 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
_scopeError ?? state.error!,
|
||||
_scopeError ??
|
||||
regionErrorText(state.error!, _l10n),
|
||||
key: const ValueKey('region_save_error'),
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
@@ -392,7 +448,7 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
onPressed: state.isSaving
|
||||
? null
|
||||
: () => Navigator.of(context).pop(false),
|
||||
child: const Text('取消'),
|
||||
child: Text(_l10n.translate('common.cancel')),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
FilledButton(
|
||||
@@ -412,7 +468,9 @@ class _RegionFormDialogState extends State<RegionFormDialog> {
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: const Text('确认保存'),
|
||||
: Text(
|
||||
_l10n.translate('region_editor.save_confirm'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/regions/presentation/region_error_text.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart';
|
||||
import '../../../../components/capsule_toast.dart';
|
||||
import '../../domain/entities/region_draft.dart';
|
||||
import '../cubit/region_list_cubit.dart';
|
||||
|
||||
typedef RegionListPageHeaderBuilder =
|
||||
Widget Function(
|
||||
BuildContext context,
|
||||
RegionListState state,
|
||||
VoidCallback? onCreate,
|
||||
VoidCallback? onRefresh,
|
||||
);
|
||||
|
||||
/// 地图分区入口、竖屏区域管理共享的真实列表与操作界面。
|
||||
class RegionListPanel extends StatelessWidget {
|
||||
const RegionListPanel({
|
||||
@@ -16,6 +27,7 @@ class RegionListPanel extends StatelessWidget {
|
||||
this.onSelect,
|
||||
this.onDeleted,
|
||||
this.onClose,
|
||||
this.pageHeaderBuilder,
|
||||
});
|
||||
final RegionListCubit cubit;
|
||||
final VoidCallback onCreate;
|
||||
@@ -25,39 +37,50 @@ class RegionListPanel extends StatelessWidget {
|
||||
final VoidCallback onRefresh;
|
||||
final VoidCallback? onClose;
|
||||
final Object? Function() currentScope;
|
||||
final RegionListPageHeaderBuilder? pageHeaderBuilder;
|
||||
|
||||
Future<void> _delete(BuildContext context, RegionDraft region) async {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final scope = currentScope();
|
||||
if (scope != cubit.scopeKey) return;
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('删除分区'),
|
||||
title: Text(l10n.translate('region_editor.delete_region')),
|
||||
content: Text(
|
||||
'确定删除「${region.name.isEmpty ? '分区 #${region.id}' : region.name}」?删除后无法恢复。',
|
||||
l10n.translate('region_editor.delete_region_message', {
|
||||
'region': region.name.isEmpty
|
||||
? l10n.translate('region_editor.region_number', {
|
||||
'id': region.id,
|
||||
})
|
||||
: region.name,
|
||||
}),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
child: const Text('取消'),
|
||||
child: Text(l10n.translate('common.cancel')),
|
||||
),
|
||||
FilledButton(
|
||||
key: const ValueKey('region_delete_confirm'),
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
child: const Text('删除'),
|
||||
child: Text(l10n.translate('route_planning.delete')),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!context.mounted || confirmed != true) return;
|
||||
if (currentScope() != scope || cubit.scopeKey != scope) {
|
||||
CapsuleToast.show('场站或账号已切换,请重新选择分区', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
l10n.translate('region_editor.scope_changed_select_region'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final deleted = await cubit.deleteRegion(region);
|
||||
if (!context.mounted || !deleted) return;
|
||||
onDeleted?.call(region);
|
||||
CapsuleToast.show('分区已删除');
|
||||
CapsuleToast.show(l10n.translate('region_editor.region_deleted'));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -66,56 +89,66 @@ class RegionListPanel extends StatelessWidget {
|
||||
) => BlocBuilder<RegionListCubit, RegionListState>(
|
||||
bloc: cubit,
|
||||
builder: (context, state) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final busy = state.deletingId != null;
|
||||
final scoped = state.siteId != null && currentScope() == cubit.scopeKey;
|
||||
final pageHeader = pageHeaderBuilder;
|
||||
final pageLayout = pageHeader != null;
|
||||
final create = scoped && !busy ? onCreate : null;
|
||||
final refresh = busy || state.status == RegionListStatus.loading
|
||||
? null
|
||||
: onRefresh;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 6, 4, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.status == RegionListStatus.ready
|
||||
? '分区列表(${state.regions.length})'
|
||||
: '分区列表',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Color(0xFF1A2B4A),
|
||||
if (pageHeader != null)
|
||||
pageHeader(context, state, create, refresh)
|
||||
else
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 6, 4, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
state.status == RegionListStatus.ready
|
||||
? l10n.translate('region_editor.regions_count', {
|
||||
'count': state.regions.length,
|
||||
})
|
||||
: l10n.translate('region_editor.regions'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Color(0xFF1A2B4A),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton.icon(
|
||||
key: const ValueKey('region_list_create'),
|
||||
onPressed: !scoped || busy ? null : onCreate,
|
||||
icon: const Icon(Icons.add_rounded, size: 17),
|
||||
label: const Text('新增'),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: '刷新分区',
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: busy || state.status == RegionListStatus.loading
|
||||
? null
|
||||
: onRefresh,
|
||||
icon: const Icon(Icons.refresh_rounded, size: 19),
|
||||
),
|
||||
if (onClose != null)
|
||||
IconButton(
|
||||
tooltip: '关闭列表',
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: busy ? null : onClose,
|
||||
icon: const Icon(Icons.close_rounded, size: 19),
|
||||
TextButton.icon(
|
||||
key: const ValueKey('region_list_create'),
|
||||
onPressed: create,
|
||||
icon: const Icon(Icons.add_rounded, size: 17),
|
||||
label: Text(l10n.translate('region_editor.add_region')),
|
||||
),
|
||||
],
|
||||
IconButton(
|
||||
tooltip: l10n.translate('region_editor.refresh_regions'),
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: refresh,
|
||||
icon: const Icon(Icons.refresh_rounded, size: 19),
|
||||
),
|
||||
if (onClose != null)
|
||||
IconButton(
|
||||
tooltip: l10n.translate('region_editor.close_regions'),
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: busy ? null : onClose,
|
||||
icon: const Icon(Icons.close_rounded, size: 19),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.operationError != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Text(
|
||||
state.operationError!,
|
||||
regionErrorText(state.operationError!, l10n),
|
||||
key: const ValueKey('region_delete_error'),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.red),
|
||||
),
|
||||
@@ -125,9 +158,13 @@ class RegionListPanel extends StatelessWidget {
|
||||
RegionListStatus.loading || RegionListStatus.idle => const Center(
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
RegionListStatus.noUser => const Center(child: Text('请先登录')),
|
||||
RegionListStatus.noSite => const Center(
|
||||
child: Text('请选择场站后查看分区'),
|
||||
RegionListStatus.noUser => Center(
|
||||
child: Text(l10n.translate('region_editor.sign_in_first')),
|
||||
),
|
||||
RegionListStatus.noSite => Center(
|
||||
child: Text(
|
||||
l10n.translate('region_editor.select_site_for_regions'),
|
||||
),
|
||||
),
|
||||
RegionListStatus.failure => Center(
|
||||
child: Padding(
|
||||
@@ -136,13 +173,19 @@ class RegionListPanel extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
state.error ?? '分区加载失败',
|
||||
state.error == null
|
||||
? l10n.translate(
|
||||
'region_editor.regions_load_failed',
|
||||
)
|
||||
: regionErrorText(state.error!, l10n),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextButton(
|
||||
onPressed: onRefresh,
|
||||
child: const Text('重新加载分区'),
|
||||
child: Text(
|
||||
l10n.translate('region_editor.reload_regions'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -150,21 +193,33 @@ class RegionListPanel extends StatelessWidget {
|
||||
),
|
||||
RegionListStatus.ready =>
|
||||
state.regions.isEmpty
|
||||
? const Center(child: Text('当前场站暂无分区,可点击「新增」'))
|
||||
? pageLayout
|
||||
? _buildPageEmpty(context)
|
||||
: Center(
|
||||
child: Text(
|
||||
l10n.translate('region_editor.regions_empty'),
|
||||
),
|
||||
)
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.fromLTRB(10, 4, 10, 16),
|
||||
padding: pageLayout
|
||||
? const EdgeInsets.only(bottom: 12)
|
||||
: const EdgeInsets.fromLTRB(10, 4, 10, 16),
|
||||
itemCount: state.regions.length,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 8),
|
||||
separatorBuilder: (_, _) =>
|
||||
SizedBox(height: pageLayout ? 10 : 8),
|
||||
itemBuilder: (context, index) {
|
||||
final region = state.regions[index];
|
||||
final selected = state.selectedId == region.id;
|
||||
final radius = BorderRadius.circular(
|
||||
pageLayout ? 16 : 12,
|
||||
);
|
||||
return Material(
|
||||
key: ValueKey('region_row_${region.id}'),
|
||||
color: selected
|
||||
? const Color(0xFFEAF3FE)
|
||||
: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: radius,
|
||||
side: BorderSide(
|
||||
color: selected
|
||||
? const Color(0xFF1C96F6)
|
||||
@@ -172,7 +227,7 @@ class RegionListPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: radius,
|
||||
onTap: !scoped || busy
|
||||
? null
|
||||
: () {
|
||||
@@ -180,69 +235,128 @@ class RegionListPanel extends StatelessWidget {
|
||||
onSelect?.call(region);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
12,
|
||||
10,
|
||||
8,
|
||||
4,
|
||||
),
|
||||
padding: pageLayout
|
||||
? const EdgeInsets.fromLTRB(14, 14, 14, 8)
|
||||
: const EdgeInsets.fromLTRB(12, 10, 8, 4),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
if (pageLayout) ...[
|
||||
Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: kWtSoftBlue,
|
||||
borderRadius:
|
||||
BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.layers_outlined,
|
||||
size: 18,
|
||||
color: kWtBlue,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
Expanded(
|
||||
child: Text(
|
||||
region.name.isEmpty
|
||||
? '分区 #${region.id}'
|
||||
? l10n.translate(
|
||||
'region_editor.region_number',
|
||||
{'id': region.id},
|
||||
)
|
||||
: region.name,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 14,
|
||||
fontSize: pageLayout ? 15 : 14,
|
||||
color: pageLayout
|
||||
? kWtNavy
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
region.enabled ? '启用' : '停用',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: region.enabled
|
||||
if (pageLayout)
|
||||
WorkChip(
|
||||
text: region.enabled
|
||||
? l10n.translate(
|
||||
'region_editor.enabled',
|
||||
)
|
||||
: l10n.translate(
|
||||
'region_editor.disabled',
|
||||
),
|
||||
background: region.enabled
|
||||
? kWtGreenBg
|
||||
: kWtLocked,
|
||||
foreground: region.enabled
|
||||
? const Color(0xFF1D9E57)
|
||||
: Colors.grey,
|
||||
: kWtGray2,
|
||||
)
|
||||
else
|
||||
Text(
|
||||
region.enabled
|
||||
? l10n.translate(
|
||||
'region_editor.enabled',
|
||||
)
|
||||
: l10n.translate(
|
||||
'region_editor.disabled',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: region.enabled
|
||||
? const Color(0xFF1D9E57)
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (region.code.isNotEmpty) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'编码:${region.code}',
|
||||
style: const TextStyle(
|
||||
l10n.translate(
|
||||
'region_editor.code_value',
|
||||
{'code': region.code},
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
color: pageLayout
|
||||
? kWtGray
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'${region.scope.length} 个范围点 · ${region.boundRouteIds.length} 条绑定路线',
|
||||
style: const TextStyle(
|
||||
l10n.translate(
|
||||
'region_editor.region_summary',
|
||||
{
|
||||
'points': region.scope.length,
|
||||
'routes': region.boundRouteIds.length,
|
||||
},
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: Colors.grey,
|
||||
color: pageLayout
|
||||
? kWtGray
|
||||
: Colors.grey,
|
||||
),
|
||||
),
|
||||
if (region.scopeError != null)
|
||||
const Text(
|
||||
'范围需重新打点',
|
||||
Text(
|
||||
l10n.translate(
|
||||
'region_editor.redraw_required',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Colors.orange,
|
||||
),
|
||||
),
|
||||
if (pageLayout) const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
@@ -253,8 +367,21 @@ class RegionListPanel extends StatelessWidget {
|
||||
onPressed: !scoped || busy
|
||||
? null
|
||||
: () => onEdit(region),
|
||||
child: const Text('修改'),
|
||||
style: pageLayout
|
||||
? _pageActionStyle(
|
||||
context,
|
||||
kWtBlue,
|
||||
kWtSoftBlue,
|
||||
)
|
||||
: null,
|
||||
child: Text(
|
||||
l10n.translate(
|
||||
'region_editor.edit',
|
||||
),
|
||||
),
|
||||
),
|
||||
if (pageLayout)
|
||||
const SizedBox(width: 8),
|
||||
TextButton(
|
||||
key: ValueKey(
|
||||
'region_delete_${region.id}',
|
||||
@@ -262,6 +389,13 @@ class RegionListPanel extends StatelessWidget {
|
||||
onPressed: !scoped || busy
|
||||
? null
|
||||
: () => _delete(context, region),
|
||||
style: pageLayout
|
||||
? _pageActionStyle(
|
||||
context,
|
||||
kWtDanger,
|
||||
kWtSegBg,
|
||||
)
|
||||
: null,
|
||||
child: state.deletingId == region.id
|
||||
? const SizedBox(
|
||||
width: 14,
|
||||
@@ -271,11 +405,17 @@ class RegionListPanel extends StatelessWidget {
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
color: Color(0xFFD54941),
|
||||
: Text(
|
||||
l10n.translate(
|
||||
'route_planning.delete',
|
||||
),
|
||||
style: pageLayout
|
||||
? null
|
||||
: const TextStyle(
|
||||
color: Color(
|
||||
0xFFD54941,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -293,4 +433,42 @@ class RegionListPanel extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
ButtonStyle _pageActionStyle(
|
||||
BuildContext context,
|
||||
Color foreground,
|
||||
Color background,
|
||||
) => TextButton.styleFrom(
|
||||
foregroundColor: foreground,
|
||||
backgroundColor: background,
|
||||
minimumSize: const Size(54, 32),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
textStyle: Theme.of(
|
||||
context,
|
||||
).textTheme.labelLarge?.copyWith(fontSize: 12, fontWeight: FontWeight.w700),
|
||||
);
|
||||
|
||||
Widget _buildPageEmpty(BuildContext context) => Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.layers_outlined, size: 26, color: kWtMuted),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('work_v2.area.empty_site'),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 12.5, color: kWtGray),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user