Showing
3 changed files
with
49 additions
and
41 deletions
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; | 2 | import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; |
| 3 | 3 | ||
| 4 | +import 'sleep_report_text_styles.dart'; | ||
| 5 | + | ||
| 4 | void showSleepQualityDialog(BuildContext context) { | 6 | void showSleepQualityDialog(BuildContext context) { |
| 5 | showModalBottomSheet<void>( | 7 | showModalBottomSheet<void>( |
| 6 | context: context, | 8 | context: context, |
| @@ -15,7 +17,6 @@ class SleepQualityDialog extends StatelessWidget { | @@ -15,7 +17,6 @@ class SleepQualityDialog extends StatelessWidget { | ||
| 15 | const SleepQualityDialog({super.key}); | 17 | const SleepQualityDialog({super.key}); |
| 16 | 18 | ||
| 17 | static const _bg = Color(0xFFF5F2FF); | 19 | static const _bg = Color(0xFFF5F2FF); |
| 18 | - static const _h1 = Color(0xFF0F0F11); | ||
| 19 | static const _h2 = Color(0xFF78787D); | 20 | static const _h2 = Color(0xFF78787D); |
| 20 | static const _purple = Color(0xFFA084EF); | 21 | static const _purple = Color(0xFFA084EF); |
| 21 | static const _orange = Color(0xFFFF9A6E); | 22 | static const _orange = Color(0xFFFF9A6E); |
| @@ -64,12 +65,9 @@ class SleepQualityDialog extends StatelessWidget { | @@ -64,12 +65,9 @@ class SleepQualityDialog extends StatelessWidget { | ||
| 64 | child: Center( | 65 | child: Center( |
| 65 | child: Text( | 66 | child: Text( |
| 66 | context.l10n.sleepQualityTitle, | 67 | context.l10n.sleepQualityTitle, |
| 67 | - style: const TextStyle( | ||
| 68 | - color: _h1, | ||
| 69 | - fontSize: 16, | ||
| 70 | - fontWeight: FontWeight.w600, | ||
| 71 | - height: 1.2, | ||
| 72 | - ), | 68 | + textAlign: TextAlign.center, |
| 69 | + strutStyle: SleepReportTextStyles.titleStrutStyle, | ||
| 70 | + style: SleepReportTextStyles.titleTextStyle, | ||
| 73 | ), | 71 | ), |
| 74 | ), | 72 | ), |
| 75 | ), | 73 | ), |
| @@ -108,7 +106,7 @@ class SleepQualityDialog extends StatelessWidget { | @@ -108,7 +106,7 @@ class SleepQualityDialog extends StatelessWidget { | ||
| 108 | height: 5, | 106 | height: 5, |
| 109 | margin: const EdgeInsets.only(bottom: 8), | 107 | margin: const EdgeInsets.only(bottom: 8), |
| 110 | decoration: BoxDecoration( | 108 | decoration: BoxDecoration( |
| 111 | - color: _h1, | 109 | + color: SleepReportTextStyles.titleColor, |
| 112 | borderRadius: BorderRadius.circular(100), | 110 | borderRadius: BorderRadius.circular(100), |
| 113 | ), | 111 | ), |
| 114 | ), | 112 | ), |
| 1 | +import 'package:flutter/foundation.dart'; | ||
| 2 | +import 'package:flutter/material.dart'; | ||
| 3 | + | ||
| 4 | +abstract final class SleepReportTextStyles { | ||
| 5 | + static const titleColor = Color(0xFF0F0F11); | ||
| 6 | + | ||
| 7 | + static bool get _usesAppleTextRenderer => | ||
| 8 | + defaultTargetPlatform == TargetPlatform.iOS || | ||
| 9 | + defaultTargetPlatform == TargetPlatform.macOS; | ||
| 10 | + | ||
| 11 | + static TextStyle get titleTextStyle { | ||
| 12 | + const baseStyle = TextStyle( | ||
| 13 | + color: titleColor, | ||
| 14 | + fontSize: 16, | ||
| 15 | + fontWeight: FontWeight.w600, | ||
| 16 | + height: 1.2, | ||
| 17 | + ); | ||
| 18 | + if (!_usesAppleTextRenderer) return baseStyle; | ||
| 19 | + return baseStyle.copyWith( | ||
| 20 | + fontFamily: 'PingFang SC', | ||
| 21 | + fontFamilyFallback: const ['Heiti SC', 'Arial Unicode MS'], | ||
| 22 | + ); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + static StrutStyle get titleStrutStyle { | ||
| 26 | + if (!_usesAppleTextRenderer) { | ||
| 27 | + return const StrutStyle( | ||
| 28 | + fontSize: 16, | ||
| 29 | + height: 1.2, | ||
| 30 | + ); | ||
| 31 | + } | ||
| 32 | + return const StrutStyle( | ||
| 33 | + fontSize: 16, | ||
| 34 | + fontFamily: 'PingFang SC', | ||
| 35 | + fontFamilyFallback: ['Heiti SC', 'Arial Unicode MS'], | ||
| 36 | + height: 1.2, | ||
| 37 | + ); | ||
| 38 | + } | ||
| 39 | +} |
| 1 | import 'package:doublefeel_flutter/r.dart'; | 1 | import 'package:doublefeel_flutter/r.dart'; |
| 2 | import 'package:fl_chart/fl_chart.dart'; | 2 | import 'package:fl_chart/fl_chart.dart'; |
| 3 | -import 'package:flutter/foundation.dart'; | ||
| 4 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 5 | import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; | 4 | import 'package:doublefeel_flutter/l10n/l10n_extensions.dart'; |
| 6 | 5 | ||
| 7 | import '../../report_common/widgets/health_report_subject_scope.dart'; | 6 | import '../../report_common/widgets/health_report_subject_scope.dart'; |
| 8 | import '../../report_common/utils/report_localization.dart'; | 7 | import '../../report_common/utils/report_localization.dart'; |
| 9 | import '../models/sleep_report_models.dart'; | 8 | import '../models/sleep_report_models.dart'; |
| 9 | +import 'sleep_report_text_styles.dart'; | ||
| 10 | 10 | ||
| 11 | class SleepWeekReportView extends StatelessWidget { | 11 | class SleepWeekReportView extends StatelessWidget { |
| 12 | const SleepWeekReportView({ | 12 | const SleepWeekReportView({ |
| @@ -22,43 +22,14 @@ class SleepWeekReportView extends StatelessWidget { | @@ -22,43 +22,14 @@ class SleepWeekReportView extends StatelessWidget { | ||
| 22 | static const qualityAverageLine = Color(0xFFC9D6FF); | 22 | static const qualityAverageLine = Color(0xFFC9D6FF); |
| 23 | static const green = Color(0xFF3BD49D); | 23 | static const green = Color(0xFF3BD49D); |
| 24 | static const red = Color(0xFFFF5279); | 24 | static const red = Color(0xFFFF5279); |
| 25 | - static const h1 = Color(0xFF0F0F11); | 25 | + static const h1 = SleepReportTextStyles.titleColor; |
| 26 | static const h2 = Color(0xFF78787D); | 26 | static const h2 = Color(0xFF78787D); |
| 27 | static const h3 = Color(0xFFB0B0B6); | 27 | static const h3 = Color(0xFFB0B0B6); |
| 28 | static const grid = Color(0xFFF3F3F3); | 28 | static const grid = Color(0xFFF3F3F3); |
| 29 | 29 | ||
| 30 | - static bool get _usesAppleTextRenderer => | ||
| 31 | - defaultTargetPlatform == TargetPlatform.iOS || | ||
| 32 | - defaultTargetPlatform == TargetPlatform.macOS; | 30 | + static TextStyle get titleTextStyle => SleepReportTextStyles.titleTextStyle; |
| 33 | 31 | ||
| 34 | - static TextStyle get titleTextStyle { | ||
| 35 | - const baseStyle = TextStyle( | ||
| 36 | - color: h1, | ||
| 37 | - fontSize: 16, | ||
| 38 | - fontWeight: FontWeight.w600, | ||
| 39 | - height: 1.2, | ||
| 40 | - ); | ||
| 41 | - if (!_usesAppleTextRenderer) return baseStyle; | ||
| 42 | - return baseStyle.copyWith( | ||
| 43 | - fontFamily: 'PingFang SC', | ||
| 44 | - fontFamilyFallback: const ['Heiti SC', 'Arial Unicode MS'], | ||
| 45 | - ); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - static StrutStyle get titleStrutStyle { | ||
| 49 | - if (!_usesAppleTextRenderer) { | ||
| 50 | - return const StrutStyle( | ||
| 51 | - fontSize: 16, | ||
| 52 | - height: 1.2, | ||
| 53 | - ); | ||
| 54 | - } | ||
| 55 | - return const StrutStyle( | ||
| 56 | - fontSize: 16, | ||
| 57 | - fontFamily: 'PingFang SC', | ||
| 58 | - fontFamilyFallback: ['Heiti SC', 'Arial Unicode MS'], | ||
| 59 | - height: 1.2, | ||
| 60 | - ); | ||
| 61 | - } | 32 | + static StrutStyle get titleStrutStyle => SleepReportTextStyles.titleStrutStyle; |
| 62 | 33 | ||
| 63 | static int minutesFromEvening(DateTime time) { | 34 | static int minutesFromEvening(DateTime time) { |
| 64 | final minutes = time.hour * 60 + time.minute; | 35 | final minutes = time.hour * 60 + time.minute; |
-
Please register or login to post a comment