Skip to content

Commit bb75a37

Browse files
committed
Jetpack_Github项目趋势模块对应的Flutter工程
0 parents  commit bb75a37

18 files changed

Lines changed: 1059 additions & 0 deletions

‎.gitignore‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
7+
.idea/
8+
.vagrant/
9+
.sconsign.dblite
10+
.svn/
11+
12+
*.swp
13+
profile
14+
15+
DerivedData/
16+
17+
.generated/
18+
19+
*.pbxuser
20+
*.mode1v3
21+
*.mode2v3
22+
*.perspectivev3
23+
24+
!default.pbxuser
25+
!default.mode1v3
26+
!default.mode2v3
27+
!default.perspectivev3
28+
29+
xcuserdata
30+
31+
*.moved-aside
32+
33+
*.pyc
34+
*sync/
35+
Icon?
36+
.tags*
37+
38+
build/
39+
.android/
40+
.ios/
41+
.flutter-plugins
42+
.flutter-plugins-dependencies
43+
44+
# Symbolication related
45+
app.*.symbols
46+
47+
# Obfuscation related
48+
app.*.map.json

‎.metadata‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: e6b34c2b5c96bb95325269a29a84e83ed8909b5f
8+
channel: stable
9+
10+
project_type: module

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# flutter_module
2+
3+
A new flutter module project.
4+
5+
## Getting Started
6+
7+
For help getting started with Flutter, view our online
8+
[documentation](https://flutter.dev/).

‎flutter_module.iml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
7+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
8+
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
9+
<excludeFolder url="file://$MODULE_DIR$/.idea" />
10+
<excludeFolder url="file://$MODULE_DIR$/.pub" />
11+
<excludeFolder url="file://$MODULE_DIR$/build" />
12+
</content>
13+
<orderEntry type="sourceFolder" forTests="false" />
14+
<orderEntry type="library" name="Dart SDK" level="project" />
15+
<orderEntry type="library" name="Flutter Plugins" level="project" />
16+
<orderEntry type="library" name="Dart Packages" level="project" />
17+
</component>
18+
</module>

‎flutter_module_android.iml‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="android" name="Android">
5+
<configuration>
6+
<option name="ALLOW_USER_CONFIGURATION" value="false" />
7+
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/.android/gen" />
8+
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/.android/gen" />
9+
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/.android/AndroidManifest.xml" />
10+
<option name="RES_FOLDER_RELATIVE_PATH" value="/.android/res" />
11+
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/.android/assets" />
12+
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/.android/libs" />
13+
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/.android/proguard_logs" />
14+
</configuration>
15+
</facet>
16+
</component>
17+
<component name="NewModuleRootManager" inherit-compiler-output="true">
18+
<exclude-output />
19+
<content url="file://$MODULE_DIR$/.android">
20+
<sourceFolder url="file://$MODULE_DIR$/.android/Flutter/src/main/java" isTestSource="false" />
21+
<sourceFolder url="file://$MODULE_DIR$/.android/gen" isTestSource="false" generated="true" />
22+
</content>
23+
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
24+
<orderEntry type="sourceFolder" forTests="false" />
25+
<orderEntry type="library" name="Flutter for Android" level="project" />
26+
<orderEntry type="library" name="Gradle: io.flutter:armeabi_v7a_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5@jar" level="project" />
27+
<orderEntry type="module" module-name="flutter_module" />
28+
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata-core:2.0.0@aar" level="project" />
29+
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-common-java8:2.2.0@jar" level="project" />
30+
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-livedata:2.0.0@aar" level="project" />
31+
<orderEntry type="library" name="Gradle: androidx.savedstate:savedstate:1.0.0@aar" level="project" />
32+
<orderEntry type="library" name="Gradle: androidx.activity:activity:1.0.0@aar" level="project" />
33+
<orderEntry type="library" name="Gradle: androidx.versionedparcelable:versionedparcelable:1.1.0@aar" level="project" />
34+
<orderEntry type="library" name="Gradle: androidx.arch.core:core-common:2.1.0@jar" level="project" />
35+
<orderEntry type="library" name="Gradle: androidx.annotation:annotation:1.1.0@jar" level="project" />
36+
<orderEntry type="library" name="Gradle: androidx.print:print:1.0.0@aar" level="project" />
37+
<orderEntry type="library" name="Gradle: androidx.customview:customview:1.0.0@aar" level="project" />
38+
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.0.2@aar" level="project" />
39+
<orderEntry type="library" name="Gradle: androidx.drawerlayout:drawerlayout:1.0.0@aar" level="project" />
40+
<orderEntry type="library" name="Gradle: androidx.constraintlayout:constraintlayout:1.1.3@aar" level="project" />
41+
<orderEntry type="library" name="Gradle: androidx.constraintlayout:constraintlayout-solver:1.1.3@jar" level="project" />
42+
<orderEntry type="library" name="Gradle: io.flutter:arm64_v8a_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5@jar" level="project" />
43+
<orderEntry type="library" name="Gradle: androidx.cursoradapter:cursoradapter:1.0.0@aar" level="project" />
44+
<orderEntry type="library" name="Gradle: androidx.documentfile:documentfile:1.0.0@aar" level="project" />
45+
<orderEntry type="library" name="Gradle: androidx.swiperefreshlayout:swiperefreshlayout:1.0.0@aar" level="project" />
46+
<orderEntry type="library" name="Gradle: io.flutter:x86_64_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5@jar" level="project" />
47+
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-utils:1.0.0@aar" level="project" />
48+
<orderEntry type="library" name="Gradle: androidx.fragment:fragment:1.1.0@aar" level="project" />
49+
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable-animated:1.0.0@aar" level="project" />
50+
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-ui:1.0.0@aar" level="project" />
51+
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-runtime:2.2.0@aar" level="project" />
52+
<orderEntry type="library" name="Gradle: androidx.asynclayoutinflater:asynclayoutinflater:1.0.0@aar" level="project" />
53+
<orderEntry type="library" name="Gradle: androidx.collection:collection:1.1.0@jar" level="project" />
54+
<orderEntry type="library" name="Gradle: androidx.viewpager:viewpager:1.0.0@aar" level="project" />
55+
<orderEntry type="library" name="Gradle: androidx.coordinatorlayout:coordinatorlayout:1.0.0@aar" level="project" />
56+
<orderEntry type="library" name="Gradle: androidx.interpolator:interpolator:1.0.0@aar" level="project" />
57+
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-viewmodel:2.1.0@aar" level="project" />
58+
<orderEntry type="library" name="Gradle: io.flutter:x86_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5@jar" level="project" />
59+
<orderEntry type="library" name="Gradle: io.flutter:flutter_embedding_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5@jar" level="project" />
60+
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-common:2.2.0@jar" level="project" />
61+
<orderEntry type="library" name="Gradle: ./Flutter/build/intermediates/flutter/debug/libs.jar" level="project" />
62+
<orderEntry type="library" name="Gradle: androidx.slidingpanelayout:slidingpanelayout:1.0.0@aar" level="project" />
63+
<orderEntry type="library" name="Gradle: androidx.localbroadcastmanager:localbroadcastmanager:1.0.0@aar" level="project" />
64+
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable:1.0.1@aar" level="project" />
65+
<orderEntry type="library" name="Gradle: androidx.arch.core:core-runtime:2.0.0@aar" level="project" />
66+
<orderEntry type="library" name="Gradle: androidx.core:core:1.1.0@aar" level="project" />
67+
<orderEntry type="library" name="Gradle: androidx.loader:loader:1.0.0@aar" level="project" />
68+
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.0.0@aar" level="project" />
69+
<orderEntry type="library" name="Gradle: androidx.vectordrawable:vectordrawable:1.0.0@aar" level="project" />
70+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.3.50@jar" level="project" />
71+
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0@jar" level="project" />
72+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.50@jar" level="project" />
73+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50@jar" level="project" />
74+
<orderEntry type="library" name="Gradle: junit:junit:4.12@jar" level="project" />
75+
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
76+
</component>
77+
</module>

‎lib/color/color.dart‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'package:flutter/cupertino.dart';
2+
3+
class DColor {
4+
5+
static Color themeColor = Color(0xff25292d);
6+
static Color desTextColor = Color(0xff787878);
7+
static Color startTextColor = Color(0xffC8C8C8);
8+
9+
}

‎lib/http/http_manager.dart‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:dio/dio.dart';
2+
3+
typedef SuccessCallback = void Function(dynamic data);
4+
typedef ErrorCallback = void Function(String error);
5+
6+
class HttpManager {
7+
HttpManager._();
8+
9+
static BaseOptions _baseOptions =
10+
BaseOptions(headers: {"api-token": "4d65e2a5626103f92a71867d7b49fea0"});
11+
static Dio _dio = Dio(_baseOptions);
12+
13+
static get(String url, SuccessCallback success, ErrorCallback error) async {
14+
try {
15+
Response response = await _dio.get(url);
16+
if (response.statusCode != 200) {
17+
throw Exception(
18+
"statusCode=${response.statusCode},statusMessage=${response.statusMessage}");
19+
} else {
20+
success(response.data);
21+
}
22+
} catch (e) {
23+
error(e);
24+
}
25+
}
26+
}

‎lib/main.dart‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import 'dart:io';
2+
import 'dart:ui';
3+
4+
import 'package:flutter/material.dart';
5+
import 'package:flutter/services.dart';
6+
import 'package:flutter_module/page/trend_page.dart';
7+
import 'color/color.dart';
8+
9+
void main() {
10+
runApp(MyApp(window.defaultRouteName));
11+
if (Platform.isAndroid) {
12+
// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。
13+
SystemUiOverlayStyle systemUiOverlayStyle =
14+
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
15+
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
16+
}
17+
}
18+
19+
class MyApp extends StatelessWidget {
20+
final String defaultRoute;
21+
22+
const MyApp(this.defaultRoute, {Key key}) : super(key: key);
23+
24+
@override
25+
Widget build(BuildContext context) {
26+
return MaterialApp(
27+
title: 'GitHub',
28+
theme: ThemeData(
29+
primarySwatch: createMaterialColor(DColor.themeColor),
30+
),
31+
home: _widgetForRoute(defaultRoute));
32+
}
33+
}
34+
35+
Widget _widgetForRoute(String route) {
36+
//根据不同的路由显示不同的界面
37+
switch (route) {
38+
case "trend":
39+
return TrendPage();
40+
default:
41+
return Center(child: Text('Unknown route: $route'));
42+
}
43+
}
44+
45+
//自定义主题颜色
46+
MaterialColor createMaterialColor(Color color) {
47+
List strengths = <double>[.05];
48+
Map swatch = <int, Color>{};
49+
final int r = color.red, g = color.green, b = color.blue;
50+
51+
for (int i = 1; i < 10; i++) {
52+
strengths.add(0.1 * i);
53+
}
54+
strengths.forEach((strength) {
55+
final double ds = 0.5 - strength;
56+
swatch[(strength * 1000).round()] = Color.fromRGBO(
57+
r + ((ds < 0 ? r : (255 - r)) * ds).round(),
58+
g + ((ds < 0 ? g : (255 - g)) * ds).round(),
59+
b + ((ds < 0 ? b : (255 - b)) * ds).round(),
60+
1,
61+
);
62+
});
63+
return MaterialColor(color.value, swatch);
64+
}

‎lib/model/trend_model.dart‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
class TrendModel {
3+
4+
String fullName;
5+
String url;
6+
String description;
7+
String language;
8+
String meta;
9+
List<String> contributors;
10+
String contributorsUrl;
11+
String starCount;
12+
String forkCount;
13+
String name;
14+
String reposName;
15+
16+
TrendModel.fromJsonMap(Map<String, dynamic> map):
17+
fullName = map["fullName"],
18+
url = map["url"],
19+
description = map["description"],
20+
language = map["language"],
21+
meta = map["meta"],
22+
contributors = List<String>.from(map["contributors"]),
23+
contributorsUrl = map["contributorsUrl"],
24+
starCount = map["starCount"],
25+
forkCount = map["forkCount"],
26+
name = map["name"],
27+
reposName = map["reposName"];
28+
29+
Map<String, dynamic> toJson() {
30+
final Map<String, dynamic> data = new Map<String, dynamic>();
31+
data['fullName'] = fullName;
32+
data['url'] = url;
33+
data['description'] = description;
34+
data['language'] = language;
35+
data['meta'] = meta;
36+
data['contributors'] = contributors;
37+
data['contributorsUrl'] = contributorsUrl;
38+
data['starCount'] = starCount;
39+
data['forkCount'] = forkCount;
40+
data['name'] = name;
41+
data['reposName'] = reposName;
42+
return data;
43+
}
44+
}

0 commit comments

Comments
 (0)