import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:wallpaperx/common/components/keep_alive_wrapper.dart'; import 'package:wallpaperx/page/home/drawer_view/drawer_view.dart'; import 'package:wallpaperx/page/home/home_controller.dart'; class HomeView extends GetView { const HomeView({super.key}); @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, key: controller.scaffoldKey, body: Stack( alignment: AlignmentDirectional.bottomCenter, children: [ PageView( physics: const NeverScrollableScrollPhysics(), controller: controller.pageController, onPageChanged: (index) => controller.onPageChanged(index), children: controller.pages .map((e) => KeepAliveWrapper(child: e.widget)) .toList(), ), Obx( () => Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [ Colors.transparent, Colors.black, ], begin: Alignment.topCenter, end: Alignment.bottomCenter, ), ), child: BottomNavigationBar( backgroundColor: Colors.transparent, type: BottomNavigationBarType.fixed, currentIndex: controller.currentIndex.value, onTap: (index) => controller.onTapNavigationBar(index), items: _bottomNavigationBarItems(), ), ), ), ], ), drawer: const DrawerView(), ); } List _bottomNavigationBarItems() { return controller.pages.map((e) { return BottomNavigationBarItem( icon: Image.asset( e.icons[0], width: 32.w, height: 32.w, color: const Color(0xff6D6D6D), gaplessPlayback: true, ), activeIcon: Image.asset( e.icons[1], width: 32.w, height: 32.w, color: Colors.white, gaplessPlayback: true, ), label: "", ); }).toList(); } }