feat:更新TabUI模块
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
Widget formLabelText({required String labelText, bool isRequired = false}) {
|
||||
return Text.rich(
|
||||
@@ -50,16 +51,46 @@ Widget buildEmptyData() {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildToggleSwitch<T extends Enum>({
|
||||
required BuildContext context,
|
||||
required T currentTab,
|
||||
required List<T> tabValues,
|
||||
required List<String> labels,
|
||||
required ValueChanged<T> onTabChanged,
|
||||
}) {
|
||||
return ToggleSwitch(
|
||||
minWidth: 90.0,
|
||||
minHeight: 40.0,
|
||||
initialLabelIndex: tabValues.indexOf(currentTab),
|
||||
totalSwitches: tabValues.length,
|
||||
labels: labels,
|
||||
activeBgColor: [Theme.of(context).colorScheme.primary],
|
||||
activeFgColor: Colors.white,
|
||||
inactiveBgColor: Colors.grey.shade200,
|
||||
inactiveFgColor: Colors.grey.shade700,
|
||||
cornerRadius: 12.0,
|
||||
customTextStyles: [TextStyle(fontSize: 12, fontWeight: FontWeight.w500)],
|
||||
onToggle: (index) {
|
||||
if (index != null && index < tabValues.length) {
|
||||
onTabChanged(tabValues[index]);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 圆形图标按钮
|
||||
Widget circleIconButton({
|
||||
required IconData icon,
|
||||
required VoidCallback onPressed,
|
||||
required BuildContext context,
|
||||
bool? isSmall
|
||||
}) {
|
||||
final double size = isSmall == true ? 24 : 36;
|
||||
|
||||
return ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
fixedSize: Size(26, 26),
|
||||
fixedSize: Size(size, size),
|
||||
shape: CircleBorder(),
|
||||
elevation: 0,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
|
||||
@@ -91,6 +91,7 @@ class _YearSelectorState extends State<YearSelector>
|
||||
circleIconButton(
|
||||
context: context,
|
||||
icon: Icons.chevron_left,
|
||||
isSmall: true,
|
||||
onPressed: () => _previousYear(),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
@@ -113,6 +114,7 @@ class _YearSelectorState extends State<YearSelector>
|
||||
circleIconButton(
|
||||
context: context,
|
||||
icon: Icons.chevron_right,
|
||||
isSmall: true,
|
||||
onPressed: () => _nextYear(),
|
||||
)
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user