feat(app): compose live Runs with deep links and reconnect retention
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../shell/adaptive_shell.dart';
|
||||
import '../shell/destination.dart';
|
||||
|
||||
/// The injectable application shell. Composition supplies the live feature
|
||||
/// bodies and, when it owns a route, the selected destination; widget tests
|
||||
/// can continue to pass a small map or no bodies at all.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({
|
||||
super.key,
|
||||
this.destinationBodies = const {},
|
||||
this.cupertino,
|
||||
this.destination,
|
||||
this.onDestinationSelected,
|
||||
}) : routerConfig = null;
|
||||
|
||||
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
||||
/// links use Flutter's multi-entry web history instead of a second, competing
|
||||
/// history implementation.
|
||||
const MyApp.router({
|
||||
super.key,
|
||||
required RouterConfig<Object> this.routerConfig,
|
||||
this.cupertino,
|
||||
}) : destinationBodies = const {},
|
||||
destination = null,
|
||||
onDestinationSelected = null;
|
||||
|
||||
final Map<AppDestination, WidgetBuilder> destinationBodies;
|
||||
final bool? cupertino;
|
||||
final AppDestination? destination;
|
||||
final ValueChanged<AppDestination>? onDestinationSelected;
|
||||
final RouterConfig<Object>? routerConfig;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final router = routerConfig;
|
||||
if (cupertino ?? _platformIsCupertino) {
|
||||
if (router != null) {
|
||||
return CupertinoApp.router(title: 'Pipelines', routerConfig: router);
|
||||
}
|
||||
return CupertinoApp(
|
||||
title: 'Pipelines',
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: destinationBodies,
|
||||
cupertino: true,
|
||||
destination: destination,
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (router != null) {
|
||||
return MaterialApp.router(
|
||||
title: 'Pipelines',
|
||||
theme: ThemeData(),
|
||||
darkTheme: ThemeData(brightness: Brightness.dark),
|
||||
themeMode: ThemeMode.system,
|
||||
routerConfig: router,
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
title: 'Pipelines',
|
||||
theme: ThemeData(),
|
||||
darkTheme: ThemeData(brightness: Brightness.dark),
|
||||
themeMode: ThemeMode.system,
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: destinationBodies,
|
||||
destination: destination,
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool get _platformIsCupertino =>
|
||||
defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.macOS;
|
||||
}
|
||||
Reference in New Issue
Block a user