-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from schultek/feat/flutter-multiview
Add flutter multi-view embedding support
- Loading branch information
Showing
107 changed files
with
2,114 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
examples/flutter_embedding/lib/components/flutter_app_container.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
import 'package:jaspr/jaspr.dart'; | ||
import 'package:jaspr_riverpod/jaspr_riverpod.dart'; | ||
|
||
@Import.onWeb('package:flutter_riverpod/flutter_riverpod.dart', show: [#UncontrolledProviderScope]) | ||
@Import.onWeb('../widgets/app.dart', show: [#MyApp]) | ||
import 'flutter_app_container.imports.dart' as flt; | ||
import 'flutter_target.dart'; | ||
import 'ripple_loader.dart'; | ||
|
||
class FlutterAppContainer extends StatelessComponent { | ||
const FlutterAppContainer({super.key}); | ||
|
||
@override | ||
Iterable<Component> build(BuildContext context) sync* { | ||
yield article([ | ||
div(id: 'flutter_target', [ | ||
RippleLoader(), | ||
]) | ||
]); | ||
yield FlutterTarget( | ||
loader: RippleLoader(), | ||
app: kIsWeb | ||
? flt.UncontrolledProviderScope( | ||
container: ProviderScope.containerOf(context), | ||
child: flt.MyApp(), | ||
) | ||
: null, | ||
); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/flutter_embedding/lib/components/flutter_app_container.imports.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// GENERATED FILE, DO NOT MODIFY | ||
// Generated with jaspr_builder | ||
|
||
export '../generated/imports/_web.dart' if (dart.library.io) '../generated/imports/_stubs.dart' | ||
show UncontrolledProviderScope, UncontrolledProviderScopeOrStubbed, MyApp, MyAppOrStubbed; |
22 changes: 0 additions & 22 deletions
22
examples/flutter_embedding/lib/components/flutter_app_container_web.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
examples/flutter_embedding/lib/components/flutter_target.imports.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// GENERATED FILE, DO NOT MODIFY | ||
// Generated with jaspr_builder | ||
|
||
export '../generated/imports/_web.dart' if (dart.library.io) '../generated/imports/_stubs.dart' | ||
show Widget, WidgetOrStubbed; |
11 changes: 11 additions & 0 deletions
11
examples/flutter_embedding/lib/generated/imports/_stubs.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// GENERATED FILE, DO NOT MODIFY | ||
// Generated with jaspr_builder | ||
|
||
// ignore_for_file: directives_ordering, non_constant_identifier_names | ||
|
||
dynamic Widget; | ||
typedef WidgetOrStubbed = dynamic; | ||
dynamic UncontrolledProviderScope; | ||
typedef UncontrolledProviderScopeOrStubbed = dynamic; | ||
dynamic MyApp; | ||
typedef MyAppOrStubbed = dynamic; |
17 changes: 17 additions & 0 deletions
17
examples/flutter_embedding/lib/generated/imports/_web.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// GENERATED FILE, DO NOT MODIFY | ||
// Generated with jaspr_builder | ||
|
||
// ignore_for_file: directives_ordering | ||
|
||
import 'package:flutter/widgets.dart' show Widget; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart' | ||
show UncontrolledProviderScope; | ||
import '../../../widgets/app.dart' show MyApp; | ||
export 'package:flutter/widgets.dart' show Widget; | ||
export 'package:flutter_riverpod/flutter_riverpod.dart' | ||
show UncontrolledProviderScope; | ||
export '../../../widgets/app.dart' show MyApp; | ||
|
||
typedef WidgetOrStubbed = Widget; | ||
typedef UncontrolledProviderScopeOrStubbed = UncontrolledProviderScope; | ||
typedef MyAppOrStubbed = MyApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{flutter_js}} | ||
{{flutter_build_config}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Files and directories created by pub. | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build output. | ||
/build/ | ||
|
||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter related | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
**/ios/Flutter/.last_build_id | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# flutter_multi_view | ||
|
||
A new jaspr project. | ||
|
||
## Running the project | ||
|
||
Run your project using `jaspr serve`. | ||
|
||
The development server will be available on `http://localhost:8080`. | ||
|
||
## Building the project | ||
|
||
Build your project using `jaspr build`. | ||
|
||
The output will be located inside the `build/jaspr/` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:flutter_lints/flutter.yaml | ||
|
||
analyzer: | ||
# Jaspr has a custom lint package 'jaspr_lints', which needs the 'custom_lint' analyzer plugin. | ||
# | ||
# Unfortunately, running 'dart analyze' does not pick up the custom lints. Instead, you need to | ||
# run a separate command for this: `jaspr analyze` | ||
plugins: | ||
- custom_lint | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import 'package:jaspr/jaspr.dart'; | ||
import 'package:jaspr_flutter_embed/jaspr_flutter_embed.dart'; | ||
|
||
import 'components/counter.dart'; | ||
import 'constants/theme.dart'; | ||
|
||
@client | ||
class App extends StatefulComponent { | ||
const App({super.key}); | ||
|
||
@override | ||
State<App> createState() => AppState(); | ||
} | ||
|
||
class AppState extends State<App> with ViewTransitionMixin<App> { | ||
List<String> counters = ['counter-1', 'counter-2']; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
FlutterEmbedView.preload(); | ||
} | ||
|
||
void addCounter() async { | ||
setStateWithViewTransition(() { | ||
counters.add('targeted-counter'); | ||
}, postTransition: () { | ||
counters[counters.length - 1] = 'counter-${counters.length}'; | ||
}); | ||
} | ||
|
||
void removeCounter() { | ||
setStateWithViewTransition(preTransition: () { | ||
counters[counters.length - 1] = 'targeted-counter'; | ||
}, () { | ||
counters.removeLast(); | ||
}); | ||
} | ||
|
||
@override | ||
Iterable<Component> build(BuildContext context) sync* { | ||
yield div(classes: 'main', [ | ||
img(src: 'images/logo.png', width: 80), | ||
div(classes: 'buttons', [ | ||
button( | ||
onClick: () { | ||
removeCounter(); | ||
}, | ||
[text('Less Counters')], | ||
), | ||
button( | ||
onClick: () { | ||
addCounter(); | ||
}, | ||
[text('More Counters')], | ||
), | ||
]), | ||
div(classes: 'counters', [ | ||
for (var name in counters) Counter(name: name), | ||
]), | ||
]); | ||
} | ||
|
||
@css | ||
static final styles = [ | ||
css('.main', [ | ||
css('&').flexbox(direction: FlexDirection.column, alignItems: AlignItems.center), | ||
css('.buttons', [ | ||
css('&').flexbox(direction: FlexDirection.row), | ||
css('button') | ||
.box(padding: EdgeInsets.all(8.px), border: Border.all(BorderSide.solid(color: primaryColor, width: 1.px))), | ||
css('button:first-child') | ||
.box(radius: BorderRadius.horizontal(left: Radius.circular(6.px)), margin: EdgeInsets.only(right: (-1).px)), | ||
css('button:last-child') | ||
.box(radius: BorderRadius.horizontal(right: Radius.circular(6.px)), margin: EdgeInsets.only(left: (-1).px)), | ||
]), | ||
css('.counters', [ | ||
css('&').flexbox( | ||
direction: FlexDirection.row, | ||
wrap: FlexWrap.wrap, | ||
justifyContent: JustifyContent.center, | ||
), | ||
]), | ||
]), | ||
]; | ||
} |
Oops, something went wrong.