feat:更新主题色适配
This commit is contained in:
@@ -4,50 +4,54 @@ import 'package:flutter/material.dart';
|
||||
InputDecoration buildInputDecoration({
|
||||
required BuildContext context,
|
||||
required String hintText,
|
||||
Widget? prefixIcon,
|
||||
required IconData prefixIcon,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return InputDecoration(
|
||||
hintText: hintText,
|
||||
hintStyle: const TextStyle(
|
||||
color: Color(0xFF999999),
|
||||
fontSize: 15,
|
||||
height: 1.2,
|
||||
),
|
||||
hintStyle: TextStyle(color: colors.onSurface.withAlpha(100)),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
fillColor: colors.surface,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Color(0xFFE5E7EB)),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Theme.of(context).primaryColor, width: 1.5),
|
||||
borderSide: BorderSide(color: colors.primary, width: 2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.red, width: 1.5),
|
||||
borderSide: const BorderSide(color: Colors.red, width: 2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 15, vertical: 14),
|
||||
errorStyle: const TextStyle(fontSize: 12, height: 1, color: Colors.red),
|
||||
prefixIcon: prefixIcon,
|
||||
prefixIcon: Icon(prefixIcon, size: 20, color: Color(0xFF86909C)),
|
||||
prefixIconConstraints: const BoxConstraints(minWidth: 40),
|
||||
isDense: true,
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFormLabel(String text, {bool required = false}) {
|
||||
Widget buildFormLabel({
|
||||
required BuildContext context,
|
||||
required String text,
|
||||
required bool isRequired,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
text: text,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF1D2129),
|
||||
style: TextStyle(
|
||||
color: colors.onSurface,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: 'CustomFont',
|
||||
height: 1.2,
|
||||
),
|
||||
children: [
|
||||
if (required)
|
||||
if (isRequired)
|
||||
const TextSpan(
|
||||
text: ' *',
|
||||
style: TextStyle(color: Colors.red, fontSize: 16),
|
||||
@@ -60,12 +64,19 @@ Widget buildFormLabel(String text, {bool required = false}) {
|
||||
/// 表单底部按钮组组件
|
||||
Widget buildFormButtonGroup({
|
||||
required BuildContext context,
|
||||
required bool isShowDelete,
|
||||
required VoidCallback onConfirm,
|
||||
required VoidCallback onDelete,
|
||||
}) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: _buildCancelButton(context)),
|
||||
const SizedBox(width: 16),
|
||||
if (isShowDelete) ...[
|
||||
SizedBox(width: 16),
|
||||
Expanded(child: _buildDeleteButton(context, onDelete)),
|
||||
],
|
||||
SizedBox(width: 16),
|
||||
Expanded(child: _buildSubmitButton(context, onConfirm)),
|
||||
],
|
||||
);
|
||||
@@ -76,9 +87,8 @@ Widget _buildCancelButton(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => Navigator.pop(context), // 直接使用传入的context返回
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
foregroundColor: const Color(0xFF4E5969),
|
||||
side: const BorderSide(color: Color(0xFFDCDFE6)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
@@ -98,3 +108,16 @@ Widget _buildSubmitButton(BuildContext context, VoidCallback onConfirm) {
|
||||
child: const Text('提交', style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
/// 删除按钮
|
||||
Widget _buildDeleteButton(BuildContext context, VoidCallback onDelete) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => onDelete(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text('删除', style: TextStyle(color: Colors.white)),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user