Preserve Flutter mirror-os codebase
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mirror_protocol/mirror_protocol.dart';
|
||||
import 'package:mirror_ui/mirror_ui.dart';
|
||||
import 'providers/display_state_provider.dart';
|
||||
import 'screens/dashboard_screen.dart';
|
||||
import 'screens/workout_screen.dart';
|
||||
import 'screens/media_screen.dart';
|
||||
import 'screens/standby_screen.dart';
|
||||
|
||||
class MirrorDisplayApp extends ConsumerWidget {
|
||||
const MirrorDisplayApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final activeScreen = ref.watch(
|
||||
displayStateProvider.select((s) => s.activeScreen),
|
||||
);
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Mirror OS',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: MirrorTheme.dark,
|
||||
home: Scaffold(
|
||||
body: AnimatedSwitcher(
|
||||
duration: MirrorAnimations.screenTransitionDuration,
|
||||
transitionBuilder: MirrorAnimations.screenTransitionBuilder,
|
||||
child: _buildScreen(activeScreen),
|
||||
),
|
||||
),
|
||||
shortcuts: {
|
||||
LogicalKeySet(LogicalKeyboardKey.escape): const _ExitIntent(),
|
||||
},
|
||||
actions: {
|
||||
_ExitIntent: CallbackAction<_ExitIntent>(
|
||||
onInvoke: (_) => SystemNavigator.pop(),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScreen(ScreenType screen) => switch (screen) {
|
||||
ScreenType.dashboard => const DashboardScreen(key: ValueKey('dashboard')),
|
||||
ScreenType.workout => const WorkoutScreen(key: ValueKey('workout')),
|
||||
ScreenType.media => const MediaScreen(key: ValueKey('media')),
|
||||
ScreenType.standby => const StandbyScreen(key: ValueKey('standby')),
|
||||
};
|
||||
}
|
||||
|
||||
class _ExitIntent extends Intent {
|
||||
const _ExitIntent();
|
||||
}
|
||||
Reference in New Issue
Block a user