mobile_skt/lib/screens/landing/zt_landing.dart

64 lines
1.8 KiB
Dart

// 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(
icon: e.icon, activeIcon: e.activeIcon, label: e.label))
.toList();
pages = roleWithBottomNavItems.map((e) => e.page!).toList();
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
iconSize: ScreenAdaper.sp(40),
type: BottomNavigationBarType.fixed,
items: bottomNavItems,
showSelectedLabels: true,
showUnselectedLabels: true,
currentIndex: _selectedLanding,
onTap: (landing) {
_onItemTapped(landing);
},
),
body: pages[_selectedLanding],
);
}
void _onItemTapped(int landing) {
if (landing != _selectedLanding) {
setState(() {
_selectedLanding = landing;
});
}
}
}