Skip to content

Commit

Permalink
firstcommit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZDfordream committed Feb 3, 2019
1 parent d24edad commit 394c0b5
Show file tree
Hide file tree
Showing 229 changed files with 19,295 additions and 192 deletions.
35 changes: 25 additions & 10 deletions README.md 100644 → 100755
@@ -1,16 +1,31 @@
# tianyue
# 天阅Flutter

A new Flutter application.
## screen shot

## Getting Started
<img src="screenshot/android_0.png">

This project is a starting point for a Flutter application.
<img src="screenshot/android_1.png">

A few resources to get you started if this is your first Flutter project:
<img src="screenshot/android_2.png">

- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
## Setup

For help getting started with Flutter, view our
[online documentation](https://flutter.io/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
1. Clone the repo

2. flutter run

## Dependency

* [carousel_slider](https://pub.flutter-io.cn/packages/carousel_slider)
* [cached_network_image](https://pub.flutter-io.cn/packages/cached_network_image)
* [shared_preferences](https://pub.flutter-io.cn/packages/shared_preferences)
* [flutter_webview_plugin](https://pub.flutter-io.cn/packages/flutter_webview_plugin)
* [share](https://pub.flutter-io.cn/packages/share)

## 简介

这是一个用Flutter写的阅读类app。

我试着让这个Demo的结构尽量接近实际项目,同时使用比较简单方式去实现功能。这样可以让刚接触Flutter的人更够容易理解代码。

App中的网络请求均通过一个名为**Request**的工具类。在Request内部,通过**本地mock**方式,获取模拟数据。
2 changes: 2 additions & 0 deletions android/app/build.gradle
Expand Up @@ -58,4 +58,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
34 changes: 22 additions & 12 deletions android/app/src/main/AndroidManifest.xml
@@ -1,39 +1,49 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhudong.tianyue">

<!-- The INTERNET permission is required for development. Specifically,
<!--
The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
<uses-permission android:name="android.permission.INTERNET" />
<!--
io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
FlutterApplication and put your custom class here.
-->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="tianyue"
android:label="天阅"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing

<!--
This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
defined in @style/LaunchTheme).
-->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AboutActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
</activity>
</application>
</manifest>
21 changes: 21 additions & 0 deletions android/app/src/main/java/com/zhudong/tianyue/AboutActivity.java
@@ -0,0 +1,21 @@
package com.zhudong.tianyue;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class AboutActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getWindow().setStatusBarColor(Color.parseColor("#ffffff"));
View decor = getWindow().getDecorView();
decor.setSystemUiVisibility(decor.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
}
63 changes: 58 additions & 5 deletions android/app/src/main/java/com/zhudong/tianyue/MainActivity.java 100644 → 100755
@@ -1,13 +1,66 @@
package com.zhudong.tianyue;

import android.os.Bundle;

import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;


public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
private static final String CHANNEL = "samples.flutter.io/battery";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
new MethodCallHandler() {
@Override
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getBatteryLevel")) {
int batteryLevel = MainActivity.this.getBatteryLevel();

if (batteryLevel != -1) {
result.success(batteryLevel);
} else {
result.error("UNAVAILABLE", "Battery level not available.", null);
}
} else if (call.method.equals("goAboutActivity")) {
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
MainActivity.this.startActivity(intent);
result.success("success");
} else {
result.notImplemented();
}
}
});
}

private int getBatteryLevel() {
int batteryLevel;
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
batteryLevel = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
} else {
Intent intent = new ContextWrapper(getApplicationContext()).
registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
batteryLevel = (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) /
intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
}

return batteryLevel;
}

}
19 changes: 19 additions & 0 deletions android/app/src/main/res/layout/activity_welcome.xml
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context=".AboutActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:lineSpacingExtra="5dp"
android:gravity="center_vertical"
android:textColor="#000000"
android:text="天阅是一款采用flutter编写的阅读app,主要涉及到flutter自定义组件,与原生的通信,跳转原生界面" />

</android.support.constraint.ConstraintLayout>
Binary file added img/2.0x/actionbar_checkin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/actionbar_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/aliuser_title_back_normal.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/arrow_right.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_cloud_0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_cloud_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_cloud_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_cloud_3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/bookshelf_continue_read.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_chapter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_fold_bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_latest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_star.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_star_half.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/detail_write_comment.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/home_search.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/home_tip.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/icon_menu_catalog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/icon_menu_share.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/me_action.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/me_buy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.0x/me_comment.png
Binary file added img/2.0x/me_coupon.png
Binary file added img/2.0x/me_date.png
Binary file added img/2.0x/me_favorite.png
Binary file added img/2.0x/me_feedback.png
Binary file added img/2.0x/me_gift.png
Binary file added img/2.0x/me_night.png
Binary file added img/2.0x/me_record.png
Binary file added img/2.0x/me_setting.png
Binary file added img/2.0x/me_theme.png
Binary file added img/2.0x/me_vip.png
Binary file added img/2.0x/me_wallet.png
Binary file added img/2.0x/menu_category.png
Binary file added img/2.0x/menu_complete.png
Binary file added img/2.0x/menu_publish.png
Binary file added img/2.0x/menu_rank.png
Binary file added img/2.0x/menu_vip.png
Binary file added img/2.0x/placeholder_avatar.png
Binary file added img/2.0x/pub_back_gray.png
Binary file added img/2.0x/pub_back_white.png
Binary file added img/2.0x/read_bg.png
Binary file added img/2.0x/read_icon_brightness.png
Binary file added img/2.0x/read_icon_catalog.png
Binary file added img/2.0x/read_icon_chapter_next.png
Binary file added img/2.0x/read_icon_chapter_previous.png
Binary file added img/2.0x/read_icon_font.png
Binary file added img/2.0x/read_icon_more.png
Binary file added img/2.0x/read_icon_setting.png
Binary file added img/2.0x/read_icon_vip.png
Binary file added img/2.0x/read_icon_voice.png
Binary file added img/2.0x/read_more_detail.png
Binary file added img/2.0x/reader_battery.png
Binary file added img/2.0x/tab_bookshelf_n.png
Binary file added img/2.0x/tab_bookshelf_p.png
Binary file added img/2.0x/tab_bookstore_n.png
Binary file added img/2.0x/tab_bookstore_p.png
Binary file added img/2.0x/tab_me_n.png
Binary file added img/2.0x/tab_me_p.png
Binary file added img/2.0x/tab_writer_n.png
Binary file added img/2.0x/tab_writer_p.png
Binary file added img/actionbar_checkin.png
Binary file added img/actionbar_search.png
Binary file added img/aliuser_title_back_normal.9.png
Binary file added img/arrow_right.png
Binary file added img/bookshelf_add.png
Binary file added img/bookshelf_bg.png
Binary file added img/bookshelf_cloud_0.png
Binary file added img/bookshelf_cloud_1.png
Binary file added img/bookshelf_cloud_2.png
Binary file added img/bookshelf_cloud_3.png
Binary file added img/bookshelf_continue_read.png
Binary file added img/detail_chapter.png
Binary file added img/detail_down.png
Binary file added img/detail_fold_bg.png
Binary file added img/detail_latest.png
Binary file added img/detail_star.png
Binary file added img/detail_star_half.png
Binary file added img/detail_up.png
Binary file added img/detail_write_comment.png
Binary file added img/home_search.png
Binary file added img/home_tip.png
Binary file added img/icon_menu_catalog.png
Binary file added img/icon_menu_share.png
Binary file added img/me_action.png
Binary file added img/me_buy.png
Binary file added img/me_comment.png
Binary file added img/me_coupon.png
Binary file added img/me_date.png
Binary file added img/me_favorite.png
Binary file added img/me_feedback.png
Binary file added img/me_gift.png
Binary file added img/me_night.png
Binary file added img/me_record.png
Binary file added img/me_setting.png
Binary file added img/me_theme.png
Binary file added img/me_vip.png
Binary file added img/me_wallet.png
Binary file added img/menu_category.png
Binary file added img/menu_complete.png
Binary file added img/menu_publish.png
Binary file added img/menu_rank.png
Binary file added img/menu_vip.png
Binary file added img/placeholder_avatar.png
Binary file added img/pub_back_gray.png
Binary file added img/pub_back_white.png
Binary file added img/read_bg.png
Binary file added img/read_icon_brightness.png
Binary file added img/read_icon_catalog.png
Binary file added img/read_icon_chapter_next.png
Binary file added img/read_icon_chapter_previous.png
Binary file added img/read_icon_font.png
Binary file added img/read_icon_more.png
Binary file added img/read_icon_setting.png
Binary file added img/read_icon_vip.png
Binary file added img/read_icon_voice.png
Binary file added img/read_more_detail.png
Binary file added img/reader_battery.png
Binary file added img/tab_bookshelf_n.png
Binary file added img/tab_bookshelf_p.png
Binary file added img/tab_bookstore_n.png
Binary file added img/tab_bookstore_p.png
Binary file added img/tab_me_n.png
Binary file added img/tab_me_p.png
Binary file added img/tab_writer_n.png
Binary file added img/tab_writer_p.png
1 change: 1 addition & 0 deletions ios/Flutter/Debug.xcconfig
@@ -1 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions ios/Flutter/Release.xcconfig
@@ -1 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
69 changes: 69 additions & 0 deletions 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
41 changes: 41 additions & 0 deletions lib/app/app_navigator.dart
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';

import 'package:tianyue/public.dart';

import 'package:tianyue/novel_detail/novel_detail_scene.dart';
import 'package:tianyue/me/login_scene.dart';
import 'package:tianyue/me/web_scene.dart';
import 'package:tianyue/reader/reader_scene.dart';

class AppNavigator {
static push(BuildContext context, Widget scene) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => scene,
),
);
}

static pushNovelDetail(BuildContext context, Novel novel) {
AppNavigator.push(context, NovelDetailScene(novel.id));
}

static pushLogin(BuildContext context) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return LoginScene();
}));
}

static pushWeb(BuildContext context, String url, String title) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return WebScene(url: url, title: title);
}));
}

static pushReader(BuildContext context, int articleId) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return ReaderScene(articleId: articleId);
}));
}
}
23 changes: 23 additions & 0 deletions lib/app/app_scene.dart
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:tianyue/app/splash_scene.dart';
import 'package:tianyue/public.dart';

final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();

class AppScene extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'tianyue',
navigatorObservers: [routeObserver],
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Colors.white,
dividerColor: Color(0xffeeeeee),
scaffoldBackgroundColor: TYColor.paper,
textTheme: TextTheme(body1: TextStyle(color: TYColor.darkGray)),
),
home: SplashScene(),
);
}
}
1 change: 1 addition & 0 deletions lib/app/constant.dart
@@ -0,0 +1 @@
const String EventToggleTabBarIndex = 'EventToggleTabBarIndex';

0 comments on commit 394c0b5

Please sign in to comment.