-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fad6ab0
commit 5f61a1b
Showing
13 changed files
with
261 additions
and
186 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,10 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class HomePage extends StatelessWidget { | ||
const HomePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Placeholder(); | ||
} | ||
} |
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
96 changes: 0 additions & 96 deletions
96
example/command_hub/packages/core_module/lib/src/agent.dart
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
example/command_hub/packages/core_module/lib/src/command.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,58 @@ | ||
// ignore_for_file: public_member_api_docs, sort_constructors_first | ||
import 'dart:convert'; | ||
|
||
import 'symbol_icon.dart'; | ||
|
||
class Command { | ||
final String name; | ||
final SymbolIcon icon; | ||
final String prompt; | ||
|
||
Command({ | ||
required this.icon, | ||
required this.name, | ||
required this.prompt, | ||
}); | ||
|
||
@override | ||
bool operator ==(covariant Command other) { | ||
if (identical(this, other)) return true; | ||
|
||
return other.name == name && other.icon == icon && other.prompt == prompt; | ||
} | ||
|
||
@override | ||
int get hashCode => name.hashCode ^ icon.hashCode ^ prompt.hashCode; | ||
|
||
Map<String, dynamic> toMap() { | ||
return <String, dynamic>{ | ||
'name': name, | ||
'icon': icon.name, | ||
'prompt': prompt, | ||
}; | ||
} | ||
|
||
factory Command.fromMap(Map<String, dynamic> map) { | ||
return Command( | ||
name: map['name'] as String, | ||
icon: SymbolIcon.fromString(map['icon'] as String), | ||
prompt: map['prompt'] as String, | ||
); | ||
} | ||
|
||
String toJson() => json.encode(toMap()); | ||
|
||
factory Command.fromJson(String source) => Command.fromMap(json.decode(source) as Map<String, dynamic>); | ||
|
||
Command copyWith({ | ||
String? name, | ||
SymbolIcon? icon, | ||
String? prompt, | ||
}) { | ||
return Command( | ||
name: name ?? this.name, | ||
icon: icon ?? this.icon, | ||
prompt: prompt ?? this.prompt, | ||
); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
example/command_hub/packages/core_module/lib/src/pipeline.dart
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
example/command_hub/packages/core_module/lib/src/symbol_icon.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 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
enum SymbolIcon { | ||
home(Icons.home); | ||
|
||
// constructor | ||
final IconData data; | ||
const SymbolIcon(this.data); | ||
|
||
// adapters | ||
static SymbolIcon fromString(String value) { | ||
return SymbolIcon.values.firstWhere( | ||
(e) => e.name == value, | ||
orElse: () => SymbolIcon.home, | ||
); | ||
} | ||
} |
Oops, something went wrong.