116 lines
3.1 KiB
Dart
Executable File
116 lines
3.1 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/tools/CustomUnderlineTabIndicator.dart';
|
|
|
|
import 'expireCard/expireCard_page.dart';
|
|
import 'expireElectronicKey/expireLockList_page.dart';
|
|
import 'expireFace/expireFace_page.dart';
|
|
import 'expireFingerprint/expireFingerprint_page.dart';
|
|
import 'expirePassword/expirePassword_page.dart';
|
|
|
|
class ExpireLockManageTabbar extends StatefulWidget {
|
|
|
|
const ExpireLockManageTabbar({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ExpireLockManageTabbar> createState() => _ExpireLockManageTabbarState();
|
|
}
|
|
|
|
class _ExpireLockManageTabbarState extends State<ExpireLockManageTabbar> with SingleTickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
|
|
final List<ItemView> _itemTabs = <ItemView>[
|
|
ItemView(title: '电子钥匙'.tr, selectType: '0'),
|
|
ItemView(title: '密码'.tr, selectType: '1'),
|
|
ItemView(title: '卡'.tr, selectType: '2'),
|
|
ItemView(title: '指纹'.tr, selectType: '3'),
|
|
ItemView(title: '人脸'.tr, selectType: '4'),
|
|
];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_tabController = TabController(
|
|
vsync: this,
|
|
length: _itemTabs.length,
|
|
initialIndex: 0);
|
|
_tabController.addListener(() {
|
|
if (_tabController.animation!.value == _tabController.index) {
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: Column(
|
|
children: <Widget>[
|
|
_tabBar(),
|
|
_pageWidget(),
|
|
],
|
|
));
|
|
}
|
|
|
|
TabBar _tabBar() {
|
|
return TabBar(
|
|
controller: _tabController,
|
|
onTap: (int index) {
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
},
|
|
tabs: _itemTabs.map(_tab).toList(),
|
|
isScrollable: true,
|
|
indicatorColor: Colors.red,
|
|
unselectedLabelColor: Colors.black,
|
|
unselectedLabelStyle: TextStyle(
|
|
color: AppColors.mainColor,
|
|
fontSize: 24.sp,
|
|
),
|
|
automaticIndicatorColorAdjustment: true,
|
|
labelColor: AppColors.mainColor,
|
|
labelStyle: TextStyle(
|
|
color: AppColors.mainColor,
|
|
fontSize: 24.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(
|
|
child: SizedBox(
|
|
// width: 1.sw / 5,
|
|
child: Text(item.title, textAlign: TextAlign.center)));
|
|
}
|
|
|
|
Widget _pageWidget() {
|
|
return Expanded(
|
|
child: TabBarView(
|
|
controller: _tabController,
|
|
children: const <Widget>[
|
|
ExpireLockListPage(),
|
|
ExpirePasswordPage(),
|
|
ExpireCardPage(),
|
|
ExpireFingerprintPage(),
|
|
ExpireFacePage(),
|
|
]
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ItemView {
|
|
const ItemView({required this.title, required this.selectType});
|
|
|
|
final String title;
|
|
final String selectType;
|
|
}
|
|
|