56 lines
1.6 KiB
Dart
56 lines
1.6 KiB
Dart
import 'package:common_utils/common_utils.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:forui/forui.dart';
|
|
|
|
import 'package:pj_supermarket_cloud/common/index.dart';
|
|
|
|
/// 构建登录页租户单选菜单;控件值统一使用租户 `code`,持久化的数值 `id` 由控制器处理。
|
|
Widget appTenantDialog(
|
|
BuildContext context,
|
|
FRadioSelectGroupController<String> controller, {
|
|
required List<ServiceTenant> list,
|
|
}) {
|
|
final theme = FTheme.of(context);
|
|
final selectList = list
|
|
.where((tenant) => ObjectUtil.isNotEmpty(tenant.code))
|
|
.toList(growable: false);
|
|
return FSelectMenuTile<String>(
|
|
title: Text(
|
|
"单位",
|
|
style: theme.typography.base,
|
|
),
|
|
groupController: controller,
|
|
validator: (value) => value == null ? '请选择' : null,
|
|
autoHide: true,
|
|
prefixIcon: FIcon(
|
|
FAssets.icons.building2,
|
|
size: theme.typography.xl.fontSize,
|
|
),
|
|
menu: selectList.map((v) {
|
|
return FSelectTile(
|
|
title: Text(
|
|
v.name ?? v.code!,
|
|
style: theme.typography.base,
|
|
),
|
|
value: v.code!,
|
|
);
|
|
}).toList(),
|
|
details: ListenableBuilder(
|
|
listenable: controller,
|
|
builder: (context, _) {
|
|
final v = controller.value.firstOrNull;
|
|
if (v == null) return const SizedBox();
|
|
final target =
|
|
selectList.where((tenant) => tenant.code == v).firstOrNull;
|
|
if (target == null) return const SizedBox();
|
|
return Text(
|
|
target.name ?? target.code!,
|
|
style: theme.typography.base.copyWith(
|
|
color: theme.colorScheme.primary,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|