Skip to content

Commit

Permalink
added new example
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Jul 18, 2024
1 parent 8c027f9 commit fad6ab0
Show file tree
Hide file tree
Showing 232 changed files with 10,563 additions and 15 deletions.
16 changes: 12 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

Expand All @@ -22,7 +19,18 @@
"cwd": "example/trivial_counter",
"request": "launch",
"type": "dart"
},
{
"name": "Command Desktop",
"cwd": "example/command_hub/apps/desktop",
"request": "launch",
"type": "dart"
},
{
"name": "Comamand Mobile",
"cwd": "example/command_hub/apps/mobile",
"request": "launch",
"type": "dart"
}

]
}
3 changes: 3 additions & 0 deletions example/command_hub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/pubspec_overrides.yaml
**/routes.g.dart
melos_command_hub.iml
43 changes: 43 additions & 0 deletions example/command_hub/apps/desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# 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
36 changes: 36 additions & 0 deletions example/command_hub/apps/desktop/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: linux
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: macos
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: windows
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
16 changes: 16 additions & 0 deletions example/command_hub/apps/desktop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# command_hub

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
28 changes: 28 additions & 0 deletions example/command_hub/apps/desktop/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:command_hub/routes.g.dart';
import 'package:core_module/core_module.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

Route routeBuilder(BuildContext context, RouteSettings settings) {
return PageRouteBuilder(
settings: settings,
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (_, a1, a2) => const CommandsPage(),
transitionsBuilder: (_, a1, a2, child) {
return FadeTransition(opacity: a1, child: child);
},
);
}

class CommandsPage extends StatefulWidget {
const CommandsPage({super.key});

@override
State<CommandsPage> createState() => _CommandsPageState();
}

class _CommandsPageState extends State<CommandsPage> {
@override
Widget build(BuildContext context) {
return CommandScaffold(
title: 'Home',
subtitle: 'View and create yours commands',
body: LayoutBuilder(builder: (context, constraints) {
double itemHeight = 100;
double itemWidth = 150;
int crossAxisCount = (constraints.maxWidth / itemWidth).floor();
final aspect = (constraints.maxWidth / crossAxisCount) / itemHeight;

return GridView.count(
crossAxisCount: crossAxisCount,
childAspectRatio: aspect,
children: [
CommandTile(
title: 'Command 1',
icon: Icons.ac_unit,
onLongPress: () {
Routefly.push(routePaths.home.editCommand);
},
),
CommandTile(
title: 'Command 2',
icon: Icons.access_alarm,
onLongPress: () {
Routefly.push(routePaths.home.editCommand);
},
),
],
);
}),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

Route routeBuilder(BuildContext context, RouteSettings settings) {
return PageRouteBuilder(
settings: settings,
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (_, a1, a2) => const ConfigPage(),
transitionsBuilder: (_, a1, a2, child) {
return FadeTransition(opacity: a1, child: child);
},
);
}

class ConfigPage extends StatelessWidget {
const ConfigPage({super.key});

@override
Widget build(BuildContext context) {
return const CommandScaffold(
title: 'Config',
subtitle: 'Configure your Command Hub',
body: Center(
child: Text('Config Page'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

class EditCommandPage extends StatefulWidget {
const EditCommandPage({super.key});

@override
State<EditCommandPage> createState() => _EditCommandPageState();
}

class _EditCommandPageState extends State<EditCommandPage> {
@override
Widget build(BuildContext context) {
return const CommandScaffold(
title: 'Edit Command',
subtitle: 'Edit your command',
body: Center(
child: Text('Edit Command Page'),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'package:core_module/core_module.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

import '../../../routes.g.dart';

class HomeLayout extends StatefulWidget {
const HomeLayout({super.key});

@override
State<HomeLayout> createState() => _HomeLayoutState();
}

class _HomeLayoutState extends State<HomeLayout> {
var selectedIndex = 0;

final _pagesTiles = const [
_PageTile('Home', Icons.home),
_PageTile('Settings', Icons.settings),
];

@override
Widget build(BuildContext context) {
return Material(
child: Row(
children: [
NavigationRail(
extended: true,
minExtendedWidth: 200,
useIndicator: true,
leading: const Padding(
padding: EdgeInsets.all(8.0),
child: Logo(),
),
trailing: Padding(
padding: const EdgeInsets.all(8.0),
child: FloatingActionButton.extended(
onPressed: () {},
icon: const Icon(Icons.add),
label: const Text('New Command'),
),
),
destinations: [
for (final tile in _pagesTiles)
NavigationRailDestination(
icon: Icon(tile.icon),
label: Text(tile.title),
),
],
selectedIndex: selectedIndex,
onDestinationSelected: (value) {
setState(() {
selectedIndex = value;
});

if (value == 0) {
Routefly.navigate(routePaths.home.commands);
} else if (value == 1) {
Routefly.navigate(routePaths.home.config);
}
},
),
const Expanded(
child: RouterOutlet(),
),
],
),
);
}
}

class _PageTile {
final String title;
final IconData icon;

const _PageTile(this.title, this.icon);
}
48 changes: 48 additions & 0 deletions example/command_hub/apps/desktop/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:core_module/core_module.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';

import 'routes.g.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Desktop Example',
themeMode: ThemeMode.light,
theme: ThemeData(
platform: TargetPlatform.macOS,
colorScheme: MaterialTheme.lightMediumContrastScheme(),
),
darkTheme: ThemeData(
platform: TargetPlatform.macOS,
colorScheme: MaterialTheme.darkMediumContrastScheme(),
brightness: Brightness.dark,
),
routerConfig: Routefly.routerConfig(
routes: routes,
initialPath: routePaths.home.commands,
// routeBuilder: (context, settings, child) {
// return PageRouteBuilder(
// settings: settings,
// pageBuilder: (context, _, __) {
// return child;
// },
// transitionsBuilder: (context, animation, secondaryAnimation, child) {
// return FadeTransition(
// opacity: animation,
// child: child,
// );
// },
// );
// },
),
);
}
}
Loading

0 comments on commit fad6ab0

Please sign in to comment.