2022-08-29 20:38:28 -06:00
|
|
|
// ignore_for_file: library_private_types_in_public_api
|
|
|
|
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:wonders/common_libs.dart';
|
|
|
|
|
|
|
|
export 'colors.dart';
|
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
AppStyle $styles = AppStyle();
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
@immutable
|
|
|
|
class AppStyle {
|
2022-10-24 15:42:27 -06:00
|
|
|
AppStyle({Size? appSize}) {
|
2022-12-22 13:34:12 -07:00
|
|
|
/// Measure the diagonal size of the app window, and slightly adjust the scale value which is
|
|
|
|
/// applied to paddings and font-sizes across the app.
|
2022-10-24 15:42:27 -06:00
|
|
|
if (appSize == null) {
|
|
|
|
scale = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final screenSize = (appSize.width + appSize.height) / 2;
|
2022-12-22 13:34:12 -07:00
|
|
|
if (screenSize > 1000) {
|
|
|
|
scale = 1.25; // large tablets
|
2022-10-24 15:42:27 -06:00
|
|
|
} else if (screenSize > 800) {
|
2022-12-22 13:34:12 -07:00
|
|
|
scale = 1; // small tablets
|
2022-10-24 15:42:27 -06:00
|
|
|
} else {
|
2022-12-22 13:34:12 -07:00
|
|
|
scale = .9; // phones
|
2022-10-24 15:42:27 -06:00
|
|
|
}
|
|
|
|
debugPrint('screenSize=$screenSize, scale=$scale');
|
|
|
|
}
|
|
|
|
|
|
|
|
late final double scale;
|
|
|
|
|
2022-08-29 20:38:28 -06:00
|
|
|
/// The current theme colors for the app
|
|
|
|
final AppColors colors = AppColors();
|
|
|
|
|
|
|
|
/// Rounded edge corner radii
|
|
|
|
late final _Corners corners = _Corners();
|
|
|
|
|
|
|
|
late final _Shadows shadows = _Shadows();
|
|
|
|
|
|
|
|
/// Padding and margin values
|
2022-10-24 15:42:27 -06:00
|
|
|
late final _Insets insets = _Insets(scale);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
/// Text styles
|
2022-10-24 15:42:27 -06:00
|
|
|
late final _Text text = _Text(scale);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
/// Animation Durations
|
|
|
|
final _Times times = _Times();
|
2022-10-07 11:28:15 -06:00
|
|
|
|
|
|
|
/// Shared sizes
|
2022-10-24 15:42:27 -06:00
|
|
|
late final _Sizes sizes = _Sizes();
|
2022-08-29 20:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
@immutable
|
|
|
|
class _Text {
|
2022-10-24 15:42:27 -06:00
|
|
|
_Text(this._scale);
|
|
|
|
final double _scale;
|
|
|
|
|
2022-08-29 20:38:28 -06:00
|
|
|
final Map<String, TextStyle> _titleFonts = {
|
|
|
|
'en': TextStyle(fontFamily: 'Tenor'),
|
|
|
|
};
|
|
|
|
|
|
|
|
final Map<String, TextStyle> _monoTitleFonts = {
|
|
|
|
'en': TextStyle(fontFamily: 'B612Mono'),
|
|
|
|
};
|
|
|
|
|
|
|
|
final Map<String, TextStyle> _quoteFonts = {
|
|
|
|
'en': TextStyle(fontFamily: 'Cinzel'),
|
|
|
|
'zh': TextStyle(fontFamily: 'MaShanZheng'),
|
|
|
|
};
|
|
|
|
|
|
|
|
final Map<String, TextStyle> _wonderTitleFonts = {
|
|
|
|
'en': TextStyle(fontFamily: 'Yeseva'),
|
|
|
|
};
|
|
|
|
|
|
|
|
final Map<String, TextStyle> _contentFonts = {
|
|
|
|
'en': TextStyle(fontFamily: 'Raleway', fontFeatures: const [
|
|
|
|
FontFeature.enable('dlig'),
|
|
|
|
FontFeature.enable('kern'),
|
|
|
|
]),
|
|
|
|
};
|
|
|
|
|
|
|
|
TextStyle _getFontForLocale(Map<String, TextStyle> fonts) {
|
|
|
|
if (localeLogic.isLoaded) {
|
|
|
|
return fonts.entries.firstWhere((x) => x.key == $strings.localeName, orElse: () => fonts.entries.first).value;
|
|
|
|
} else {
|
|
|
|
return fonts.entries.first.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextStyle get titleFont => _getFontForLocale(_titleFonts);
|
|
|
|
TextStyle get quoteFont => _getFontForLocale(_quoteFonts);
|
|
|
|
TextStyle get wonderTitleFont => _getFontForLocale(_wonderTitleFonts);
|
|
|
|
TextStyle get contentFont => _getFontForLocale(_contentFonts);
|
|
|
|
TextStyle get monoTitleFont => _getFontForLocale(_monoTitleFonts);
|
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
late final TextStyle dropCase = _createFont(quoteFont, sizePx: 56, heightPx: 20);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
late final TextStyle wonderTitle = _createFont(wonderTitleFont, sizePx: 64, heightPx: 56);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
late final TextStyle h1 = _createFont(titleFont, sizePx: 64, heightPx: 62);
|
|
|
|
late final TextStyle h2 = _createFont(titleFont, sizePx: 32, heightPx: 46);
|
|
|
|
late final TextStyle h3 = _createFont(titleFont, sizePx: 24, heightPx: 36, weight: FontWeight.w600);
|
|
|
|
late final TextStyle h4 = _createFont(contentFont, sizePx: 14, heightPx: 23, spacingPc: 5, weight: FontWeight.w600);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
late final TextStyle title1 = _createFont(titleFont, sizePx: 16, heightPx: 26, spacingPc: 5);
|
|
|
|
late final TextStyle title2 = _createFont(titleFont, sizePx: 14, heightPx: 16.38);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
late final TextStyle body = _createFont(contentFont, sizePx: 16, heightPx: 27);
|
|
|
|
late final TextStyle bodyBold = _createFont(contentFont, sizePx: 16, heightPx: 26, weight: FontWeight.w600);
|
|
|
|
late final TextStyle bodySmall = _createFont(contentFont, sizePx: 14, heightPx: 23);
|
|
|
|
late final TextStyle bodySmallBold = _createFont(contentFont, sizePx: 14, heightPx: 23, weight: FontWeight.w600);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
2022-10-24 15:42:27 -06:00
|
|
|
late final TextStyle quote1 =
|
|
|
|
_createFont(quoteFont, sizePx: 32, heightPx: 40, weight: FontWeight.w600, spacingPc: -3);
|
|
|
|
late final TextStyle quote2 = _createFont(quoteFont, sizePx: 21, heightPx: 32, weight: FontWeight.w400);
|
|
|
|
late final TextStyle quote2Sub = _createFont(body, sizePx: 16, heightPx: 40, weight: FontWeight.w400);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
late final TextStyle caption =
|
2022-10-24 15:42:27 -06:00
|
|
|
_createFont(contentFont, sizePx: 12, heightPx: 18, weight: FontWeight.w500).copyWith(fontStyle: FontStyle.italic);
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
late final TextStyle callout =
|
2022-10-24 15:42:27 -06:00
|
|
|
_createFont(contentFont, sizePx: 16, heightPx: 26, weight: FontWeight.w600).copyWith(fontStyle: FontStyle.italic);
|
2022-11-08 11:14:11 -07:00
|
|
|
late final TextStyle btn = _createFont(contentFont, sizePx: 12, weight: FontWeight.w600, heightPx: 14);
|
2022-10-24 15:42:27 -06:00
|
|
|
|
|
|
|
TextStyle _createFont(TextStyle style,
|
|
|
|
{required double sizePx, double? heightPx, double? spacingPc, FontWeight? weight}) {
|
|
|
|
sizePx *= _scale;
|
|
|
|
if (heightPx != null) {
|
|
|
|
heightPx *= _scale;
|
|
|
|
}
|
2022-08-29 20:38:28 -06:00
|
|
|
return style.copyWith(
|
|
|
|
fontSize: sizePx,
|
|
|
|
height: heightPx != null ? (heightPx / sizePx) : style.height,
|
|
|
|
letterSpacing: spacingPc != null ? sizePx * spacingPc * 0.01 : style.letterSpacing,
|
|
|
|
fontWeight: weight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@immutable
|
|
|
|
class _Times {
|
|
|
|
final Duration fast = Duration(milliseconds: 300);
|
|
|
|
final Duration med = Duration(milliseconds: 600);
|
|
|
|
final Duration slow = Duration(milliseconds: 900);
|
|
|
|
final Duration pageTransition = Duration(milliseconds: 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
@immutable
|
|
|
|
class _Corners {
|
|
|
|
late final double sm = 4;
|
|
|
|
late final double md = 8;
|
|
|
|
late final double lg = 32;
|
|
|
|
}
|
|
|
|
|
2022-10-07 11:28:15 -06:00
|
|
|
// TODO: add, @immutable when design is solidified
|
|
|
|
class _Sizes {
|
2022-10-27 10:25:13 -06:00
|
|
|
double get maxContentWidth1 => 800;
|
|
|
|
double get maxContentWidth2 => 600;
|
2022-11-14 11:59:45 -07:00
|
|
|
double get maxContentWidth3 => 500;
|
2022-11-29 11:34:15 -07:00
|
|
|
final Size minAppSize = Size(380, 675);
|
2022-10-07 11:28:15 -06:00
|
|
|
}
|
|
|
|
|
2022-08-29 20:38:28 -06:00
|
|
|
@immutable
|
|
|
|
class _Insets {
|
2022-10-24 15:42:27 -06:00
|
|
|
_Insets(this._scale);
|
|
|
|
final double _scale;
|
|
|
|
|
|
|
|
late final double xxs = 4 * _scale;
|
|
|
|
late final double xs = 8 * _scale;
|
|
|
|
late final double sm = 16 * _scale;
|
|
|
|
late final double md = 24 * _scale;
|
|
|
|
late final double lg = 32 * _scale;
|
|
|
|
late final double xl = 48 * _scale;
|
|
|
|
late final double xxl = 56 * _scale;
|
|
|
|
late final double offset = 80 * _scale;
|
2022-08-29 20:38:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
@immutable
|
|
|
|
class _Shadows {
|
2022-09-06 09:39:01 -06:00
|
|
|
final textSoft = [
|
|
|
|
Shadow(color: Colors.black.withOpacity(.25), offset: Offset(0, 2), blurRadius: 4),
|
|
|
|
];
|
2022-08-29 20:38:28 -06:00
|
|
|
final text = [
|
|
|
|
Shadow(color: Colors.black.withOpacity(.6), offset: Offset(0, 2), blurRadius: 2),
|
|
|
|
];
|
|
|
|
final textStrong = [
|
|
|
|
Shadow(color: Colors.black.withOpacity(.6), offset: Offset(0, 4), blurRadius: 6),
|
|
|
|
];
|
|
|
|
}
|