main.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:fis_common/logger/logger.dart';
  4. import 'package:flutter_easyloading/flutter_easyloading.dart';
  5. import 'package:get/get.dart';
  6. import 'package:vitalapp/components/floating_window/index.dart';
  7. import 'package:vitalapp/store/store.dart';
  8. import 'global.dart';
  9. import 'routes/routes.dart';
  10. void main() async {
  11. runZonedGuarded(
  12. () async {
  13. try {
  14. WidgetsFlutterBinding.ensureInitialized();
  15. await Global.init();
  16. } catch (e) {
  17. logger.e('Global init Error', e);
  18. }
  19. runApp(const _App());
  20. },
  21. (error, stack) {
  22. // GlobalErrorHandler.handle(error, stack);
  23. },
  24. );
  25. }
  26. class _App extends StatelessWidget {
  27. const _App();
  28. @override
  29. Widget build(BuildContext context) {
  30. return GetMaterialApp(
  31. title: "家医一体机",
  32. theme: ThemeData(
  33. // primaryColor: const Color.fromRGBO(0, 178, 237, 1),
  34. // TODO:
  35. primaryColor: Colors.blue,
  36. colorScheme:
  37. ColorScheme.fromSeed(seedColor: Color(Colors.blue.value - 40)),
  38. // colorScheme: ColorScheme.fromSeed(
  39. // // seedColor: const Color.fromRGBO(44, 119, 229, 1),
  40. // // seedColor: Colors.lightBlue,
  41. // seedColor: const Color.fromRGBO(0, 178, 237, 1),
  42. // ),
  43. // colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
  44. useMaterial3: true,
  45. fontFamily: "NotoSansSC-R-fixed",
  46. fontFamilyFallback: const ["NotoSansSC-R-fixed"],
  47. ),
  48. debugShowCheckedModeBanner: false,
  49. getPages: Routes.routes,
  50. initialRoute: "splash",
  51. // initialRoute: "/patient/create",
  52. // initialRoute: "/contract/signature",
  53. // initialRoute: "/",
  54. builder: EasyLoading.init(
  55. builder: (context, widget) {
  56. const designWidth = 1280.0; // 设计尺寸宽度:1280
  57. final size = MediaQuery.of(context).size;
  58. final scale = size.width / designWidth; // 计算缩放比例
  59. return Obx(() {
  60. if (!Store.user.isShowUserCard) {
  61. return FittedBox(
  62. fit: BoxFit.fitWidth,
  63. child: SizedBox(
  64. width: designWidth,
  65. height: size.height / scale,
  66. child: Center(child: widget ?? const SizedBox()),
  67. ),
  68. );
  69. }
  70. return HoveringPatientCard(
  71. bgChild: FittedBox(
  72. fit: BoxFit.fitWidth,
  73. child: SizedBox(
  74. width: designWidth,
  75. height: size.height / scale,
  76. child: Center(child: widget ?? const SizedBox()),
  77. ),
  78. ),
  79. child: Container(
  80. width: 80,
  81. height: 80,
  82. decoration: BoxDecoration(
  83. color: Colors.blue.withOpacity(0.5),
  84. border: Border.all(color: Colors.blue),
  85. borderRadius: const BorderRadius.all(
  86. Radius.circular(50),
  87. ),
  88. ),
  89. child: Center(
  90. child: _buildPatient(),
  91. ),
  92. ),
  93. );
  94. });
  95. // return widget ?? const SizedBox();
  96. },
  97. ),
  98. );
  99. }
  100. Widget _buildPatient() {
  101. if (Store.user.currentSelectPatientInfo?.patientName?.isNotEmpty ?? false) {
  102. return Text(
  103. Store.user.currentSelectPatientInfo?.patientName ?? '',
  104. style: const TextStyle(
  105. color: Colors.white,
  106. fontSize: 20,
  107. ),
  108. overflow: TextOverflow.ellipsis,
  109. );
  110. } else {
  111. return const Icon(
  112. Icons.add,
  113. size: 40,
  114. color: Colors.white,
  115. );
  116. }
  117. }
  118. }