2024-03-18 13:23:58 +08:00
|
|
|
// import 'dart:io';
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import '../../models/app_bottom_nav_item.dart';
|
|
|
|
import '../../services/app_info.service.dart';
|
|
|
|
import '../../util/util.dart';
|
|
|
|
|
|
|
|
class LandingPage extends StatefulWidget {
|
|
|
|
LandingPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_LandingPageState createState() => _LandingPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _LandingPageState extends State<LandingPage> {
|
|
|
|
int _selectedLanding = 0;
|
|
|
|
|
|
|
|
List<BottomNavigationBarItem> bottomNavItems = [];
|
|
|
|
List<Widget> pages = [];
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
// ScreenUtil.init(
|
|
|
|
// BoxConstraints(
|
|
|
|
// maxWidth: MediaQuery.of(context).size.width,
|
|
|
|
// maxHeight: MediaQuery.of(context).size.height),
|
|
|
|
// designSize: const Size(414, 896),
|
|
|
|
// orientation: Orientation.portrait,
|
|
|
|
// context: context,
|
|
|
|
// );
|
|
|
|
List<AppBottomNavItem> roleWithBottomNavItems =
|
|
|
|
AppInfoService.to.bottomNavItems!;
|
|
|
|
bottomNavItems = roleWithBottomNavItems
|
|
|
|
.map((e) => BottomNavigationBarItem(
|
2024-03-19 08:59:08 +08:00
|
|
|
icon: e.icon, activeIcon: e.activeIcon, label: e.label))
|
2024-03-18 13:23:58 +08:00
|
|
|
.toList();
|
|
|
|
pages = roleWithBottomNavItems.map((e) => e.page!).toList();
|
|
|
|
return Scaffold(
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
2024-03-19 08:59:08 +08:00
|
|
|
iconSize: ScreenAdaper.sp(40),
|
2024-03-18 13:23:58 +08:00
|
|
|
type: BottomNavigationBarType.fixed,
|
|
|
|
items: bottomNavItems,
|
2024-03-19 08:59:08 +08:00
|
|
|
showSelectedLabels: true,
|
|
|
|
showUnselectedLabels: true,
|
2024-03-18 13:23:58 +08:00
|
|
|
currentIndex: _selectedLanding,
|
|
|
|
onTap: (landing) {
|
|
|
|
_onItemTapped(landing);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: pages[_selectedLanding],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onItemTapped(int landing) {
|
|
|
|
if (landing != _selectedLanding) {
|
|
|
|
setState(() {
|
|
|
|
_selectedLanding = landing;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|