frap 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/frap.rb +3 -2
  4. data/lib/frap/{generators → commands}/generate.rb +2 -3
  5. data/lib/frap/create_app.rb +16 -4
  6. data/lib/frap/create_base.rb +2 -0
  7. data/lib/frap/create_resource.rb +62 -0
  8. data/lib/frap/generators/config.rb +0 -3
  9. data/lib/frap/generators/flutter_config.rb +33 -11
  10. data/lib/frap/generators/flutter_resource.rb +57 -0
  11. data/lib/frap/generators/templates/dart/main.dart.erb +2 -2
  12. data/lib/frap/generators/templates/dart/src/animations/slide_right_route.dart.erb +23 -0
  13. data/lib/frap/generators/templates/dart/src/app.dart.erb +26 -0
  14. data/lib/frap/generators/templates/dart/src/config/router.dart.erb +14 -0
  15. data/lib/frap/generators/templates/dart/src/constants/pages_list.dart.erb +13 -0
  16. data/lib/frap/generators/templates/dart/src/constants/routing.dart.erb +1 -0
  17. data/lib/frap/generators/templates/dart/src/screens/base.dart.erb +23 -0
  18. data/lib/frap/generators/templates/dart/src/screens/undefined_route_screen.dart.erb +15 -0
  19. data/lib/frap/generators/templates/dart/src/widgets/base_app_bar.dart.erb +23 -0
  20. data/lib/frap/generators/templates/dart/src/widgets/popup_menu_widget.dart.erb +30 -0
  21. data/lib/frap/version.rb +1 -1
  22. metadata +15 -10
  23. data/lib/frap/generators/resource.rb +0 -42
  24. data/lib/frap/generators/templates/dart/src/app_bloc.dart.erb +0 -9
  25. data/lib/frap/generators/templates/dart/src/app_module.dart.erb +0 -19
  26. data/lib/frap/generators/templates/dart/src/app_widget.dart.erb +0 -15
  27. data/lib/frap/generators/templates/dart/src/home/home_bloc.dart.erb +0 -9
  28. data/lib/frap/generators/templates/dart/src/home/home_module.dart.erb +0 -19
  29. data/lib/frap/generators/templates/dart/src/home/home_page.dart.erb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c9b0b37bc3db97c0fa4da096081a9172a2a4579eb185ea1b3a3613e2eec9e53
4
- data.tar.gz: 5c701bc7b28b449fa300f4c3449d07bda9b530983ae2d67637cb3b1891feb8d9
3
+ metadata.gz: 0a94c44eaae2cb515d4ae619672a6e2eed5d3e352c9ccceb60e49bc6123f2d2b
4
+ data.tar.gz: 8e3f7a0d93b24ac0bb3ffdb5b2963cbb09e2c83c26e33d16970b88f194cc382b
5
5
  SHA512:
6
- metadata.gz: 99fcc47f280d953775d23f796ebc76c19196b2c21bdf183860854310f5ff188056e53599bdd4f6c4c239592ebcb5db9a24227c3d7c5500f79adc7b19205beb02
7
- data.tar.gz: 1407e786731d16af8f5b8d9b2ebb3f9dfcbd182e1b29cfacc4e0d856b2189f766c9433e51b52dac2786dfd9ab067f7aaa02225ad3636f9c5dfdc34023e86321e
6
+ metadata.gz: e955d2a12647e5ba589f6d88baa5aa68c1105d4cb3618836ec9e60299286fede785f4d0fb190c47d516f4295a36409c6937e70e606ebebdb6593ce0ef706f96a
7
+ data.tar.gz: ad972c11753fa6ecbaa24cb81c147d657650356a615909b6dd254678108daec5182643aafb23c596a50f9964f2738fd745f7afcd263eaf9428d9360b31b1d8c9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frap (0.1.1)
4
+ frap (0.2.0)
5
5
  thor (~> 0.20.3)
6
6
 
7
7
  GEM
@@ -1,6 +1,7 @@
1
1
  require 'frap/version'
2
2
  require 'frap/create_app'
3
- require 'frap/generators/generate'
3
+ require 'frap/create_resource'
4
+ require 'frap/commands/generate'
4
5
  require 'frap/generators/config'
5
6
  require 'frap/generators/flutter_config'
6
7
  require 'thor'
@@ -30,6 +31,6 @@ module Frap
30
31
  Generate all the boiler plate code such as controllers, pages and blocks for Rails and Flutter.
31
32
  run `frap g help` to see a list of existing generators
32
33
  LONGDESC
33
- subcommand 'generate', Frap::Generators::Generate
34
+ subcommand 'generate', Frap::Commands::Generate
34
35
  end
35
36
  end
@@ -1,8 +1,7 @@
1
1
  require 'thor'
2
- require 'frap/generators/resource'
3
2
 
4
3
  module Frap
5
- module Generators
4
+ module Commands
6
5
  class Generate < Thor
7
6
  desc 'resource NAME', 'generate a resource'
8
7
  method_option :rails, type: :boolean, aliases: :r, default: true
@@ -10,7 +9,7 @@ module Frap
10
9
  method_option :attributes, type: :hash, aliases: :a
11
10
 
12
11
  def resource(name)
13
- Frap::Generators::Resource.new(name, options).create_resource
12
+ Frap::CreateResource.new(name, options).create_resource
14
13
  end
15
14
  end
16
15
  end
@@ -1,6 +1,3 @@
1
- require 'thor'
2
- require 'frap/generators/config'
3
-
4
1
  module Frap
5
2
  class CreateApp
6
3
  attr_accessor :name
@@ -60,8 +57,23 @@ module Frap
60
57
  end
61
58
 
62
59
  def show_completed_notes
63
- shell.say(shell_text('DONE'), :green)
60
+ shell.say(shell_text('YAY! App setup complete!'), :green)
64
61
  shell.say('TODO: Install your favourite Rails Testing library', :yellow)
62
+ shell.say(shell_text(''), :green)
63
+
64
+ shell.say('Generate Some resources:', :yellow)
65
+ shell.say("cd #{working_dir}", :green)
66
+ shell.say('frap generate resource user --attributes name:string age:integer', :green)
67
+
68
+ shell.say('Start the rails serve:', :yellow)
69
+ shell.say("cd #{working_dir}/#{server_name}", :green)
70
+ shell.say("rails s", :green)
71
+
72
+ shell.say('Start the Flutter App:', :yellow)
73
+ shell.say("cd #{working_dir}/#{ui_name}", :green)
74
+ shell.say("flutter run", :green)
75
+
76
+ shell.say(shell_text('========================'), :green)
65
77
  end
66
78
 
67
79
  def server_name
@@ -0,0 +1,2 @@
1
+ class CreateBase
2
+ end
@@ -0,0 +1,62 @@
1
+ require 'yaml'
2
+
3
+ module Frap
4
+ class CreateResource
5
+ attr_accessor :name, :attributes, :options
6
+
7
+ def initialize(name, options)
8
+ @name = name
9
+ @options = options
10
+ end
11
+
12
+ def create_resource
13
+ generate_rails_resource if options['rails']
14
+ generate_flutter_resource if options['flutter']
15
+ end
16
+
17
+ private
18
+
19
+ def generate_rails_resource
20
+ Dir.chdir("#{working_dir}/#{rails_app}")
21
+
22
+ system("rails generate resource #{name} #{fields}")
23
+ end
24
+
25
+ def generate_flutter_resource
26
+ Dir.chdir("#{working_dir}/#{flutter_app}")
27
+
28
+ puts "TODO: frap g flutter resource #{name} #{fields}"
29
+ end
30
+
31
+ def fields
32
+ @fields ||= build_fields
33
+ end
34
+
35
+ def build_fields
36
+ return unless options[:attributes]
37
+
38
+ fields_string = ''
39
+ options[:attributes].each { |k, v| fields_string << "#{k}:#{v} " }
40
+
41
+ return fields_string
42
+ end
43
+
44
+ private
45
+
46
+ def working_dir
47
+ @working_dir ||= Dir.pwd
48
+ end
49
+
50
+ def config
51
+ @config ||= YAML.load(File.read('config.yml'))
52
+ end
53
+
54
+ def flutter_app
55
+ config['flutter_app']
56
+ end
57
+
58
+ def rails_app
59
+ config['rails_app']
60
+ end
61
+ end
62
+ end
@@ -1,6 +1,3 @@
1
- require 'thor'
2
- require 'thor/group'
3
-
4
1
  module Frap
5
2
  module Generators
6
3
  class Config < Thor::Group
@@ -1,7 +1,3 @@
1
-
2
- require 'thor'
3
- require 'thor/group'
4
-
5
1
  module Frap
6
2
  module Generators
7
3
  class FlutterConfig < Thor::Group
@@ -22,18 +18,33 @@ module Frap
22
18
  end
23
19
 
24
20
  def create_directories
25
- empty_directory("#{lib_directory}/src/home")
21
+ empty_directory("#{lib_directory}/src/animations")
22
+ empty_directory("#{lib_directory}/src/config")
23
+ empty_directory("#{lib_directory}/src/constants")
24
+ empty_directory("#{lib_directory}/src/screens")
25
+ empty_directory("#{lib_directory}/src/widgets")
26
26
  invoke :create_files
27
27
  end
28
28
 
29
29
  def create_files
30
30
  template('main.dart.erb', "#{lib_directory}/main.dart")
31
- template('src/app_bloc.dart.erb', "#{src_directory}/app_bloc.dart")
32
- template('src/app_module.dart.erb', "#{src_directory}/app_module.dart")
33
- template('src/app_widget.dart.erb', "#{src_directory}/app_widget.dart")
34
- template('src/home/home_bloc.dart.erb', "#{src_directory}/home/home_bloc.dart")
35
- template('src/home/home_module.dart.erb', "#{src_directory}/home/home_module.dart")
36
- template('src/home/home_page.dart.erb', "#{src_directory}/home/home_page.dart")
31
+ template('src/app.dart.erb', "#{src_directory}/app.dart")
32
+ template('src/animations/slide_right_route.dart.erb', "#{src_directory}/animations/slide_right_route.dart")
33
+ template('src/config/router.dart.erb', "#{src_directory}/config/router.dart")
34
+ template('src/constants/pages_list.dart.erb', "#{src_directory}/constants/pages_list.dart")
35
+ template('src/constants/routing.dart.erb', "#{src_directory}/constants/routing.dart")
36
+ template('src/screens/base.dart.erb', "#{src_directory}/screens/home_screen.dart")
37
+ template('src/screens/undefined_route_screen.dart.erb', "#{src_directory}/screens/undefined_route_screen.dart")
38
+ template('src/widgets/base_app_bar.dart.erb', "#{src_directory}/widgets/base_app_bar.dart")
39
+ template('src/widgets/popup_menu_widget.dart.erb', "#{src_directory}/widgets/popup_menu_widget.dart")
40
+
41
+ invoke :setup_pages
42
+ end
43
+
44
+ def setup_pages
45
+ inject_into_file("#{src_directory}/config/router.dart", home_router, after: /^.*switch \(settings.name\) \{$/)
46
+ inject_into_file("#{src_directory}/constants/pages_list.dart", home_route, after: /const List<Page> pages = const <Page>\[.*$/)
47
+ append_to_file("#{src_directory}/constants/routing.dart", "const String HomeScreenRoute = '/';")
37
48
  end
38
49
 
39
50
  private
@@ -56,6 +67,17 @@ module Frap
56
67
  rxdart: ^0.22.0
57
68
  bloc_pattern: ^2.2.3)
58
69
  end
70
+
71
+ def home_router
72
+ %Q(
73
+ case HomeScreenRoute:
74
+ return SlideRightRoute(widget:HomeScreen());)
75
+ end
76
+
77
+ def home_route
78
+ %Q(
79
+ const Page(title: 'Home', icon: Icons.home, route: HomeScreenRoute),)
80
+ end
59
81
  end
60
82
  end
61
83
  end
@@ -0,0 +1,57 @@
1
+ module Frap
2
+ module Generators
3
+ class FlutterResource < Thor::Group
4
+ include Thor::Actions
5
+
6
+ desc 'Generate Flutter Config files'
7
+ argument :name
8
+ argument :folder_name
9
+
10
+ def self.source_root
11
+ File.dirname(__FILE__) + '/templates/dart'
12
+ end
13
+
14
+ def configure_directories
15
+ inject_into_file("#{working_directory}/pubspec.yaml", pub_files, after: /^dependencies:.*$/)
16
+ remove_file("#{lib_directory}/main.dart")
17
+ invoke :create_directories
18
+ end
19
+
20
+ def create_directories
21
+ empty_directory("#{lib_directory}/src/home")
22
+ invoke :create_files
23
+ end
24
+
25
+ def create_files
26
+ template('main.dart.erb', "#{lib_directory}/main.dart")
27
+ template('src/app_bloc.dart.erb', "#{src_directory}/app_bloc.dart")
28
+ template('src/app_module.dart.erb', "#{src_directory}/app_module.dart")
29
+ template('src/app_widget.dart.erb', "#{src_directory}/app_widget.dart")
30
+ template('src/home/home_bloc.dart.erb', "#{src_directory}/home/home_bloc.dart")
31
+ template('src/home/home_module.dart.erb', "#{src_directory}/home/home_module.dart")
32
+ template('src/home/home_page.dart.erb', "#{src_directory}/home/home_page.dart")
33
+ end
34
+
35
+ private
36
+
37
+ def working_directory
38
+ "#{destination_root}/#{folder_name}"
39
+ end
40
+
41
+ def lib_directory
42
+ "#{working_directory}/lib"
43
+ end
44
+
45
+ def src_directory
46
+ "#{lib_directory}/src"
47
+ end
48
+
49
+ def pub_files
50
+ %Q(
51
+ dio: ^2.1.13
52
+ rxdart: ^0.22.0
53
+ bloc_pattern: ^2.2.3)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,4 +1,4 @@
1
1
  import 'package:flutter/material.dart';
2
- import 'package:<%= folder_name %>/src/app_module.dart';
2
+ import 'package:<%= folder_name %>/src/app.dart';
3
3
 
4
- void main() => runApp(AppModule());
4
+ void main() => runApp(App());
@@ -0,0 +1,23 @@
1
+ import 'package:flutter/material.dart';
2
+
3
+ class SlideRightRoute extends PageRouteBuilder {
4
+ final Widget widget;
5
+ SlideRightRoute({this.widget}) : super(
6
+ pageBuilder: (BuildContext context, Animation<double> animation,
7
+ Animation<double> secondaryAnimation) {
8
+ return widget;
9
+ },
10
+ transitionsBuilder: (BuildContext context,
11
+ Animation<double> animation,
12
+ Animation<double> secondaryAnimation,
13
+ Widget child) {
14
+ return new SlideTransition(
15
+ position: new Tween<Offset>(
16
+ begin: const Offset(1.0, 0.0),
17
+ end: Offset.zero,
18
+ ).animate(animation),
19
+ child: child,
20
+ );
21
+ },
22
+ );
23
+ }
@@ -0,0 +1,26 @@
1
+ import 'package:flutter/material.dart';
2
+ import 'package:<%= folder_name %>/src/screens/undefined_route_screen.dart';
3
+ import 'package:<%= folder_name %>/src/screens/home_screen.dart';
4
+ import 'package:<%= folder_name %>/src/config/router.dart' as router;
5
+ import 'package:<%= folder_name %>/src/constants/routing.dart';
6
+
7
+ class App extends StatelessWidget {
8
+ @override
9
+
10
+ static const String _title = '<%= folder_name %>';
11
+
12
+ Widget build(BuildContext context) {
13
+ return MaterialApp(
14
+ title: _title,
15
+ theme: ThemeData.light(),
16
+ home: HomeScreen(),
17
+ initialRoute: HomeScreenRoute,
18
+ onGenerateRoute: router.generateRoute,
19
+ onUnknownRoute: (settings) => MaterialPageRoute(
20
+ builder: (context) => UndefinedRouteScreen(
21
+ name: settings.name,
22
+ )
23
+ ),
24
+ );
25
+ }
26
+ }
@@ -0,0 +1,14 @@
1
+ import 'package:flutter/material.dart';
2
+
3
+ import 'package:<%= folder_name %>/src/animations/slide_right_route.dart';
4
+ import 'package:<%= folder_name %>/src/constants/routing.dart';
5
+ import 'package:<%= folder_name %>/src/screens/home_screen.dart';
6
+ import 'package:<%= folder_name %>/src/screens/undefined_route_screen.dart';
7
+
8
+
9
+ Route<dynamic> generateRoute(RouteSettings settings) {
10
+ switch (settings.name) {
11
+ default:
12
+ return SlideRightRoute(widget:UndefinedRouteScreen());
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ import 'package:flutter/material.dart';
2
+ import 'package:<%= folder_name %>/src/constants/routing.dart';
3
+
4
+ class Page {
5
+ const Page({this.title, this.icon, this.route});
6
+
7
+ final String title;
8
+ final IconData icon;
9
+ final String route;
10
+ }
11
+
12
+ const List<Page> pages = const <Page>[
13
+ ];
@@ -0,0 +1,23 @@
1
+ import 'package:flutter/material.dart';
2
+ import 'package:<%= folder_name %>/src/constants/routing.dart';
3
+ import 'package:<%= folder_name %>/src/widgets/base_app_bar.dart';
4
+ import 'package:<%= folder_name %>/src/widgets/popup_menu_widget.dart';
5
+
6
+ class HomeScreen extends StatelessWidget {
7
+ @override
8
+
9
+ Widget build(BuildContext context) {
10
+ return Scaffold(
11
+ appBar: BaseAppBar(
12
+ title: Text('<%= name %>'),
13
+ appBar: AppBar(),
14
+ widgets: <Widget>[
15
+ PopupMenuWidget(),
16
+ ],
17
+ ),
18
+ body: Center(
19
+ child: Text('<%= name %>'),
20
+ ),
21
+ );
22
+ }
23
+ }
@@ -0,0 +1,15 @@
1
+ import 'package:flutter/material.dart';
2
+
3
+ class UndefinedRouteScreen extends StatelessWidget {
4
+ final String name;
5
+ const UndefinedRouteScreen({Key key, this.name}) : super(key: key);
6
+
7
+ @override
8
+ Widget build(BuildContext context) {
9
+ return Scaffold(
10
+ body: Center(
11
+ child: Text('Route for $name is not defined'),
12
+ ),
13
+ );
14
+ }
15
+ }
@@ -0,0 +1,23 @@
1
+ import 'package:flutter/material.dart';
2
+
3
+ class BaseAppBar extends StatelessWidget implements PreferredSizeWidget {
4
+ final Color backgroundColor = Colors.blue;
5
+ final Text title;
6
+ final AppBar appBar;
7
+ final List<Widget> widgets;
8
+
9
+ const BaseAppBar({Key key, this.title, this.appBar, this.widgets})
10
+ : super(key: key);
11
+
12
+ @override
13
+ Widget build(BuildContext context) {
14
+ return AppBar(
15
+ title: title,
16
+ backgroundColor: backgroundColor,
17
+ actions: widgets,
18
+ );
19
+ }
20
+
21
+ @override
22
+ Size get preferredSize => new Size.fromHeight(appBar.preferredSize.height);
23
+ }
@@ -0,0 +1,30 @@
1
+ import 'package:flutter/material.dart';
2
+ import 'package:<%= folder_name %>/src/constants/pages_list.dart';
3
+ import 'package:<%= folder_name %>/src/constants/routing.dart';
4
+
5
+ class PopupMenuWidget extends StatefulWidget {
6
+ @override
7
+ _PopupMenuWidgetState createState() => _PopupMenuWidgetState();
8
+ }
9
+
10
+ class _PopupMenuWidgetState extends State<PopupMenuWidget> {
11
+ @override
12
+
13
+ _onSelect(Page page) {
14
+ Navigator.pushNamed(context, page.route);
15
+ }
16
+
17
+ Widget build(BuildContext context) {
18
+ return PopupMenuButton<Page>(
19
+ onSelected: _onSelect,
20
+ itemBuilder: (BuildContext context) {
21
+ return pages.map((Page page) {
22
+ return PopupMenuItem<Page>(
23
+ value: page,
24
+ child: Text(page.title),
25
+ );
26
+ }).toList();
27
+ },
28
+ );
29
+ }
30
+ }
@@ -1,3 +1,3 @@
1
1
  module Frap
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Gascoigne - Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-24 00:00:00.000000000 Z
11
+ date: 2019-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -104,19 +104,24 @@ files:
104
104
  - bin/setup
105
105
  - frap.gemspec
106
106
  - lib/frap.rb
107
+ - lib/frap/commands/generate.rb
107
108
  - lib/frap/create_app.rb
109
+ - lib/frap/create_base.rb
110
+ - lib/frap/create_resource.rb
108
111
  - lib/frap/generators/config.rb
109
112
  - lib/frap/generators/flutter_config.rb
110
- - lib/frap/generators/generate.rb
111
- - lib/frap/generators/resource.rb
113
+ - lib/frap/generators/flutter_resource.rb
112
114
  - lib/frap/generators/templates/config.erb
113
115
  - lib/frap/generators/templates/dart/main.dart.erb
114
- - lib/frap/generators/templates/dart/src/app_bloc.dart.erb
115
- - lib/frap/generators/templates/dart/src/app_module.dart.erb
116
- - lib/frap/generators/templates/dart/src/app_widget.dart.erb
117
- - lib/frap/generators/templates/dart/src/home/home_bloc.dart.erb
118
- - lib/frap/generators/templates/dart/src/home/home_module.dart.erb
119
- - lib/frap/generators/templates/dart/src/home/home_page.dart.erb
116
+ - lib/frap/generators/templates/dart/src/animations/slide_right_route.dart.erb
117
+ - lib/frap/generators/templates/dart/src/app.dart.erb
118
+ - lib/frap/generators/templates/dart/src/config/router.dart.erb
119
+ - lib/frap/generators/templates/dart/src/constants/pages_list.dart.erb
120
+ - lib/frap/generators/templates/dart/src/constants/routing.dart.erb
121
+ - lib/frap/generators/templates/dart/src/screens/base.dart.erb
122
+ - lib/frap/generators/templates/dart/src/screens/undefined_route_screen.dart.erb
123
+ - lib/frap/generators/templates/dart/src/widgets/base_app_bar.dart.erb
124
+ - lib/frap/generators/templates/dart/src/widgets/popup_menu_widget.dart.erb
120
125
  - lib/frap/version.rb
121
126
  homepage: https://github.com/flippakitten/frap
122
127
  licenses:
@@ -1,42 +0,0 @@
1
- require 'thor'
2
-
3
- module Frap
4
- module Generators
5
- class Resource
6
- attr_accessor :name, :attributes, :options
7
-
8
- def initialize(name, options)
9
- @name = name
10
- @options = options
11
- end
12
-
13
- def create_resource
14
- generate_rails_resource if options['rails']
15
- generate_flutter_resource if options['flutter']
16
- end
17
-
18
- private
19
-
20
- def generate_rails_resource
21
-
22
-
23
- puts "TODO: rails g resource #{fields}"
24
- end
25
-
26
- def generate_flutter_resource
27
- puts "TODO: frap g flutter resource #{fields}"
28
- end
29
-
30
- def fields
31
- @fields ||= build_fields
32
- end
33
-
34
- def build_fields
35
- fields_string = ''
36
- options[:attributes].each { |k, v| fields_string << "#{k}:#{v} " }
37
-
38
- return fields_string
39
- end
40
- end
41
- end
42
- end
@@ -1,9 +0,0 @@
1
- import 'package:bloc_pattern/bloc_pattern.dart';
2
-
3
- class AppBloc extends BlocBase {
4
- //dispose will be called automatically by closing its streams
5
- @override
6
- void dispose() {
7
- super.dispose();
8
- }
9
- }
@@ -1,19 +0,0 @@
1
- import 'package:bloc_pattern/bloc_pattern.dart';
2
- import 'package:flutter/material.dart';
3
- import 'package:<%= folder_name %>/src/app_widget.dart';
4
- import 'package:<%= folder_name %>/src/app_bloc.dart';
5
-
6
- class AppModule extends ModuleWidget {
7
- @override
8
- List<Bloc> get blocs => [
9
- Bloc((i) => AppBloc()),
10
- ];
11
-
12
- @override
13
- List<Dependency> get dependencies => [];
14
-
15
- @override
16
- Widget get view => AppWidget();
17
-
18
- static Inject get to => Inject<AppModule>.of();
19
- }
@@ -1,15 +0,0 @@
1
- import 'package:flutter/material.dart';
2
- import 'package:<%= folder_name %>/src/home/home_module.dart';
3
-
4
- class AppWidget extends StatelessWidget {
5
- @override
6
- Widget build(BuildContext context) {
7
- return MaterialApp(
8
- title: '<%= name.split(/ |\_|\-/).map(&:capitalize).join(' ') %> App',
9
- theme: ThemeData(
10
- primarySwatch: Colors.blue,
11
- ),
12
- home: HomeModule(),
13
- );
14
- }
15
- }
@@ -1,9 +0,0 @@
1
- import 'package:bloc_pattern/bloc_pattern.dart';
2
-
3
- class HomeBloc extends BlocBase {
4
- //dispose will be called automatically by closing its streams
5
- @override
6
- void dispose() {
7
- super.dispose();
8
- }
9
- }
@@ -1,19 +0,0 @@
1
- import 'package:<%= folder_name %>/src/home/home_bloc.dart';
2
- import 'package:bloc_pattern/bloc_pattern.dart';
3
- import 'package:flutter/material.dart';
4
- import 'package:<%= folder_name %>/src/home/home_page.dart';
5
-
6
- class HomeModule extends ModuleWidget {
7
- @override
8
- List<Bloc> get blocs => [
9
- Bloc((i) => HomeBloc()),
10
- ];
11
-
12
- @override
13
- List<Dependency> get dependencies => [];
14
-
15
- @override
16
- Widget get view => HomePage();
17
-
18
- static Inject get to => Inject<HomeModule>.of();
19
- }
@@ -1,20 +0,0 @@
1
- import 'package:flutter/material.dart';
2
-
3
- class HomePage extends StatefulWidget {
4
- @override
5
- _HomePageState createState() => _HomePageState();
6
- }
7
-
8
- class _HomePageState extends State<HomePage> {
9
- @override
10
- Widget build(BuildContext context) {
11
- return Scaffold(
12
- appBar: AppBar(
13
- title: Text("Home"),
14
- ),
15
- body: Center(
16
- child: Text('<%= folder_name %> Home'),
17
- ),
18
- );
19
- }
20
- }