WallPaper_FSX_Flutter/lib/modules/home/home_view.dart
2024-05-13 13:44:27 +08:00

49 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaper/common/components/keep_alive_wrapper.dart';
import 'package:wallpaper/modules/home/home_controller.dart';
class HomeView extends GetView<HomeController> {
const HomeView({super.key});
@override
Widget build(BuildContext context) {
Get.lazyPut(() => HomeController());
return SafeArea(
child: GetBuilder<HomeController>(
builder: (controller) {
return Column(
children: [
if (controller.wallpaperModelList.isNotEmpty) ...[
_tabBar(),
_tabBarView(),
],
],
);
},
),
);
}
Widget _tabBar() {
return TabBar(
isScrollable: true,
labelPadding: const EdgeInsets.symmetric(horizontal: 8.0).w,
indicatorPadding: const EdgeInsets.only(bottom: 6).h,
controller: controller.tabController,
tabs: controller.wallpaperModelList.map((e) => Tab(text: '${e.name}')).toList(),
);
}
Widget _tabBarView() {
return Expanded(
child: TabBarView(
physics: const BouncingScrollPhysics(),
controller: controller.tabController,
children: controller.clsPages.map((e) => KeepAliveWrapper(child: e)).toList(),
),
);
}
}