Skip to content

Commit

Permalink
docs: Additional Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Jan 17, 2023
1 parent 2c18fd3 commit 91ac4d6
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 46 deletions.
28 changes: 14 additions & 14 deletions packages/katana_theme/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ packages:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.4.2"
version: "8.4.3"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -285,33 +285,33 @@ packages:
source: hosted
version: "4.7.0"
katana:
dependency: "direct overridden"
dependency: transitive
description:
path: "../../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+1"
katana_theme:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.2.8"
version: "1.2.9"
katana_theme_annotation:
dependency: "direct overridden"
dependency: transitive
description:
path: "../../katana_theme_annotation"
relative: true
source: path
version: "1.2.5"
name: katana_theme_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.6"
katana_theme_builder:
dependency: "direct dev"
description:
path: "../../katana_theme_builder"
relative: true
source: path
version: "1.2.6"
version: "1.2.7"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -353,7 +353,7 @@ packages:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.0.4"
package_config:
dependency: transitive
description:
Expand Down Expand Up @@ -547,7 +547,7 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.0"
xml:
dependency: transitive
description:
Expand Down
14 changes: 7 additions & 7 deletions packages/katana_theme/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ packages:
katana:
dependency: "direct main"
description:
path: "../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+1"
katana_theme_annotation:
dependency: "direct main"
description:
path: "../katana_theme_annotation"
relative: true
source: path
version: "1.2.5"
name: katana_theme_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.6"
matcher:
dependency: transitive
description:
Expand Down
20 changes: 10 additions & 10 deletions packages/katana_theme_annotation/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ packages:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
version: "1.6.2"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -151,9 +151,9 @@ packages:
katana:
dependency: "direct main"
description:
path: "../katana"
relative: true
source: path
name: katana
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.10+1"
logging:
dependency: transitive
Expand Down Expand Up @@ -182,7 +182,7 @@ packages:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.0.4"
node_preamble:
dependency: transitive
description:
Expand Down Expand Up @@ -322,21 +322,21 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.22.1"
version: "1.22.2"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.17"
version: "0.4.18"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.21"
version: "0.4.22"
typed_data:
dependency: transitive
description:
Expand All @@ -357,7 +357,7 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "9.4.0"
version: "10.0.0"
watcher:
dependency: transitive
description:
Expand All @@ -371,7 +371,7 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.0"
webkit_inspection_protocol:
dependency: transitive
description:
Expand Down
7 changes: 7 additions & 0 deletions packages/katana_theme_builder/lib/common/extensions.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
part of katana_theme_builder;

/// Create an extension method.
///
/// Pass [assets] a node for assets, [fonts] a node for fonts, and [config] an asset config.
///
/// 拡張メソッドを作成します。
///
/// [assets]にアセット用のノード、[fonts]にフォント用のノード、[config]にアセットコンフィグを渡します。
List<Spec> extension(
List<AssetNode> assets,
List<FontNode> fonts,
Expand Down
24 changes: 24 additions & 0 deletions packages/katana_theme_builder/lib/value/asset_config.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
part of katana_theme_builder;

/// Config data for the asset.
///
/// [useSvg] to set whether to use SVG data.
///
/// アセット用のコンフィグデータ。
///
/// [useSvg]でSVGデータを利用するかを設定します。
class AssetConfig {
/// Config data for the asset.
///
/// [useSvg] to set whether to use SVG data.
///
/// アセット用のコンフィグデータ。
///
/// [useSvg]でSVGデータを利用するかを設定します。
const AssetConfig({required this.useSvg});

/// `true` if you use SVG data.
///
/// SVGデータを利用する場合`true`
final bool useSvg;

/// Get whether or not to use as Assets according to [type].
///
/// Returns `true` if used as Assets.
///
/// [type]に応じてAssetsとして利用するかどうかを取得します。
///
/// Assetsとして利用する場合`true`を返します。
bool checkEnabled(AssetValueType type) {
switch (type) {
case AssetValueType.svg:
Expand Down
29 changes: 29 additions & 0 deletions packages/katana_theme_builder/lib/value/asset_node.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
part of katana_theme_builder;

/// Nodes for assets.
///
/// アセット用のノード。
class AssetNode {
AssetNode._withNode({
required this.name,
Expand All @@ -12,12 +15,29 @@ class AssetNode {
required this.children,
}) : value = null;

/// Asset Data.
///
/// アセットデータ。
final AssetValue? value;

/// Path of the asset node.
///
/// アセットノードのパス。
final String path;

/// Asset Name.
///
/// アセットの名前。
final String name;

/// List of children of the asset.
///
/// アセットの子供の一覧。
final List<AssetNode> children;

/// Parses the list of [AssetNode] from [values] and [path].
///
/// [values][path]から[AssetNode]の一覧のパースします。
static List<AssetNode> parse(
Map<String, dynamic> values, [
String path = "",
Expand Down Expand Up @@ -46,6 +66,9 @@ class AssetNode {
return res;
}

/// Build methods to create `ImageProvider`.
///
/// `ImageProvider`を作成するためのメソッドをビルドします。
Method? buildProvider() {
if (value == null) {
return null;
Expand Down Expand Up @@ -94,6 +117,9 @@ class AssetNode {
}
}

/// Create an extension method by passing [config].
///
/// [config]を渡して拡張メソッドを作成します。
Method toExtensionSpec(AssetConfig config) {
return Method(
(m) => m
Expand All @@ -105,6 +131,9 @@ class AssetNode {
);
}

/// Create a class by passing [config].
///
/// [config]を渡してクラスを作成します。
List<Spec> toClassSpec(AssetConfig config) {
if (value != null) {
if (!config.checkEnabled(value!.type)) {
Expand Down
35 changes: 35 additions & 0 deletions packages/katana_theme_builder/lib/value/asset_value.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
part of katana_theme_builder;

/// Stored data for Asset.
///
/// Asset用の格納データ。
class AssetValue {
/// Stored data for Asset.
///
/// Asset用の格納データ。
AssetValue({
required this.path,
required this.type,
});

/// Path of the asset.
///
/// アセットのパス。
final String path;

/// Asset type.
///
/// アセットのタイプ。
final AssetValueType type;
}

Expand All @@ -31,10 +44,32 @@ AssetValueType _type(String path) {
return AssetValueType.text;
}

/// Asset type.
///
/// アセットタイプ。
enum AssetValueType {
/// Image.
///
/// 画像。
image,

/// SVG image.
///
/// SVG画像。
svg,

/// Text.
///
/// テキスト。
text,

/// Video.
///
/// ビデオ。
video,

/// Font data.
///
/// フォントデータ。
font,
}
18 changes: 18 additions & 0 deletions packages/katana_theme_builder/lib/value/font_node.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
part of katana_theme_builder;

/// Node data for fonts.
///
/// フォント用のノードデータ。
class FontNode {
/// Node data for fonts.
///
/// フォント用のノードデータ。
FontNode(this.value);

/// Font data.
///
/// フォントデータ。
final FontValue value;

/// Parses to a list of [FontNode] by passing [values].
///
/// [values]を渡して[FontNode]のリストにパースします。
static List<FontNode> parse(Map<String, dynamic> values) {
return values.values.map((e) => FontNode(e)).toList();
}

/// Create an extension method by passing [config].
///
/// [config]を渡して拡張メソッドを作成します。
Method toExtensionSpec(AssetConfig config) {
return Method(
(m) => m
Expand All @@ -20,6 +35,9 @@ class FontNode {
);
}

/// Pass [config] to create a text style.
///
/// [config]を渡してテキストスタイルを作成します。
Method toTextStyleSpec(AssetConfig config) {
return Method(
(m) => m
Expand Down
Loading

0 comments on commit 91ac4d6

Please sign in to comment.