63 lines
1.9 KiB
Dart
63 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:hello_wallpaper/common/components/keep_alive_wrapper.dart';
|
|
import 'package:hello_wallpaper/common/components/navigation_bar/title_bar_widget.dart';
|
|
import 'package:hello_wallpaper/modules/home/home_controller.dart';
|
|
|
|
class HomeView extends GetView<HomeController> {
|
|
const HomeView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Column(
|
|
children: [
|
|
SizedBox(height: ScreenUtil().statusBarHeight),
|
|
Obx(() {
|
|
return TitleBarWidget(
|
|
controller.pages[controller.currentIndex.value].label,
|
|
settingsOnTap: controller.onTapSettings,
|
|
);
|
|
}),
|
|
Expanded(
|
|
child: PageView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
controller: controller.pageController,
|
|
onPageChanged: (index) => controller.onPageChanged(index),
|
|
children: controller.pages.map((e) => KeepAliveWrapper(child: e.widget)).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
bottomNavigationBar: Obx(() {
|
|
return BottomNavigationBar(
|
|
currentIndex: controller.currentIndex.value,
|
|
onTap: (index) => controller.onTapNavigationBar(index),
|
|
items: _bottomNavigationBarItems(),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
List<BottomNavigationBarItem> _bottomNavigationBarItems() {
|
|
return controller.pages.map((e) {
|
|
return BottomNavigationBarItem(
|
|
icon: Image.asset(
|
|
e.icons[0],
|
|
width: 22.w,
|
|
height: 22.w,
|
|
gaplessPlayback: true,
|
|
),
|
|
activeIcon: Image.asset(
|
|
e.icons[1],
|
|
width: 22.w,
|
|
height: 22.w,
|
|
gaplessPlayback: true,
|
|
),
|
|
label: e.label,
|
|
);
|
|
}).toList();
|
|
}
|
|
}
|