Browse Source

add some structure

x1ongzhu 6 years ago
parent
commit
e53b26e61a

+ 1 - 0
ios/Flutter/Debug.xcconfig

@@ -1 +1,2 @@
+#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
 #include "Generated.xcconfig"

+ 1 - 0
ios/Flutter/Release.xcconfig

@@ -1 +1,2 @@
+#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
 #include "Generated.xcconfig"

+ 69 - 0
ios/Podfile

@@ -0,0 +1,69 @@
+# Uncomment this line to define a global platform for your project
+# platform :ios, '9.0'
+
+# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
+ENV['COCOAPODS_DISABLE_STATS'] = 'true'
+
+project 'Runner', {
+  'Debug' => :debug,
+  'Profile' => :release,
+  'Release' => :release,
+}
+
+def parse_KV_file(file, separator='=')
+  file_abs_path = File.expand_path(file)
+  if !File.exists? file_abs_path
+    return [];
+  end
+  pods_ary = []
+  skip_line_start_symbols = ["#", "/"]
+  File.foreach(file_abs_path) { |line|
+      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
+      plugin = line.split(pattern=separator)
+      if plugin.length == 2
+        podname = plugin[0].strip()
+        path = plugin[1].strip()
+        podpath = File.expand_path("#{path}", file_abs_path)
+        pods_ary.push({:name => podname, :path => podpath});
+      else
+        puts "Invalid plugin specification: #{line}"
+      end
+  }
+  return pods_ary
+end
+
+target 'Runner' do
+  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
+  # referring to absolute paths on developers' machines.
+  system('rm -rf .symlinks')
+  system('mkdir -p .symlinks/plugins')
+
+  # Flutter Pods
+  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
+  if generated_xcode_build_settings.empty?
+    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
+  end
+  generated_xcode_build_settings.map { |p|
+    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
+      symlink = File.join('.symlinks', 'flutter')
+      File.symlink(File.dirname(p[:path]), symlink)
+      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
+    end
+  }
+
+  # Plugin Pods
+  plugin_pods = parse_KV_file('../.flutter-plugins')
+  plugin_pods.map { |p|
+    symlink = File.join('.symlinks', 'plugins', p[:name])
+    File.symlink(p[:path], symlink)
+    pod p[:name], :path => File.join(symlink, 'ios')
+  }
+end
+
+post_install do |installer|
+  installer.pods_project.targets.each do |target|
+    target.build_configurations.each do |config|
+      config.build_settings['ENABLE_BITCODE'] = 'NO'
+    end
+  end
+end

+ 21 - 0
lib/main1.dart

@@ -0,0 +1,21 @@
+import 'package:redux/redux.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import 'redux/AppState.dart';
+import 'pages/HomePage.dart';
+
+class MobileCyberGamesApp extends StatelessWidget {
+  final Store<AppState> store =
+      Store<AppState>(appReducer, initialState: AppState());
+  @override
+  Widget build(BuildContext context) => StoreProvider(
+      store: this.store,
+      child: new MaterialApp(
+        title: 'aaa',
+        home: HomePage(),
+      ));
+}
+
+void main() {
+  runApp(new MobileCyberGamesApp());
+}

+ 24 - 0
lib/model/UserInfo.dart

@@ -0,0 +1,24 @@
+import 'package:json_annotation/json_annotation.dart';
+
+part 'UserInfo.g.dart';
+
+@JsonSerializable()
+class UserInfo {
+  UserInfo(this.id, this.nickname, this.username, this.icon, this.phone,
+      this.sex, this.moneyCoin, this.moneyPoint);
+  int id;
+  String nickname;
+  String username;
+  String icon;
+  String phone;
+  String sex;
+  String moneyCoin; //余额
+  String moneyPoint; //积分
+  factory UserInfo.fromJson(Map<String, dynamic> json) =>
+      _$UserInfoFromJson(json);
+
+  Map<String, dynamic> toJson() => _$UserInfoToJson(this);
+
+  // 命名构造函数
+  UserInfo.empty();
+}

+ 30 - 0
lib/model/UserInfo.g.dart

@@ -0,0 +1,30 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'UserInfo.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+UserInfo _$UserInfoFromJson(Map<String, dynamic> json) {
+  return UserInfo(
+      json['id'] as int,
+      json['nickname'] as String,
+      json['username'] as String,
+      json['icon'] as String,
+      json['phone'] as String,
+      json['sex'] as String,
+      json['moneyCoin'] as String,
+      json['moneyPoint'] as String);
+}
+
+Map<String, dynamic> _$UserInfoToJson(UserInfo instance) => <String, dynamic>{
+      'id': instance.id,
+      'nickname': instance.nickname,
+      'username': instance.username,
+      'icon': instance.icon,
+      'phone': instance.phone,
+      'sex': instance.sex,
+      'moneyCoin': instance.moneyCoin,
+      'moneyPoint': instance.moneyPoint
+    };

+ 15 - 0
lib/pages/HomePage.dart

@@ -0,0 +1,15 @@
+import 'package:flutter/material.dart';
+import '../widgets/HomeDrawer.dart';
+class HomePage extends StatefulWidget {
+  @override
+  _HomePageState createState() => _HomePageState();
+}
+
+class _HomePageState extends State<HomePage> {
+  @override
+  Widget build(BuildContext context) {
+    return new Scaffold(
+      drawer: new HomeDrawer(),
+    );
+  }
+}

+ 7 - 0
lib/redux/AppState.dart

@@ -0,0 +1,7 @@
+import 'package:electric_contest/model/UserInfo.dart';
+
+class AppState {
+  UserInfo userInfo;
+}
+
+AppState appReducer(AppState state, action) {}

+ 7 - 0
lib/serivces/BaseService.dart

@@ -0,0 +1,7 @@
+import 'package:dio/dio.dart';
+
+Dio _dio;
+
+class BaseService {
+  Dio _getDio() {}
+}

+ 7 - 0
lib/serivces/UserService.dart

@@ -0,0 +1,7 @@
+import 'package:dio/dio.dart';
+import '../model/UserInfo.dart';
+
+class UserService {
+  static Future<UserInfo> login() async {
+  }
+}

+ 53 - 0
lib/widgets/HomeDrawer.dart

@@ -0,0 +1,53 @@
+import 'package:flutter/material.dart';
+import 'package:redux/redux.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import '../redux/AppState.dart';
+import '../model/UserInfo.dart';
+
+class HomeDrawer extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return new StoreConnector<AppState, UserInfo>(
+      converter: (Store store) => store.state.userInfo,
+      builder: (context, userInfo) {
+        return new Drawer(
+            child: Container(
+          decoration: BoxDecoration(
+              gradient: LinearGradient(
+            begin: Alignment.bottomRight,
+            colors: [Color(0xFF3D3E6C), Color(0xFF626C85)],
+          )),
+          child: new Column(
+            children: <Widget>[
+              Container(
+                decoration: BoxDecoration(color: Color(0x4D000000)),
+                child: SizedBox(
+                  width: double.infinity,
+                  height: 210,
+                  child: Row(
+                    mainAxisAlignment: MainAxisAlignment.center,
+                    children: <Widget>[
+                      ClipOval(
+                        child: SizedBox(
+                            width: 86,
+                            height: 86,
+                            child: FittedBox(
+                                fit: BoxFit.cover,
+                                child: Image.network(
+                                    "https://ws1.sinaimg.cn/large/0065oQSqly1g0ajj4h6ndj30sg11xdmj.jpg"))),
+                      )
+                    ],
+                  ),
+                ),
+              ),
+              Expanded(
+                flex: 1,
+                child: new Container(),
+              )
+            ],
+          ),
+        ));
+      },
+    );
+  }
+}

+ 2 - 0
pubspec.yaml

@@ -25,6 +25,8 @@ dependencies:
   intl: "^0.15.6"
 
 dev_dependencies:
+  build_runner: ^1.1.1
+  json_serializable: ^2.0.0
   flutter_test:
     sdk: flutter