Skip to content

Commit

Permalink
feat: Added MasamuneAdapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Feb 5, 2023
1 parent 0d24c7c commit 4c8d61a
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 41 deletions.
28 changes: 14 additions & 14 deletions packages/masamune/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ packages:
dependency: transitive
description:
name: katana_form
sha256: "29d02abf2a2961a1cec48efa0901b398e8a6ec9621e1f865a8346201398a913e"
sha256: "0a9cf858d76331765ee6ca03a0a7e1c4b927da9ea21eb9944a4ff4b7222df402"
url: "https://pub.dev"
source: hosted
version: "1.3.8"
version: "1.3.10"
katana_functions:
dependency: transitive
description:
Expand Down Expand Up @@ -473,18 +473,18 @@ packages:
dependency: transitive
description:
name: katana_model
sha256: "4d5db5f025bed98460e0deea908b56f10d65415a98ac58354f01baf85f2bb3c6"
sha256: aeabf0992fa9a35408f3fd10b6a9411d2f409eadb97d426164af7866eca27915
url: "https://pub.dev"
source: hosted
version: "1.5.8"
version: "1.5.9"
katana_prefs:
dependency: transitive
description:
name: katana_prefs
sha256: dd45a8481abebf128bf6cb539ed39b7252b76e50544046eaa6417160e03410d1
sha256: d67a1d185d72ebab7a21f78c71d16559c982034115266871cd13813914349dd9
url: "https://pub.dev"
source: hosted
version: "1.1.14"
version: "1.1.16"
katana_prefs_annotation:
dependency: transitive
description:
Expand All @@ -497,10 +497,10 @@ packages:
dependency: transitive
description:
name: katana_prefs_builder
sha256: "9180b29391a808cb7902f48769b1e4eb15f6b7f3d0ca48f3623dbac4e4b630ee"
sha256: "1876a45f1ce7f90d3f92d5bb8bf8f70861ad239371d9aa89f8d79d90c0d62807"
url: "https://pub.dev"
source: hosted
version: "1.1.17"
version: "1.1.19"
katana_router:
dependency: transitive
description:
Expand Down Expand Up @@ -603,22 +603,22 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.14"
version: "1.4.20"
masamune_annotation:
dependency: transitive
description:
name: masamune_annotation
sha256: "10366db8d1a6f8745b9b02bbce249b12d4e96dd11e6021c8756359974bf1f260"
sha256: deeab4150a3ceb2fac1005df4811112e68ad10ceada5457bccb602a289688def
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
masamune_builder:
dependency: "direct dev"
description:
path: "../../masamune_builder"
relative: true
source: path
version: "1.2.7"
version: "1.2.10"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -948,10 +948,10 @@ packages:
dependency: transitive
description:
name: tint
sha256: d856019547532d4ea24171f554b319081c004c37741e7946eae30cb09f24e1c7
sha256: "9652d9a589f4536d5e392cf790263d120474f15da3cf1bee7f1fdb31b4de5f46"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "2.0.1"
typed_data:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions packages/masamune/lib/masamune.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ part 'model/model.dart';
part 'prefs/prefs.dart';
part 'scoped/controller.dart';
part 'src/masamune_app.dart';
part 'src/masamune_adapter.dart';

part 'ui/grid_builder.dart';
part 'ui/list_builder.dart';
Expand Down
80 changes: 80 additions & 0 deletions packages/masamune/lib/src/masamune_adapter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
part of masamune;

/// Adapter for easily adding functions to Masamune Framework.
///
/// Setting [runZonedGuarded] to `true` allows wrapping [runApp] with [runZonedGuarded].
/// At that time, [onPreRunApp] can be used to execute the process before [runApp], and [onError] can be used to describe the process in case of an error.
///
/// You can set up observers to monitor transitions between pages at [navigatorObservers].
///
/// Widgets can be added during the build of [MasamuneApp] with [onBuildApp].
///
/// Masamune Frameworkに機能を手軽に追加するためのアダプター。
///
/// アプリ起動時と[MasamuneApp]に渡す処理を記述することができます。
///
/// [runZonedGuarded]`true`にすると[runApp][runZonedGuarded]でラッピングすることができます。
/// その際、[onPreRunApp][runApp]前の処理を実行することができ、[onError]でエラー時の処理を記述することができます。
///
/// [navigatorObservers]でページ間の遷移を監視するためのオブザーバーを設置することができます。
///
/// [onBuildApp][MasamuneApp]のビルド時にウィジェットを追加することが可能です。
abstract class MasamuneAdapter {
/// Adapter for easily adding functions to Masamune Framework.
///
/// Setting [runZonedGuarded] to `true` allows wrapping [runApp] with [runZonedGuarded].
/// At that time, [onPreRunApp] can be used to execute the process before [runApp], and [onError] can be used to describe the process in case of an error.
///
/// You can set up observers to monitor transitions between pages at [navigatorObservers].
///
/// Widgets can be added during the build of [MasamuneApp] with [onBuildApp].
///
/// Masamune Frameworkに機能を手軽に追加するためのアダプター。
///
/// アプリ起動時と[MasamuneApp]に渡す処理を記述することができます。
///
/// [runZonedGuarded]`true`にすると[runApp][runZonedGuarded]でラッピングすることができます。
/// その際、[onPreRunApp][runApp]前の処理を実行することができ、[onError]でエラー時の処理を記述することができます。
///
/// [navigatorObservers]でページ間の遷移を監視するためのオブザーバーを設置することができます。
///
/// [onBuildApp][MasamuneApp]のビルド時にウィジェットを追加することが可能です。
const MasamuneAdapter();

/// If you set this to `true`, you can wrap [runApp] with [runZonedGuarded].
///
/// これを`true`にした場合、[runApp][runZonedGuarded]でラッピングすることができます。
bool get runZonedGuarded;

/// Observers can be set up to monitor transitions between pages.
///
/// ページ間の遷移を監視するためのオブザーバーを設置することができます。
List<NavigatorObserver> get navigatorObservers;

/// Widgets can be added during the build of [MasamuneApp].
///
/// The widget generated in [MasamuneApp] is passed to [app].
///
/// Returning [Widget] will build the widget.
///
/// [MasamuneApp]のビルド時にウィジェットを追加することが可能です。
///
/// [app][MasamuneApp]内で生成されたウィジェットが渡されます。
///
/// [Widget]を返すとそのウィジェットがビルドされます。
Widget onBuildApp(BuildContext context, Widget app);

/// You can describe the process before [runApp].
///
/// [runApp]前の処理を記述することができます。
FutureOr<void>? onPreRunApp();

/// You can describe the process when [runZonedGuarded] is set to `true`.
///
/// The object in which the error occurred is passed to [error] and [stackTrace].
///
/// [runZonedGuarded]`true`にした場合の処理を記述することができます。
///
/// [error][stackTrace]にエラーが起きた際のオブジェクトが渡されます。
void onError(Object error, StackTrace stackTrace);
}

0 comments on commit 4c8d61a

Please sign in to comment.