123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- import 'package:fis_theme/theme.dart';
- import 'package:fis_ui/values/icons.dart';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/dynamic_drawer.dart';
- import 'package:vitalapp/pages/home/controller.dart';
- import 'package:vitalapp/pages/home/widgets/avatar.dart';
- import 'package:fis_common/helpers/color.dart';
- import 'package:vitalapp/pages/settings/center/controller.dart';
- import 'package:vitalapp/pages/settings/center/view.dart';
- import 'package:vitalapp/pages/settings/devices/controller.dart';
- import 'package:vitalapp/pages/settings/server/controller.dart';
- import 'package:vitalapp/pages/widgets/qr_view_example.dart';
- import 'package:vitalapp/store/store.dart';
- import 'widgets/menus.dart';
- import 'widgets/navigator.dart';
- import 'widgets/patient.dart';
- import 'widgets/status_bar.dart';
- import 'widgets/title_bar_buttons.dart';
- class HomePage extends GetView<HomeController> {
- const HomePage({super.key});
- @override
- Widget build(BuildContext context) {
- return SafeArea(
- top: false,
- bottom: false,
- right: false,
- left: false,
- // maintainBottomViewPadding: true,
- child: LayoutBuilder(
- builder: (context, c) {
- return WillPopScope(
- onWillPop: () async {
- return false;
- },
- child: Scaffold(
- key: controller.homeScaffoldKey,
- // resizeToAvoidBottomInset: false,
- backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
- endDrawer: VDynamicDrawerWrapper(
- scaffoldKey: controller.homeScaffoldKey,
- ),
- body: Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- // Expanded(child: _buildBody(context)),
- SizedBox(
- width: c.maxWidth,
- child: _buildBody(context),
- ),
- ],
- )),
- );
- },
- ),
- );
- }
- Widget _buildBody(BuildContext context) {
- Widget leftMenus = SizedBox();
- if (controller.state.menuItems.length != 1) leftMenus = _buildMenu(context);
- return Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- leftMenus,
- Container(
- color: Theme.of(context).primaryColor,
- child: VerticalDivider(
- width: 1,
- color: Colors.white.withOpacity(.4),
- ),
- ),
- Expanded(
- child: Column(
- children: [
- SizedBox(
- height: 60,
- child: _buildHeader(context),
- ),
- Expanded(
- child: Row(
- children: [
- Expanded(
- child: _buildContent(),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ],
- );
- }
- Widget _buildMenu(BuildContext context) {
- final menuScrollController = ScrollController();
- return Container(
- width: kIsWeb ? 100 : 120,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [
- Theme.of(context).primaryColor,
- FColorHelper.mixColor(
- Colors.black,
- Theme.of(context).primaryColor,
- 50,
- ),
- ],
- begin: Alignment.bottomRight,
- end: Alignment.topLeft,
- ),
- ),
- child: Stack(
- children: [
- Positioned(
- bottom: 0,
- left: 0,
- right: 0,
- child: Opacity(
- opacity: 0.5,
- child: Image.asset(
- "assets/images/e_hospital.png",
- fit: BoxFit.fitWidth,
- ),
- ),
- ),
- Column(
- mainAxisSize: MainAxisSize.max,
- children: [
- SizedBox(
- height: 90,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Obx(
- () => HomeAvatarWidget(
- size: 40,
- headImageToken: controller.state.headImageToken,
- ),
- ),
- const SizedBox(
- height: 8,
- ),
- Obx(
- () => Text(
- controller.state.doctorName,
- style: const TextStyle(
- color: Colors.white,
- fontSize: 16,
- ),
- ),
- ),
- ],
- ),
- ),
- Divider(
- color: Colors.white.withOpacity(.4),
- height: 1,
- indent: 30,
- endIndent: 30,
- ),
- const SizedBox(
- height: 8,
- ),
- Expanded(
- child: Obx(
- () {
- return HomeMenuListViewWidget(
- source: controller.state.menuItems,
- scrollerController: menuScrollController,
- currentSelectMenu: controller.state.currentSelectMenu,
- );
- },
- ),
- ),
- ],
- ),
- ],
- ),
- );
- }
- Widget _buildContent() {
- return Padding(
- padding: EdgeInsets.all(8),
- child: HomeNavigator(),
- // child: Container(
- // color: Colors.white,
- // child: HomeNavigator(),
- // ),
- );
- }
- Widget _buildHeader(BuildContext context) {
- final themeData = Theme.of(context);
- return Container(
- alignment: Alignment.center,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [
- // Color.fromRGBO(59, 188, 255, 1),
- // Color.fromRGBO(44, 120, 229, 1),
- themeData.primaryColor.withOpacity(.6),
- themeData.primaryColor,
- ],
- begin: Alignment.topRight,
- end: Alignment.bottomLeft,
- ),
- ),
- child: Center(
- child: kIsWeb
- ? GestureDetector(
- onPanStart: (event) {
- controller.onStartDrag();
- },
- onPanEnd: (e) {
- controller.onEndDrag();
- },
- onDoubleTap: () {
- controller.onMaximize();
- },
- onPanCancel: () {
- controller.onEndDrag();
- },
- child: _buildWindowTitle(context),
- )
- : _buildWindowTitle(context),
- ),
- );
- }
- Widget _buildHeaderLeft() {
- return Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- // const HomeAvatarWidget(size: 40),
- const SizedBox(width: 16),
- RichText(
- text: TextSpan(
- text: controller.state.doctorTeamName,
- style: const TextStyle(
- color: Colors.white,
- fontSize: 20,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- if (kIsWeb)
- Expanded(
- child: Container(
- color: Colors.transparent,
- height: 60,
- ),
- ),
- ],
- );
- }
- Widget _buildHeaderCenter() {
- int clickCount = 0;
- return Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- const SizedBox(width: 10),
- if (kIsWeb)
- Expanded(
- child: Container(
- color: Colors.transparent,
- height: 60,
- ),
- ),
- Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- GestureDetector(
- onTap: () async {
- if (clickCount >= 10) {
- clickCount = 0;
- Get.toNamed("/admin");
- } else {
- if (clickCount > 5) {
- PromptBox.toast("Click count: $clickCount!");
- }
- clickCount++;
- }
- },
- child: const Text(
- "杏聆荟健康平台",
- style: TextStyle(
- color: Colors.white,
- fontSize: 24,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ],
- ),
- if (kIsWeb)
- Expanded(
- child: Container(
- color: Colors.transparent,
- height: 60,
- ),
- ),
- ],
- );
- }
- Widget _buildHeaderRight(BuildContext context) {
- return Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- if (kIsWeb)
- Expanded(
- child: Container(
- color: Colors.transparent,
- height: 60,
- ),
- ),
- if (!kIsWeb && Store.user.kIsVitalStation)
- IconButton(
- onPressed: () {
- Get.to(
- () => QRViewExample(
- onPressed: controller.onScanData,
- ),
- );
- },
- icon: Icon(
- FIcons.fis_scan,
- size: 40,
- color: Colors.white,
- ),
- ),
- HeaderPatientPlace(),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 8),
- child: VerticalDivider(
- indent: 12,
- endIndent: 12,
- color: Colors.white,
- ),
- ),
- HeaderStatusBar(),
- Center(
- child: IconButton(
- padding: EdgeInsets.all(0),
- onPressed: () {
- Get.lazyPut(() => DevicesSettingController());
- Get.lazyPut(() => ServerSettingController());
- Get.lazyPut(() => SettingCenterController());
- Get.to(
- Container(
- child: SettingCenterPage(),
- color: Colors.white,
- ),
- );
- },
- icon: Icon(
- Icons.settings,
- color: Colors.white,
- size: 36,
- ),
- ),
- ),
- if (kIsWeb) ...[
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 8),
- child: VerticalDivider(
- indent: 12,
- endIndent: 12,
- color: Colors.white,
- ),
- ),
- TitleBarButtons(
- controller.onMinimize,
- controller.onWindowClose,
- controller.onMaximize,
- Colors.white,
- Colors.transparent,
- ),
- ],
- ],
- );
- }
- Widget _buildWindowTitle(BuildContext context) {
- return Row(
- mainAxisSize: MainAxisSize.max,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- flex: 4,
- child: Align(
- alignment: Alignment.centerLeft,
- child: _buildHeaderLeft(),
- ),
- ),
- Flexible(
- flex: 4,
- child: Align(
- alignment: Alignment.center,
- child: _buildHeaderCenter(),
- ),
- ),
- Expanded(
- flex: 6,
- child: Align(
- alignment: Alignment.centerRight,
- child: _buildHeaderRight(context),
- ),
- ),
- ],
- );
- }
- }
|