Skip to content

Commit

Permalink
Added fontFamily in MiraiTheme data with example theme assets
Browse files Browse the repository at this point in the history
  • Loading branch information
i-asimkhan committed Jul 25, 2023
1 parent 0ba620b commit 0b20cf1
Show file tree
Hide file tree
Showing 33 changed files with 207 additions and 14 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
98 changes: 98 additions & 0 deletions examples/mirai_gallery/assets/fonts/Lisu_Bosa/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Copyright (c) 1998-2019 David Morse (original regular)
with Reserved Font Name "LisuTzimu".
Copyright (c) 2019-2023 SIL International (regular revisions, bold, italic, bold italic)
with Reserved Font Name "Bosa".
Copyright (c) 2014-2019 Adobe (http://www.adobe.com/) (Latin glyphs)
with Reserved Font Name "Source".

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
1 change: 1 addition & 0 deletions examples/mirai_gallery/assets/json/example_dark_theme.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"brightness": "dark",
"disabledColor": "#60FFFFFF",
"fontFamily": "Handjet",
"colorScheme": {
"brightness": "dark",
"primary": "#CCBDFA",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"brightness": "light",
"disabledColor": "#60FEF7FF",
"fontFamily": "LisuBosa",
"colorScheme": {
"brightness": "light",
"primary": "#6750a4",
Expand Down
16 changes: 8 additions & 8 deletions examples/mirai_gallery/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ packages:
dependency: transitive
description:
name: dio
sha256: "347d56c26d63519552ef9a569f2a593dda99a81fdbdff13c584b7197cfe05059"
sha256: "3866d67f93523161b643187af65f5ac08bc991a5bcdaf41a2d587fe4ccb49993"
url: "https://pub.dev"
source: hosted
version: "5.1.2"
version: "5.3.0"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -319,10 +319,10 @@ packages:
dependency: "direct main"
description:
name: json_annotation
sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
url: "https://pub.dev"
source: hosted
version: "4.8.0"
version: "4.8.1"
json_serializable:
dependency: "direct dev"
description:
Expand All @@ -343,10 +343,10 @@ packages:
dependency: transitive
description:
name: logger
sha256: db2ff852ed77090ba9f62d3611e4208a3d11dfa35991a81ae724c113fcb3e3f7
sha256: "7ad7215c15420a102ec687bb320a7312afd449bac63bfb1c60d9787c27b9767f"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.0"
logging:
dependency: transitive
description:
Expand Down Expand Up @@ -393,7 +393,7 @@ packages:
path: "../../packages/mirai"
relative: true
source: path
version: "0.2.0"
version: "0.4.0"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -593,4 +593,4 @@ packages:
version: "3.1.1"
sdks:
dart: ">=3.0.0 <4.0.0"
flutter: ">=1.17.0"
flutter: ">=1.17.0"
31 changes: 31 additions & 0 deletions examples/mirai_gallery/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,34 @@ flutter:
assets:
- assets/images/
- assets/json/
fonts:
- family: Raleway
fonts:
- asset: assets/fonts/Lisu_Bosa/LisuBosa-Black.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-BlackItalic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-Bold.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-BoldItalic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-ExtraBold.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-ExtraBoldItalic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-ExtraLight.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-ExtraLightItalic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-Italic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-Light.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-LightItalic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-Medium.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-MediumItalic.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-Regular.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-SemiBold.ttf
- asset: assets/fonts/Lisu_Bosa/LisuBosa-SemiBoldItalic.ttf

- family: Handjet
fonts:
- asset: assets/fonts/Handjet/Handjet-Black.ttf
- asset: assets/fonts/Handjet/Handjet-Bold.ttf
- asset: assets/fonts/Handjet/Handjet-ExtraBold.ttf
- asset: assets/fonts/Handjet/Handjet-ExtraLight.ttf
- asset: assets/fonts/Handjet/Handjet-Light.ttf
- asset: assets/fonts/Handjet/Handjet-Medium.ttf
- asset: assets/fonts/Handjet/Handjet-Regular.ttf
- asset: assets/fonts/Handjet/Handjet-SemiBold.ttf
- asset: assets/fonts/Handjet/Handjet-Thin.ttf
4 changes: 4 additions & 0 deletions packages/mirai/lib/src/parsers/mirai_theme/mirai_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class MiraiTheme with _$MiraiTheme {
String? shadowColor,
String? splashColor,
String? unselectedWidgetColor,
String? fontFamily,
@Default([]) List<String> fontFamilyFallback,
MiraiAppBarTheme? appBarTheme,
MiraiButtonStyle? elevatedButtonTheme,
MiraiButtonStyle? outlinedButtonTheme,
Expand Down Expand Up @@ -88,6 +90,8 @@ extension MiraiThemeParser on MiraiTheme {
shadowColor: shadowColor.toColor,
splashColor: splashColor.toColor,
unselectedWidgetColor: unselectedWidgetColor.toColor,
fontFamily: fontFamily,
fontFamilyFallback: fontFamilyFallback,
primarySwatch: primarySwatch?.parse,
appBarTheme: appBarTheme?.parse,
elevatedButtonTheme:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ mixin _$MiraiTheme {
String? get shadowColor => throw _privateConstructorUsedError;
String? get splashColor => throw _privateConstructorUsedError;
String? get unselectedWidgetColor => throw _privateConstructorUsedError;
String? get fontFamily => throw _privateConstructorUsedError;
List<String> get fontFamilyFallback => throw _privateConstructorUsedError;
MiraiAppBarTheme? get appBarTheme => throw _privateConstructorUsedError;
MiraiButtonStyle? get elevatedButtonTheme =>
throw _privateConstructorUsedError;
Expand Down Expand Up @@ -110,6 +112,8 @@ abstract class $MiraiThemeCopyWith<$Res> {
String? shadowColor,
String? splashColor,
String? unselectedWidgetColor,
String? fontFamily,
List<String> fontFamilyFallback,
MiraiAppBarTheme? appBarTheme,
MiraiButtonStyle? elevatedButtonTheme,
MiraiButtonStyle? outlinedButtonTheme,
Expand Down Expand Up @@ -187,6 +191,8 @@ class _$MiraiThemeCopyWithImpl<$Res, $Val extends MiraiTheme>
Object? shadowColor = freezed,
Object? splashColor = freezed,
Object? unselectedWidgetColor = freezed,
Object? fontFamily = freezed,
Object? fontFamilyFallback = null,
Object? appBarTheme = freezed,
Object? elevatedButtonTheme = freezed,
Object? outlinedButtonTheme = freezed,
Expand Down Expand Up @@ -305,6 +311,14 @@ class _$MiraiThemeCopyWithImpl<$Res, $Val extends MiraiTheme>
? _value.unselectedWidgetColor
: unselectedWidgetColor // ignore: cast_nullable_to_non_nullable
as String?,
fontFamily: freezed == fontFamily
? _value.fontFamily
: fontFamily // ignore: cast_nullable_to_non_nullable
as String?,
fontFamilyFallback: null == fontFamilyFallback
? _value.fontFamilyFallback
: fontFamilyFallback // ignore: cast_nullable_to_non_nullable
as List<String>,
appBarTheme: freezed == appBarTheme
? _value.appBarTheme
: appBarTheme // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -645,6 +659,8 @@ abstract class _$$_MiraiThemeCopyWith<$Res>
String? shadowColor,
String? splashColor,
String? unselectedWidgetColor,
String? fontFamily,
List<String> fontFamilyFallback,
MiraiAppBarTheme? appBarTheme,
MiraiButtonStyle? elevatedButtonTheme,
MiraiButtonStyle? outlinedButtonTheme,
Expand Down Expand Up @@ -739,6 +755,8 @@ class __$$_MiraiThemeCopyWithImpl<$Res>
Object? shadowColor = freezed,
Object? splashColor = freezed,
Object? unselectedWidgetColor = freezed,
Object? fontFamily = freezed,
Object? fontFamilyFallback = null,
Object? appBarTheme = freezed,
Object? elevatedButtonTheme = freezed,
Object? outlinedButtonTheme = freezed,
Expand Down Expand Up @@ -857,6 +875,14 @@ class __$$_MiraiThemeCopyWithImpl<$Res>
? _value.unselectedWidgetColor
: unselectedWidgetColor // ignore: cast_nullable_to_non_nullable
as String?,
fontFamily: freezed == fontFamily
? _value.fontFamily
: fontFamily // ignore: cast_nullable_to_non_nullable
as String?,
fontFamilyFallback: null == fontFamilyFallback
? _value._fontFamilyFallback
: fontFamilyFallback // ignore: cast_nullable_to_non_nullable
as List<String>,
appBarTheme: freezed == appBarTheme
? _value.appBarTheme
: appBarTheme // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -954,6 +980,8 @@ class _$_MiraiTheme implements _MiraiTheme {
this.shadowColor,
this.splashColor,
this.unselectedWidgetColor,
this.fontFamily,
final List<String> fontFamilyFallback = const [],
this.appBarTheme,
this.elevatedButtonTheme,
this.outlinedButtonTheme,
Expand All @@ -969,7 +997,8 @@ class _$_MiraiTheme implements _MiraiTheme {
this.cardTheme,
this.listTileTheme,
this.navigationBarTheme,
this.tabBarTheme});
this.tabBarTheme})
: _fontFamilyFallback = fontFamilyFallback;

factory _$_MiraiTheme.fromJson(Map<String, dynamic> json) =>
_$$_MiraiThemeFromJson(json);
Expand Down Expand Up @@ -1024,6 +1053,18 @@ class _$_MiraiTheme implements _MiraiTheme {
final String? splashColor;
@override
final String? unselectedWidgetColor;
@override
final String? fontFamily;
final List<String> _fontFamilyFallback;
@override
@JsonKey()
List<String> get fontFamilyFallback {
if (_fontFamilyFallback is EqualUnmodifiableListView)
return _fontFamilyFallback;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_fontFamilyFallback);
}

@override
final MiraiAppBarTheme? appBarTheme;
@override
Expand Down Expand Up @@ -1059,7 +1100,7 @@ class _$_MiraiTheme implements _MiraiTheme {

@override
String toString() {
return 'MiraiTheme(applyElevationOverlayColor: $applyElevationOverlayColor, inputDecorationTheme: $inputDecorationTheme, useMaterial3: $useMaterial3, brightness: $brightness, canvasColor: $canvasColor, cardColor: $cardColor, colorScheme: $colorScheme, colorSchemeSeed: $colorSchemeSeed, dialogBackgroundColor: $dialogBackgroundColor, disabledColor: $disabledColor, dividerColor: $dividerColor, focusColor: $focusColor, highlightColor: $highlightColor, hintColor: $hintColor, hoverColor: $hoverColor, indicatorColor: $indicatorColor, primaryColor: $primaryColor, primaryColorDark: $primaryColorDark, primaryColorLight: $primaryColorLight, primarySwatch: $primarySwatch, scaffoldBackgroundColor: $scaffoldBackgroundColor, secondaryHeaderColor: $secondaryHeaderColor, shadowColor: $shadowColor, splashColor: $splashColor, unselectedWidgetColor: $unselectedWidgetColor, appBarTheme: $appBarTheme, elevatedButtonTheme: $elevatedButtonTheme, outlinedButtonTheme: $outlinedButtonTheme, iconButtonTheme: $iconButtonTheme, iconTheme: $iconTheme, primaryIconTheme: $primaryIconTheme, dialogTheme: $dialogTheme, floatingActionButtonTheme: $floatingActionButtonTheme, textButtonTheme: $textButtonTheme, bottomAppBarTheme: $bottomAppBarTheme, bottomNavigationBarTheme: $bottomNavigationBarTheme, bottomSheetTheme: $bottomSheetTheme, cardTheme: $cardTheme, listTileTheme: $listTileTheme, navigationBarTheme: $navigationBarTheme, tabBarTheme: $tabBarTheme)';
return 'MiraiTheme(applyElevationOverlayColor: $applyElevationOverlayColor, inputDecorationTheme: $inputDecorationTheme, useMaterial3: $useMaterial3, brightness: $brightness, canvasColor: $canvasColor, cardColor: $cardColor, colorScheme: $colorScheme, colorSchemeSeed: $colorSchemeSeed, dialogBackgroundColor: $dialogBackgroundColor, disabledColor: $disabledColor, dividerColor: $dividerColor, focusColor: $focusColor, highlightColor: $highlightColor, hintColor: $hintColor, hoverColor: $hoverColor, indicatorColor: $indicatorColor, primaryColor: $primaryColor, primaryColorDark: $primaryColorDark, primaryColorLight: $primaryColorLight, primarySwatch: $primarySwatch, scaffoldBackgroundColor: $scaffoldBackgroundColor, secondaryHeaderColor: $secondaryHeaderColor, shadowColor: $shadowColor, splashColor: $splashColor, unselectedWidgetColor: $unselectedWidgetColor, fontFamily: $fontFamily, fontFamilyFallback: $fontFamilyFallback, appBarTheme: $appBarTheme, elevatedButtonTheme: $elevatedButtonTheme, outlinedButtonTheme: $outlinedButtonTheme, iconButtonTheme: $iconButtonTheme, iconTheme: $iconTheme, primaryIconTheme: $primaryIconTheme, dialogTheme: $dialogTheme, floatingActionButtonTheme: $floatingActionButtonTheme, textButtonTheme: $textButtonTheme, bottomAppBarTheme: $bottomAppBarTheme, bottomNavigationBarTheme: $bottomNavigationBarTheme, bottomSheetTheme: $bottomSheetTheme, cardTheme: $cardTheme, listTileTheme: $listTileTheme, navigationBarTheme: $navigationBarTheme, tabBarTheme: $tabBarTheme)';
}

@override
Expand Down Expand Up @@ -1118,6 +1159,10 @@ class _$_MiraiTheme implements _MiraiTheme {
other.splashColor == splashColor) &&
(identical(other.unselectedWidgetColor, unselectedWidgetColor) ||
other.unselectedWidgetColor == unselectedWidgetColor) &&
(identical(other.fontFamily, fontFamily) ||
other.fontFamily == fontFamily) &&
const DeepCollectionEquality()
.equals(other._fontFamilyFallback, _fontFamilyFallback) &&
(identical(other.appBarTheme, appBarTheme) ||
other.appBarTheme == appBarTheme) &&
(identical(other.elevatedButtonTheme, elevatedButtonTheme) ||
Expand All @@ -1128,10 +1173,8 @@ class _$_MiraiTheme implements _MiraiTheme {
other.iconButtonTheme == iconButtonTheme) &&
(identical(other.iconTheme, iconTheme) ||
other.iconTheme == iconTheme) &&
(identical(other.primaryIconTheme, primaryIconTheme) ||
other.primaryIconTheme == primaryIconTheme) &&
(identical(other.dialogTheme, dialogTheme) ||
other.dialogTheme == dialogTheme) &&
(identical(other.primaryIconTheme, primaryIconTheme) || other.primaryIconTheme == primaryIconTheme) &&
(identical(other.dialogTheme, dialogTheme) || other.dialogTheme == dialogTheme) &&
(identical(other.floatingActionButtonTheme, floatingActionButtonTheme) || other.floatingActionButtonTheme == floatingActionButtonTheme) &&
(identical(other.textButtonTheme, textButtonTheme) || other.textButtonTheme == textButtonTheme) &&
(identical(other.bottomAppBarTheme, bottomAppBarTheme) || other.bottomAppBarTheme == bottomAppBarTheme) &&
Expand Down Expand Up @@ -1172,6 +1215,8 @@ class _$_MiraiTheme implements _MiraiTheme {
shadowColor,
splashColor,
unselectedWidgetColor,
fontFamily,
const DeepCollectionEquality().hash(_fontFamilyFallback),
appBarTheme,
elevatedButtonTheme,
outlinedButtonTheme,
Expand Down Expand Up @@ -1231,6 +1276,8 @@ abstract class _MiraiTheme implements MiraiTheme {
final String? shadowColor,
final String? splashColor,
final String? unselectedWidgetColor,
final String? fontFamily,
final List<String> fontFamilyFallback,
final MiraiAppBarTheme? appBarTheme,
final MiraiButtonStyle? elevatedButtonTheme,
final MiraiButtonStyle? outlinedButtonTheme,
Expand Down Expand Up @@ -1302,6 +1349,10 @@ abstract class _MiraiTheme implements MiraiTheme {
@override
String? get unselectedWidgetColor;
@override
String? get fontFamily;
@override
List<String> get fontFamilyFallback;
@override
MiraiAppBarTheme? get appBarTheme;
@override
MiraiButtonStyle? get elevatedButtonTheme;
Expand Down
Loading

0 comments on commit 0b20cf1

Please sign in to comment.