2024-05-15 10:06:18 +08:00

113 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../../../app_settings/app_colors.dart';
import '../../../../../../tools/CustomUnderlineTabIndicator.dart';
import '../../../../../../translations/trans_lib.dart';
import '../massSendElectronicKey_page.dart';
class MassSendElectronicKeyManageTabbar extends StatefulWidget {
var initialIndex = 1;
MassSendElectronicKeyManageTabbar({Key? key, required this.initialIndex})
: super(key: key);
@override
State<MassSendElectronicKeyManageTabbar> createState() =>
_MassSendElectronicKeyManageTabbarState();
}
class _MassSendElectronicKeyManageTabbarState
extends State<MassSendElectronicKeyManageTabbar>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "0"),
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "1"),
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "2"),
];
@override
void initState() {
// TODO: implement initState
super.initState();
_tabController = TabController(
vsync: this,
length: _itemTabs.length,
initialIndex: widget.initialIndex);
}
@override
Widget build(BuildContext context) {
return Expanded(
child: Column(
children: [
_tabBar(),
_pageWidget(),
],
));
}
TabBar _tabBar() {
return TabBar(
controller: _tabController,
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 28.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 32.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
// text: item.title,
child: Container(
width: 1.sw / 8,
margin: EdgeInsets.all(10.w),
// color: Colors.red,
child: Text(
item.title,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24.sp),
),
),
);
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: _tabController,
children: _itemTabs
.map((ItemView item) => MassSendElectronicKeyPage(
type: item.type,
))
.toList(),
),
);
}
}
class ItemView {
const ItemView({required this.title, required this.type});
final String title;
final String type;
}