Skip to content

Commit e1cca83

Browse files
committed
feat: add list component
1 parent 354f335 commit e1cca83

File tree

6 files changed

+167
-55
lines changed

6 files changed

+167
-55
lines changed

ios/Flutter/Debug.xcconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"

ios/Flutter/Release.xcconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

ios/Podfile

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '9.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
13+
def parse_KV_file(file, separator='=')
14+
file_abs_path = File.expand_path(file)
15+
if !File.exists? file_abs_path
16+
return [];
17+
end
18+
pods_ary = []
19+
skip_line_start_symbols = ["#", "/"]
20+
File.foreach(file_abs_path) { |line|
21+
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22+
plugin = line.split(pattern=separator)
23+
if plugin.length == 2
24+
podname = plugin[0].strip()
25+
path = plugin[1].strip()
26+
podpath = File.expand_path("#{path}", file_abs_path)
27+
pods_ary.push({:name => podname, :path => podpath});
28+
else
29+
puts "Invalid plugin specification: #{line}"
30+
end
31+
}
32+
return pods_ary
33+
end
34+
35+
target 'Runner' do
36+
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
37+
# referring to absolute paths on developers' machines.
38+
system('rm -rf .symlinks')
39+
system('mkdir -p .symlinks/plugins')
40+
41+
# Flutter Pods
42+
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
43+
if generated_xcode_build_settings.empty?
44+
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
45+
end
46+
generated_xcode_build_settings.map { |p|
47+
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
48+
symlink = File.join('.symlinks', 'flutter')
49+
File.symlink(File.dirname(p[:path]), symlink)
50+
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
51+
end
52+
}
53+
54+
# Plugin Pods
55+
plugin_pods = parse_KV_file('../.flutter-plugins')
56+
plugin_pods.map { |p|
57+
symlink = File.join('.symlinks', 'plugins', p[:name])
58+
File.symlink(p[:path], symlink)
59+
pod p[:name], :path => File.join(symlink, 'ios')
60+
}
61+
end
62+
63+
post_install do |installer|
64+
installer.pods_project.targets.each do |target|
65+
target.build_configurations.each do |config|
66+
config.build_settings['ENABLE_BITCODE'] = 'NO'
67+
end
68+
end
69+
end

lib/component/list.dart

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:flutter/material.dart';
2+
import 'dart:io' show Platform;
3+
4+
import '../constants.dart' as CONSTANTS;
5+
import '../utils.dart' as Utils;
6+
7+
class ListComponent extends StatelessWidget {
8+
ListComponent({Key key}) : super(key: key);
9+
10+
@override
11+
Widget build(BuildContext context) {
12+
String os = Platform.operatingSystem;
13+
String osString = '${os[0].toUpperCase()}${os.substring(1)}';
14+
return new Container(
15+
padding: const EdgeInsets.all(20.0),
16+
child: Column(
17+
mainAxisAlignment: MainAxisAlignment.center,
18+
children: <Widget>[
19+
Text(
20+
'$osString Flutter Bootstrap',
21+
style: new TextStyle(fontSize: 20.0, color: Colors.black),
22+
),
23+
new Container(
24+
width: MediaQuery.of(context).size.width,
25+
margin: const EdgeInsets.only(top: 80.0),
26+
decoration: new BoxDecoration(
27+
color: Color(Utils.getColorHexFromStr(CONSTANTS.COLOR_1)),
28+
borderRadius: new BorderRadius.circular(4.0),
29+
),
30+
child: FlatButton(
31+
child: Text(
32+
'list',
33+
textAlign: TextAlign.center,
34+
style: new TextStyle(
35+
fontSize: 20.0,
36+
color: Color(Utils.getColorHexFromStr('#ffffff'))),
37+
),
38+
onPressed: () {
39+
Navigator.pushNamed(context, '/list');
40+
}))
41+
],
42+
),
43+
);
44+
}
45+
}

lib/component/logout.dart

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:flutter/material.dart';
2+
import 'dart:io' show Platform;
3+
4+
import '../constants.dart' as CONSTANTS;
5+
import '../utils.dart' as Utils;
6+
7+
class LogoutComponent extends StatelessWidget {
8+
LogoutComponent({Key key}) : super(key: key);
9+
10+
@override
11+
Widget build(BuildContext context) {
12+
String os = Platform.operatingSystem;
13+
String osString = '${os[0].toUpperCase()}${os.substring(1)}';
14+
return new Container(
15+
padding: const EdgeInsets.all(20.0),
16+
child: Column(
17+
mainAxisAlignment: MainAxisAlignment.center,
18+
children: <Widget>[
19+
Text(
20+
'$osString Flutter Bootstrap',
21+
style: new TextStyle(fontSize: 20.0, color: Colors.black),
22+
),
23+
new Container(
24+
width: MediaQuery.of(context).size.width,
25+
margin: const EdgeInsets.only(top: 80.0),
26+
decoration: new BoxDecoration(
27+
color: Color(Utils.getColorHexFromStr(CONSTANTS.COLOR_1)),
28+
borderRadius: new BorderRadius.circular(4.0),
29+
),
30+
child: FlatButton(
31+
child: Text(
32+
'Logout',
33+
textAlign: TextAlign.center,
34+
style: new TextStyle(
35+
fontSize: 20.0,
36+
color: Color(Utils.getColorHexFromStr('#ffffff'))),
37+
),
38+
onPressed: () {
39+
Navigator.pushNamed(context, '/login');
40+
}))
41+
],
42+
),
43+
);
44+
}
45+
}

lib/page/home.dart

+6-55
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import 'package:flutter/material.dart';
2-
import 'dart:io' show Platform;
3-
42
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
53

64
import '../constants.dart' as CONSTANTS;
75
import '../utils.dart' as Utils;
86

7+
import '../component/list.dart';
8+
import '../component/logout.dart';
9+
910
class HomePage extends StatefulWidget {
1011
HomePage({Key key, this.title}) : super(key: key);
1112

@@ -19,23 +20,11 @@ class HomePage extends StatefulWidget {
1920

2021
class HomePageState extends State<HomePage> {
2122
int _currentIndex = 0;
22-
var a = WebviewScaffold(
23-
url: "https://www.youku.com",
24-
hidden: true,
25-
);
2623

27-
var b = WebviewScaffold(
28-
url: "https://www.baidu.com",
29-
hidden: true,
30-
);
3124
@override
3225
Widget build(BuildContext context) {
33-
String os = Platform.operatingSystem;
34-
String osString = '${os[0].toUpperCase()}${os.substring(1)}';
35-
36-
final List<Widget> _children = [
37-
a,
38-
b,
26+
var _children = [
27+
ListComponent(),
3928
WebviewScaffold(
4029
url: CONSTANTS.TEST_URL,
4130
hidden: true,
@@ -46,6 +35,7 @@ class HomePageState extends State<HomePage> {
4635
hidden: true,
4736
withLocalStorage: true,
4837
),
38+
LogoutComponent(),
4939
];
5040
return Scaffold(
5141
appBar: new AppBar(
@@ -60,45 +50,6 @@ class HomePageState extends State<HomePage> {
6050
backgroundColor: Colors.white,
6151
),
6252
body: _children[_currentIndex],
63-
/*
64-
new Container(
65-
padding: const EdgeInsets.all(20.0),
66-
child: Column(
67-
mainAxisAlignment: MainAxisAlignment.center,
68-
children: <Widget>[
69-
Text(
70-
'$osString Flutter Bootstrap',
71-
style: new TextStyle(
72-
fontSize: 20.0,
73-
color: Colors.black
74-
),
75-
),
76-
new Container(
77-
width: MediaQuery.of(context).size.width,
78-
margin: const EdgeInsets.only(top: 80.0),
79-
decoration: new BoxDecoration(
80-
color: Color(Utils.getColorHexFromStr(CONSTANTS.COLOR_1)),
81-
borderRadius: new BorderRadius.circular(4.0),
82-
),
83-
child: FlatButton(
84-
child: Text(
85-
'list',
86-
textAlign: TextAlign.center,
87-
style: new TextStyle(
88-
fontSize: 20.0,
89-
color: Color(Utils.getColorHexFromStr('#ffffff'))
90-
),
91-
),
92-
onPressed: () {
93-
Navigator.pushNamed(context, '/list');
94-
}
95-
)
96-
)
97-
],
98-
),
99-
),
100-
*/
101-
10253
bottomNavigationBar: BottomNavigationBar(
10354
type: BottomNavigationBarType.fixed,
10455
items: <BottomNavigationBarItem>[

0 commit comments

Comments
 (0)