123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import 'package:flutter/material.dart';
- import 'package:flyinsonolite/infrastructure/scale.dart';
- import 'package:flyinsonolite/infrastructure/storage.dart';
- class FISLabelInputField extends StatelessWidget {
- /// 是否必填
- final bool isRequired;
- final String label;
- /// 组件
- final Widget widget;
- final double width;
- final double? height;
- final double? labelWidth;
- final EdgeInsetsGeometry? labelPadding;
- final EdgeInsetsGeometry? padding;
- final Color? labelColor;
- final double minHeight;
- const FISLabelInputField(this.isRequired, this.label, this.widget, this.width,
- {super.key,
- this.height,
- this.padding,
- this.labelWidth,
- this.labelColor,
- this.minHeight = 0,
- this.labelPadding});
- @override
- Widget build(BuildContext context) {
- return Container(
- margin: EdgeInsets.symmetric(horizontal: 5.s),
- padding: padding,
- width: width - 11.s, //多1是因为缩放会有误差
- child: Flex(
- direction: Axis.horizontal,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- padding: labelPadding ?? const EdgeInsets.all(0),
- width: labelWidth,
- alignment: Alignment.centerLeft,
- child: RichText(
- text: TextSpan(
- style: labelColor == null
- ? Storage
- .currentTheme.fisLabelInputFieldStyle.labelTextStyle
- .copyWith(
- fontSize: Storage
- .currentTheme
- .fisLabelInputFieldStyle
- .labelTextStyle
- .fontSize!
- .s)
- : Storage
- .currentTheme.fisLabelInputFieldStyle.labelTextStyle
- .copyWith(
- color: labelColor,
- fontSize: Storage
- .currentTheme
- .fisLabelInputFieldStyle
- .labelTextStyle
- .fontSize!
- .s),
- children: [
- TextSpan(
- text: label,
- ),
- if (isRequired) ...[
- TextSpan(
- text: ' * ',
- style: Storage
- .currentTheme.fisLabelInputFieldStyle.labelTextStyle
- .copyWith(
- color: Colors.red,
- fontSize: Storage
- .currentTheme
- .fisLabelInputFieldStyle
- .labelTextStyle
- .fontSize!
- .s),
- )
- ]
- ],
- ),
- textAlign: TextAlign.left,
- ),
- ),
- Expanded(
- child: Container(
- constraints: BoxConstraints(minHeight: minHeight),
- margin: EdgeInsets.fromLTRB(5.s, 0, 0, 0),
- height: height,
- child: widget,
- ))
- ],
- ),
- );
- }
- }
- class FISLabelInputFieldWithWrap extends StatelessWidget {
- /// 是否必填
- final bool isRequired;
- final String label;
- /// 组件
- final Widget widget;
- final double? width;
- final double? height;
- final double? labelWidth;
- final EdgeInsetsGeometry? labelPadding;
- final EdgeInsetsGeometry? padding;
- final Color? labelColor;
- final double minHeight;
- const FISLabelInputFieldWithWrap(
- this.isRequired, this.label, this.widget, this.width,
- {super.key,
- this.height,
- this.padding,
- this.labelWidth,
- this.labelColor,
- this.minHeight = 0,
- this.labelPadding});
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: padding,
- width: width,
- child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
- Container(
- padding: labelPadding ?? EdgeInsets.fromLTRB(0, 12.s, 0, 0),
- width: labelWidth,
- alignment: Alignment.centerLeft,
- child: RichText(
- text: TextSpan(
- style: labelColor == null
- ? Storage
- .currentTheme.fisLabelInputFieldStyle.labelTextStyle
- .copyWith(
- fontSize: Storage
- .currentTheme
- .fisLabelInputFieldStyle
- .labelTextStyle
- .fontSize!
- .s)
- : Storage
- .currentTheme.fisLabelInputFieldStyle.labelTextStyle
- .copyWith(
- color: labelColor,
- fontSize: Storage
- .currentTheme
- .fisLabelInputFieldStyle
- .labelTextStyle
- .fontSize!
- .s),
- children: [
- TextSpan(text: label),
- if (isRequired) ...[
- TextSpan(
- text: ' * ',
- style: Storage
- .currentTheme.fisLabelInputFieldStyle.labelTextStyle
- .copyWith(
- color: Colors.red,
- fontSize: Storage
- .currentTheme
- .fisLabelInputFieldStyle
- .labelTextStyle
- .fontSize!
- .s),
- )
- ]
- ],
- ),
- textAlign: TextAlign.left,
- ),
- ),
- Expanded(child: widget)
- ]));
- }
- }
|