123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- import 'package:flutter/foundation.dart';
- import 'package:flutter/gestures.dart';
- import 'package:flyinsono/architecture/utils/window__change_helpler.dart';
- import 'package:flyinsono/global.dart';
- import 'package:flyinsono/lab/color/lab_colors.dart';
- import 'package:flyinsono/lab/manager/page_manager.dart';
- import 'package:flyinsono/lab/pages/lab_main/index.dart';
- import 'package:flutter/material.dart';
- import 'package:flyinsono/lab/pages/lab_main/widgets/logo_item.dart';
- import 'package:flyinsono/lab/pages/lab_main/widgets/user_label.dart';
- import 'package:flyinsono/lab/pages/lab_main/widgets/widgets.dart';
- import 'package:flyinsono/pages/others/title_bar_buttons.dart';
- import 'package:get/get.dart';
- import 'package:fis_common/index.dart';
- class MainPageHeader extends GetView<LabMainController> {
- const MainPageHeader({Key? key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- final content = Container(
- color: LabColors.mainPageHeaderColor,
- height: 50,
- child: Row(
- children: [
- if (!Global.isVStationSlave)
- GetBuilder<LabMainController>(
- id: LabMainController.headerLogoId,
- builder: (_) {
- return LogoItem(
- isActive: PageManager.ins.activeTabHash ==
- PageManager.ins.tabTitles[0].tabHash,
- onTap: () {
- PageManager.ins
- .changeTabByHash(PageManager.ins.tabTitles[0].tabHash);
- },
- );
- },
- ),
- Expanded(
- child: Stack(
- children: [
- GetBuilder<LabMainController>(
- id: LabMainController.headerTabsId,
- builder: (_) {
- List<Widget> tabs = [];
- if (PageManager.ins.tabViews.isEmpty) {
- return Container();
- }
- for (var i = 0; i < PageManager.ins.tabTitles.length; i++) {
- final int tabHash = PageManager.ins.tabTitles[i].tabHash;
- tabs.add(
- TabItem(
- index: i,
- isActive: PageManager.ins.activeTabHash == tabHash,
- text: PageManager.ins.tabTitles[i].title,
- onTap: () {
- PageManager.ins.changeTabByHash(tabHash);
- },
- onClose: PageManager.ins.isFixedTab(tabHash)
- ? null
- : () => PageManager.ins.closeTab(tabHash),
- ),
- );
- }
- return Listener(
- onPointerSignal: (pointerSignal) {
- if (pointerSignal is PointerScrollEvent) {
- controller
- .scrollTabByPointerScrollEvent(pointerSignal);
- }
- },
- child: SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- controller: controller.tabScrollController,
- physics: const NeverScrollableScrollPhysics(),
- child: Row(
- children: tabs,
- ),
- ),
- );
- },
- ),
- Row(
- children: [
- Obx(
- () => controller.state.showLeftMoreIcon
- ? ShowMoreIcon(
- isLeft: true,
- onTap: () {
- controller.scrollTabToLeft();
- },
- )
- : Container(),
- ),
- Expanded(child: Container()),
- Obx(
- () => controller.state.showRightMoreIcon
- ? ShowMoreIcon(
- isLeft: false,
- onTap: () {
- controller.scrollTabToRight();
- },
- )
- : Container(),
- ),
- ],
- )
- ],
- ),
- ),
- Container(
- margin: const EdgeInsets.symmetric(horizontal: 10),
- child: Row(
- children: [
- if (!Global.isVStationSlave) UserLabel(),
- if (FPlatform.isWindows && !Global.isVStationSlave)
- _buildWindowOperateButtons(),
- ],
- ),
- ),
- ],
- ),
- );
- if (FPlatform.isPureWeb) {
- return content;
- } else {
- return GestureDetector(
- onPanStart: (event) {
- WindowChangeHelper.onStartDrag();
- },
- onPanEnd: (e) {
- WindowChangeHelper.onEndDrag();
- },
- onDoubleTap: () {
- WindowChangeHelper.onMaximize();
- },
- onPanCancel: () {
- WindowChangeHelper.onEndDrag();
- },
- child: content,
- );
- }
- }
- ///最大化、最小化、关闭按钮
- Widget _buildWindowOperateButtons() {
- return TitleBarButtons(
- WindowChangeHelper.onMinimize,
- WindowChangeHelper.onClose,
- WindowChangeHelper.onMaximize,
- LabColors.text100,
- LabColors.tabBarButtonColor,
- hoverColor: LabColors.hoverButtonColor,
- isLabHeader: true,
- isShowNotification: false,
- );
- }
- }
|