|
@@ -0,0 +1,119 @@
|
|
|
+import 'package:fis_ui/index.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+
|
|
|
+/// 配置项布局组件
|
|
|
+class FConfigureLayoutStyle extends InheritedWidget implements FWidget {
|
|
|
+ const FConfigureLayoutStyle({
|
|
|
+ key,
|
|
|
+ required this.child,
|
|
|
+ required this.width,
|
|
|
+ }) : super(child: child);
|
|
|
+ final double width;
|
|
|
+ final FWidget child;
|
|
|
+
|
|
|
+ static double? of(BuildContext context) {
|
|
|
+ final style =
|
|
|
+ context.dependOnInheritedWidgetOfExactType<FConfigureLayoutStyle>();
|
|
|
+ return style?.width;
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ bool updateShouldNotify(covariant InheritedWidget oldWidget) {
|
|
|
+ return this.width != oldWidget.child;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class FConfigureLayout extends FStatelessWidget {
|
|
|
+ static const C_FONT_SIZE = 16.0;
|
|
|
+ static const C_PADDING_LEFT = 25.0;
|
|
|
+ static const C_PADDING_BOTTOM = 5.0;
|
|
|
+ static const C_FCONTAITNER_WIDTH = 125.0;
|
|
|
+ static const C_MARGIN_HORIZONTAL_SIZE = 15.0;
|
|
|
+ static const C_MARGIN_VERTICAL_SIZE = 20.0;
|
|
|
+
|
|
|
+ /// 标题
|
|
|
+ final String title;
|
|
|
+
|
|
|
+ /// 组件
|
|
|
+ final FWidget widget;
|
|
|
+
|
|
|
+ /// 比例
|
|
|
+ final double? proportion;
|
|
|
+
|
|
|
+ /// 是否必填
|
|
|
+ final bool? isRequired;
|
|
|
+
|
|
|
+ /// 是否显示标题
|
|
|
+ final bool? isShowTitle;
|
|
|
+
|
|
|
+ FConfigureLayout({
|
|
|
+ required this.title,
|
|
|
+ required this.widget,
|
|
|
+ this.proportion = 1,
|
|
|
+ this.isRequired = false,
|
|
|
+ this.isShowTitle = true,
|
|
|
+ });
|
|
|
+
|
|
|
+ @override
|
|
|
+ FWidget build(BuildContext context) {
|
|
|
+ final width = FConfigureLayoutStyle.of(context);
|
|
|
+ return FContainer(
|
|
|
+ width: proportion! * width!,
|
|
|
+ child: FRow(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ FSizedBox(
|
|
|
+ width: 20,
|
|
|
+ ),
|
|
|
+ isShowTitle!
|
|
|
+ ? _buildTitle()
|
|
|
+ : FSizedBox(
|
|
|
+ width: C_PADDING_LEFT,
|
|
|
+ ),
|
|
|
+ widget,
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 构建标题
|
|
|
+ FWidget _buildTitle() {
|
|
|
+ final labelStyle = TextStyle(fontSize: C_FONT_SIZE);
|
|
|
+
|
|
|
+ return FContainer(
|
|
|
+ margin: EdgeInsets.symmetric(
|
|
|
+ vertical: C_MARGIN_VERTICAL_SIZE,
|
|
|
+ horizontal: C_MARGIN_HORIZONTAL_SIZE,
|
|
|
+ ),
|
|
|
+ width: C_FCONTAITNER_WIDTH,
|
|
|
+ height: 40,
|
|
|
+ alignment: Alignment.centerLeft,
|
|
|
+ child: FRow(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ FExpanded(
|
|
|
+ child: FText.rich(
|
|
|
+ TextSpan(
|
|
|
+ children: [
|
|
|
+ TextSpan(
|
|
|
+ text: title,
|
|
|
+ style: labelStyle,
|
|
|
+ ),
|
|
|
+ if (isRequired!) ...[
|
|
|
+ TextSpan(
|
|
|
+ text: ' *',
|
|
|
+ style: labelStyle.copyWith(color: Colors.red),
|
|
|
+ )
|
|
|
+ ] else ...[
|
|
|
+ TextSpan(text: '')
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|