123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- // Copyright 2019 The Flutter team. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- import 'package:colorize_logger/colorize_logger.dart';
- import 'package:flutter/material.dart';
- import 'package:get_it/get_it.dart';
- import 'package:ustest/AutoTestView.dart';
- import 'package:ustest/MyView.dart';
- import 'package:ustest/PackageView.dart';
- import 'package:ustest/PublishView.dart';
- import 'BuildView.dart';
- import 'Services/UserService.dart';
- import 'package:flutter_gen/gen_l10n/app_localizations.dart';
- class MainScreen extends StatefulWidget {
- const MainScreen({Key? key}) : super(key: key);
- @override
- _MainScreenState createState() => _MainScreenState();
- }
- class _MainScreenState extends State<MainScreen> with RestorationMixin {
- final RestorableInt _selectedIndex = RestorableInt(0);
- @override
- String get restorationId => 'nav_rail_demo';
- @override
- void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
- registerForRestoration(_selectedIndex, 'selected_index');
- }
- @override
- void initState() {
- Logger.info('MainScreen initState');
- super.initState();
- }
- void loadUserData() async {
- try {
- var service = GetIt.instance.get<UserService>();
- await service.UpdateCurrentUserDetail();
- } catch (ex) {
- Logger.warning('loadUserData ex:$ex');
- }
- }
- @override
- void dispose() {
- _selectedIndex.dispose();
- Logger.info('MainScreen dispose');
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- print("build MainScreen");
- final selectedItem = <Widget>[
- BuildView(),
- PackageView(),
- PublishView(),
- AutoTestView(),
- MyView()
- ]; //DOTo
- return Scaffold(
- appBar: AppBar(
- title: Text(
- AppLocalizations.of(context)!.deploySystem,
- ),
- ),
- body: Row(
- children: [
- NavigationRail(
- selectedIndex: _selectedIndex.value,
- onDestinationSelected: (index) {
- setState(() {
- var oldIndex = _selectedIndex.value;
- print('oldIndex:$oldIndex =>index:$index');
- _selectedIndex.value = index;
- });
- },
- labelType: NavigationRailLabelType.all,
- destinations: [
- NavigationRailDestination(
- icon: const Icon(
- Icons.build_outlined,
- ),
- selectedIcon: const Icon(
- Icons.build_rounded,
- ),
- label: Text(
- AppLocalizations.of(context)!.build,
- ),
- ),
- NavigationRailDestination(
- icon: const Icon(
- Icons.badge_outlined,
- ),
- selectedIcon: const Icon(
- Icons.badge_rounded,
- ),
- label: Text(
- AppLocalizations.of(context)!.package,
- ),
- ),
- NavigationRailDestination(
- icon: const Icon(
- Icons.publish_outlined,
- ),
- selectedIcon: const Icon(
- Icons.publish_rounded,
- ),
- label: Text(
- AppLocalizations.of(context)!.publish,
- ),
- ),
- NavigationRailDestination(
- icon: const Icon(
- Icons.list_outlined,
- ),
- selectedIcon: const Icon(
- Icons.list_alt_rounded,
- ),
- label: Text(
- AppLocalizations.of(context)!.autoTest,
- ),
- ),
- NavigationRailDestination(
- icon: const Icon(
- Icons.account_circle_outlined,
- ),
- selectedIcon: const Icon(
- Icons.account_circle_rounded,
- ),
- label: Text(
- "My",
- ),
- ),
- ],
- ),
- const VerticalDivider(thickness: 1, width: 1),
- Expanded(
- child: Center(
- child: selectedItem[_selectedIndex.value],
- ),
- ),
- ],
- ),
- );
- }
- }
|