Skip to content

Commit

Permalink
refactor: moving packages into the system folder
Browse files Browse the repository at this point in the history
feat: added sample features for counter, settings and the launchpad
  • Loading branch information
pavanpodila committed Mar 16, 2024
1 parent d33228b commit e1b3a74
Show file tree
Hide file tree
Showing 94 changed files with 175 additions and 33 deletions.
31 changes: 14 additions & 17 deletions apps/vyuh_demo/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void main() async {
initialLocation: '/',
features: [
developer.feature,
sample.featureDevLink,
sample.featureLauncher,
sample.featureCounter,
],
plugins: [
vc.ConsoleLoggerPlugin(),
Expand All @@ -26,26 +27,22 @@ void main() async {
return MaterialApp.router(
title: 'Vyuh Demo',
themeMode: mode,
theme: ThemeMode.light.theme,
darkTheme: ThemeMode.dark.theme,
theme: ThemeData.from(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.light,
)),
darkTheme: ThemeData.from(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurpleAccent,
brightness: Brightness.dark,
)),
routerConfig: platform.router,
);
},
);
}),
);
}

extension ThemeInfoProvider on ThemeMode {
String get name => switch (this) {
ThemeMode.system => 'System',
ThemeMode.light => 'Light',
ThemeMode.dark => 'Dark',
};

ThemeData get theme => switch (this) {
ThemeMode.system => ThemeData.fallback(useMaterial3: true),
ThemeMode.light => ThemeData.light(useMaterial3: true),
ThemeMode.dark => ThemeData.dark(useMaterial3: true)
};
}
6 changes: 3 additions & 3 deletions apps/vyuh_demo/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -526,21 +526,21 @@ packages:
vyuh_core:
dependency: "direct main"
description:
path: "../../packages/vyuh_core"
path: "../../packages/system/vyuh_core"
relative: true
source: path
version: "1.0.0-beta.1"
vyuh_extension_content:
dependency: "direct main"
description:
path: "../../packages/vyuh_extension_content"
path: "../../packages/system/vyuh_extension_content"
relative: true
source: path
version: "1.0.0-beta.1"
vyuh_feature_developer:
dependency: "direct main"
description:
path: "../../packages/vyuh_feature_developer"
path: "../../packages/system/vyuh_feature_developer"
relative: true
source: path
version: "1.0.0-beta.1"
Expand Down
61 changes: 61 additions & 0 deletions features/feature_sample/lib/feature_counter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:go_router/go_router.dart';
import 'package:mobx/mobx.dart';
import 'package:vyuh_core/vyuh_core.dart';

final featureCounter = FeatureDescriptor(
name: 'counter',
title: 'The classic Flutter counter',
description: 'A simple counter that tracks the number of button presses',
routes: () async {
return [
GoRoute(
path: '/counter',
builder: (context, state) {
return const _Counter();
}),
];
},
);

class _Counter extends StatefulWidget {
const _Counter();

@override
State<_Counter> createState() => _CounterState();
}

class _CounterState extends State<_Counter> {
final counter = 0.obs();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Counter')),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Number of Button presses',
textAlign: TextAlign.center,
),
Observer(
builder: (_) => Text(
'${counter.value}',
style: Theme.of(context)
.textTheme
.displayLarge
?.apply(fontFamily: 'Courier New', fontWeightDelta: 2),
textAlign: TextAlign.center,
)),
],
),
floatingActionButton: IconButton.filled(
icon: const Icon(Icons.add),
onPressed: () => runInAction(() => counter.value++),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:vyuh_core/vyuh_core.dart';

final featureDevLink = FeatureDescriptor(
name: 'devLink',
title: 'Link to /developer',
description: 'A simple feature that links to the /developer route',
final featureLauncher = FeatureDescriptor(
name: 'launcher',
title: 'A launchpad for all features',
description: 'Launchpad for features where the actual liftoff happens',
routes: () async {
return [
GoRoute(
Expand All @@ -26,7 +26,7 @@ class _LaunchPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Local Root')),
appBar: AppBar(title: const Text('Launchpad')),
body: Column(
children: [
ListTile(
Expand All @@ -35,7 +35,21 @@ class _LaunchPage extends StatelessWidget {
onTap: () => context.push('/developer'),
leading: const Icon(Icons.account_tree),
trailing: const Icon(Icons.chevron_right),
)
),
ListTile(
title: const Text('Counter'),
subtitle: const Text('The classic Flutter counter'),
onTap: () => context.push('/counter'),
leading: const Icon(Icons.add_circle_outlined),
trailing: const Icon(Icons.chevron_right),
),
ListTile(
title: const Text('Theme Settings'),
subtitle: const Text('Switch to Light / Dark mode'),
onTap: () => context.push('/settings'),
leading: const Icon(Icons.light_mode),
trailing: const Icon(Icons.chevron_right),
),
],
),
);
Expand Down
3 changes: 2 additions & 1 deletion features/feature_sample/lib/feature_sample.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library feature_sample;

export './feature.dart';
export './feature_counter.dart';
export './feature_launcher.dart';
56 changes: 56 additions & 0 deletions features/feature_sample/lib/feature_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:go_router/go_router.dart';
import 'package:mobx/mobx.dart';
import 'package:vyuh_core/vyuh_core.dart';

final featureCounter = FeatureDescriptor(
name: 'settings',
title: 'Settings',
description: 'Settings to adjust the light/dark mode and other features',
routes: () async {
return [
GoRoute(
path: '/settings',
builder: (context, state) {
return const _Settings();
}),
];
},
);

class _Settings extends StatefulWidget {
const _Settings();

@override
State<_Settings> createState() => _SettingsState();
}

class _SettingsState extends State<_Settings> {
@override
Widget build(BuildContext context) {
final service = vyuh.di.get<ThemeService>();

return Scaffold(
appBar: AppBar(title: const Text('Settings')),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Theme',
textAlign: TextAlign.center,
),
Observer(
builder: (_) => Switch(
value: service.currentMode.value == ThemeMode.light,
onChanged: (value) {
runInAction(() => service.currentMode.value =
value ? ThemeMode.light : ThemeMode.dark);
},
)),
],
),
);
}
}
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: vyuh
repository: https://github.com/vyuh-tech/vyuh

packages:
- packages/{sanity,}/*
- packages/{sanity,system,}/*
- features/*
- apps/*

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,32 @@ class _FallbackRouteNotifier extends StatelessWidget {
Widget build(BuildContext context) {
if (kDebugMode) {
return Scaffold(
appBar: AppBar(
title: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.warning_amber,
color: Colors.redAccent,
),
SizedBox(width: 8),
Text('Missing Route'),
],
),
),
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: child),
const Icon(
Icons.warning,
color: Colors.red,
),
Text(
'Using a fallback Page for "$path"',
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.labelMedium
?.apply(color: Colors.redAccent),
),
Expanded(child: child),
],
),
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e1b3a74

Please sign in to comment.