├── 36627.jpg
├── Chapter_5
├── App.js
├── android
│ ├── app
│ │ ├── BUCK
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── shudan
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── MainApplication.java
│ │ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── logo.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── logo.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── keystores
│ │ ├── BUCK
│ │ └── debug.keystore.properties
│ ├── local.properties
│ └── settings.gradle
├── app.json
├── app
│ ├── common
│ │ ├── CommonStyle.js
│ │ └── Constant.js
│ ├── component
│ │ └── BaseComponent.js
│ ├── img
│ │ ├── default.png
│ │ ├── default_icon@2x.png
│ │ ├── default_icon@3x.png
│ │ ├── drawer_arrow@2x.png
│ │ ├── drawer_arrow@3x.png
│ │ ├── drawer_icon1@2x.png
│ │ ├── drawer_icon1@3x.png
│ │ ├── drawer_icon2@2x.png
│ │ ├── drawer_icon2@3x.png
│ │ ├── drawer_icon3@2x.png
│ │ ├── drawer_icon3@3x.png
│ │ ├── home_unselect@2x.png
│ │ ├── home_unselect@3x.png
│ │ ├── icon1@2x.png
│ │ ├── icon1@3x.png
│ │ ├── icon2@2x.png
│ │ ├── icon2@3x.png
│ │ ├── icon3@2x.png
│ │ ├── icon3@3x.png
│ │ ├── login_btn@2x.png
│ │ ├── login_btn@3x.png
│ │ ├── me_dianzan@2x.png
│ │ ├── me_dianzan@3x.png
│ │ ├── me_header@2x.png
│ │ ├── me_header@3x.png
│ │ ├── me_like@2x.png
│ │ ├── me_like@3x.png
│ │ ├── me_lingqu@2x.png
│ │ ├── me_lingqu@3x.png
│ │ ├── me_rect@2x.png
│ │ ├── me_rect@3x.png
│ │ ├── me_selected@2x.png
│ │ ├── me_selected@3x.png
│ │ ├── me_setting@2x.png
│ │ ├── me_setting@3x.png
│ │ ├── me_shoucang@2x.png
│ │ ├── me_shoucang@3x.png
│ │ ├── register_btn@2x.png
│ │ ├── register_btn@3x.png
│ │ ├── register_header@2x.png
│ │ ├── register_header@3x.png
│ │ ├── right_arrow.png
│ │ ├── shudan_dianzan@2x.png
│ │ ├── shudan_dianzan@3x.png
│ │ ├── shudan_shoucang@2x.png
│ │ ├── shudan_shoucang@3x.png
│ │ ├── shudan_underline@2x.png
│ │ ├── shudan_underline@3x.png
│ │ ├── shudan_unshoucang@2x.png
│ │ └── shudan_unshoucang@3x.png
│ ├── navigate
│ │ └── AppStack.js
│ ├── util
│ │ ├── AsyncStorageUtil.js
│ │ ├── HttpUtil.js
│ │ ├── StringUtil.js
│ │ └── ToastUtil.js
│ └── view
│ │ ├── account
│ │ └── MeView.js
│ │ ├── drawer
│ │ └── DrawerView.js
│ │ ├── login
│ │ ├── LoginView.js
│ │ ├── RegisterView.js
│ │ └── SplashView.js
│ │ └── shudan
│ │ ├── ShanDanListView.js
│ │ ├── ShuDanDetailView.js
│ │ └── ShuDanView.js
├── index.js
├── ios
│ ├── ShuDan-tvOS
│ │ └── Info.plist
│ ├── ShuDan-tvOSTests
│ │ └── Info.plist
│ ├── ShuDan.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ ├── ShuDan-tvOS.xcscheme
│ │ │ └── ShuDan.xcscheme
│ ├── ShuDan
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj
│ │ │ └── LaunchScreen.xib
│ │ ├── Images.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── icon-1024.png
│ │ │ │ ├── icon-20@2x.png
│ │ │ │ ├── icon-20@3x.png
│ │ │ │ ├── icon-29@2x.png
│ │ │ │ ├── icon-29@3x.png
│ │ │ │ ├── icon-40@2x.png
│ │ │ │ ├── icon-40@3x.png
│ │ │ │ ├── icon-60@2x.png
│ │ │ │ └── icon-60@3x.png
│ │ │ ├── Contents.json
│ │ │ └── logo.png
│ │ ├── Info.plist
│ │ └── main.m
│ ├── ShuDanTests
│ │ ├── Info.plist
│ │ └── ShuDanTests.m
│ └── bundle
│ │ ├── assets
│ │ └── app
│ │ │ └── img
│ │ │ ├── default.png
│ │ │ ├── default_icon@2x.png
│ │ │ ├── default_icon@3x.png
│ │ │ ├── drawer_arrow@2x.png
│ │ │ ├── drawer_arrow@3x.png
│ │ │ ├── drawer_icon1@2x.png
│ │ │ ├── drawer_icon1@3x.png
│ │ │ ├── drawer_icon2@2x.png
│ │ │ ├── drawer_icon2@3x.png
│ │ │ ├── drawer_icon3@2x.png
│ │ │ ├── drawer_icon3@3x.png
│ │ │ ├── home_unselect@2x.png
│ │ │ ├── home_unselect@3x.png
│ │ │ ├── icon1@2x.png
│ │ │ ├── icon1@3x.png
│ │ │ ├── icon2@2x.png
│ │ │ ├── icon2@3x.png
│ │ │ ├── icon3@2x.png
│ │ │ ├── icon3@3x.png
│ │ │ ├── login_btn@2x.png
│ │ │ ├── login_btn@3x.png
│ │ │ ├── me_dianzan@2x.png
│ │ │ ├── me_dianzan@3x.png
│ │ │ ├── me_header@2x.png
│ │ │ ├── me_header@3x.png
│ │ │ ├── me_like@2x.png
│ │ │ ├── me_like@3x.png
│ │ │ ├── me_lingqu@2x.png
│ │ │ ├── me_lingqu@3x.png
│ │ │ ├── me_rect@2x.png
│ │ │ ├── me_rect@3x.png
│ │ │ ├── me_selected@2x.png
│ │ │ ├── me_selected@3x.png
│ │ │ ├── me_setting@2x.png
│ │ │ ├── me_setting@3x.png
│ │ │ ├── me_shoucang@2x.png
│ │ │ ├── me_shoucang@3x.png
│ │ │ ├── register_btn@2x.png
│ │ │ ├── register_btn@3x.png
│ │ │ ├── register_header@2x.png
│ │ │ ├── register_header@3x.png
│ │ │ ├── shudan_dianzan@2x.png
│ │ │ ├── shudan_dianzan@3x.png
│ │ │ ├── shudan_shoucang@2x.png
│ │ │ ├── shudan_shoucang@3x.png
│ │ │ ├── shudan_underline@2x.png
│ │ │ └── shudan_underline@3x.png
│ │ └── index.jsbundle.meta
├── package-lock.json
├── package.json
├── shudan.keystore
└── yarn.lock
├── Chapter_6
├── app.js
├── app.json
├── app.wxss
├── pages
│ ├── container-base
│ │ ├── container-base.js
│ │ ├── container-base.json
│ │ ├── container-base.wxml
│ │ └── container-base.wxss
│ ├── container-form
│ │ ├── container-form.js
│ │ ├── container-form.json
│ │ ├── container-form.wxml
│ │ └── container-form.wxss
│ ├── container-map
│ │ ├── container-map.js
│ │ ├── container-map.json
│ │ ├── container-map.wxml
│ │ └── container-map.wxss
│ ├── container-media
│ │ ├── container-media.js
│ │ ├── container-media.json
│ │ ├── container-media.wxml
│ │ └── container-media.wxss
│ ├── container-scroll-view
│ │ ├── container-scroll-view.js
│ │ ├── container-scroll-view.json
│ │ ├── container-scroll-view.wxml
│ │ └── container-scroll-view.wxss
│ ├── container-swiper
│ │ ├── container-swiper.js
│ │ ├── container-swiper.json
│ │ ├── container-swiper.wxml
│ │ └── container-swiper.wxss
│ ├── container-view
│ │ ├── container-view.js
│ │ ├── container-view.json
│ │ ├── container-view.wxml
│ │ └── container-view.wxss
│ ├── container-web-view
│ │ ├── container-web-view.js
│ │ ├── container-web-view.json
│ │ ├── container-web-view.wxml
│ │ └── container-web-view.wxss
│ └── tab1
│ │ ├── tab1.js
│ │ ├── tab1.json
│ │ ├── tab1.wxml
│ │ └── tab1.wxss
└── project.config.json
├── Chapter_7
├── app.js
├── app.json
├── app.wxss
├── config
│ ├── api.js
│ └── config.js
├── images
│ ├── book.jpg
│ ├── detail
│ │ ├── ic_agree_2x.png
│ │ ├── ic_favorite_normal_2x.png
│ │ └── ic_favorite_selected_2x.png
│ ├── logo.png
│ ├── mine
│ │ ├── bg_mine_hot_2x.png
│ │ ├── btn_get_2x.png
│ │ ├── ic_agree_2x.png
│ │ ├── ic_collect_2x.png
│ │ └── ic_favorite_2x.png
│ ├── sign_in
│ │ └── btn_sign_in_2x.png
│ ├── sign_up
│ │ ├── bg_avatar_2x.png
│ │ └── btn_sign_up_2x.png
│ └── tabbar
│ │ ├── ic_home_normal_2x.png
│ │ ├── ic_home_selected_2x.png
│ │ ├── ic_mine_normal_2x.png
│ │ └── ic_mine_selected_2x.png
├── pages
│ ├── detail
│ │ ├── detail.js
│ │ ├── detail.json
│ │ ├── detail.wxml
│ │ └── detail.wxss
│ ├── favorite
│ │ ├── favorite.js
│ │ ├── favorite.json
│ │ ├── favorite.wxml
│ │ └── favorite.wxss
│ ├── home
│ │ ├── home.js
│ │ ├── home.json
│ │ ├── home.wxml
│ │ └── home.wxss
│ ├── mine
│ │ ├── mine.js
│ │ ├── mine.json
│ │ ├── mine.wxml
│ │ └── mine.wxss
│ ├── settings
│ │ ├── settings.js
│ │ ├── settings.wxml
│ │ └── settings.wxss
│ ├── sign-in
│ │ ├── sign-in.js
│ │ ├── sign-in.json
│ │ ├── sign-in.wxml
│ │ └── sign-in.wxss
│ └── sign-up
│ │ ├── sign-up.js
│ │ ├── sign-up.json
│ │ ├── sign-up.wxml
│ │ └── sign-up.wxss
├── project.config.json
├── sitemap.json
└── utils
│ ├── data.js
│ ├── date.js
│ └── money.js
├── Chapter_9
├── README.md
├── android
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── yugangtalk
│ │ │ │ └── read
│ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── icon_logo.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── images
│ ├── icon_arrow_right.png
│ ├── icon_collection.png
│ ├── icon_home.png
│ ├── icon_home_default.png
│ ├── icon_love.png
│ ├── icon_love_card.png
│ ├── icon_my.png
│ ├── icon_my_default.png
│ ├── icon_praise.png
│ ├── icon_setting.png
│ ├── icon_star.png
│ ├── icon_star_checked.png
│ ├── icon_star_default.png
│ ├── icon_user.png
│ ├── img_bg.png
│ ├── img_book_card.png
│ ├── img_book_yskf.jpg
│ ├── img_card.png
│ ├── img_header.jpeg
│ ├── img_login.png
│ └── img_register.png
├── ios
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── icon_logo58.png
│ │ │ └── icon_logo87.png
│ │ ├── Contents.json
│ │ ├── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ └── LaunchImage.launchimage
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── main.m
├── lib
│ ├── api
│ │ ├── Api.dart
│ │ └── NetUtils.dart
│ ├── common
│ │ ├── ColorsUtil.dart
│ │ ├── DbProvider.dart
│ │ └── DialogUtils.dart
│ ├── main.dart
│ ├── models
│ │ ├── Book.dart
│ │ ├── BookTab.dart
│ │ ├── Comment.dart
│ │ └── Constants.dart
│ ├── pages
│ │ ├── BookDetailPage.dart
│ │ ├── BookList.dart
│ │ ├── BookStore.dart
│ │ ├── CollectBooksPage.dart
│ │ ├── DrawerPage.dart
│ │ ├── LoginPage.dart
│ │ ├── MyInfoPage.dart
│ │ ├── RegisterPage.dart
│ │ └── SettingPage.dart
│ └── widgets
│ │ └── CommentBar.dart
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── LICENSE.md
└── README.md
/36627.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/36627.jpg
--------------------------------------------------------------------------------
/Chapter_5/App.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | * @flow
5 | */
6 |
7 | import React, { Component } from 'react';
8 | import {
9 | Platform,
10 | StyleSheet,
11 | Text,
12 | View,
13 | BackHandler
14 | } from 'react-native';
15 | import { RootStack } from './app/navigate/AppStack';
16 |
17 | export default class App extends Component {
18 | constructor(props) {
19 | super(props);
20 |
21 | }
22 |
23 | render() {
24 | return (
25 |
26 | );
27 | }
28 | }
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | lib_deps = []
12 |
13 | for jarfile in glob(['libs/*.jar']):
14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15 | lib_deps.append(':' + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
21 | for aarfile in glob(['libs/*.aar']):
22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23 | lib_deps.append(':' + name)
24 | android_prebuilt_aar(
25 | name = name,
26 | aar = aarfile,
27 | )
28 |
29 | android_library(
30 | name = "all-libs",
31 | exported_deps = lib_deps,
32 | )
33 |
34 | android_library(
35 | name = "app-code",
36 | srcs = glob([
37 | "src/main/java/**/*.java",
38 | ]),
39 | deps = [
40 | ":all-libs",
41 | ":build_config",
42 | ":res",
43 | ],
44 | )
45 |
46 | android_build_config(
47 | name = "build_config",
48 | package = "com.shudan",
49 | )
50 |
51 | android_resource(
52 | name = "res",
53 | package = "com.shudan",
54 | res = "src/main/res",
55 | )
56 |
57 | android_binary(
58 | name = "app",
59 | keystore = "//android/keystores:debug",
60 | manifest = "src/main/AndroidManifest.xml",
61 | package_type = "debug",
62 | deps = [
63 | ":app-code",
64 | ],
65 | )
66 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Disabling obfuscation is useful if you collect stack traces from production crashes
20 | # (unless you are using a system that supports de-obfuscate the stack traces).
21 | -dontobfuscate
22 |
23 | # React Native
24 |
25 | # Keep our interfaces so they can be used by other ProGuard rules.
26 | # See http://sourceforge.net/p/proguard/bugs/466/
27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
30 |
31 | # Do not strip any method/class that is annotated with @DoNotStrip
32 | -keep @com.facebook.proguard.annotations.DoNotStrip class *
33 | -keep @com.facebook.common.internal.DoNotStrip class *
34 | -keepclassmembers class * {
35 | @com.facebook.proguard.annotations.DoNotStrip *;
36 | @com.facebook.common.internal.DoNotStrip *;
37 | }
38 |
39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
40 | void set*(***);
41 | *** get*();
42 | }
43 |
44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; }
46 | -keepclassmembers,includedescriptorclasses class * { native ; }
47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; }
48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; }
49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; }
50 |
51 | -dontwarn com.facebook.react.**
52 |
53 | # TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
54 | # See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
55 | -dontwarn android.text.StaticLayout
56 |
57 | # okhttp
58 |
59 | -keepattributes Signature
60 | -keepattributes *Annotation*
61 | -keep class okhttp3.** { *; }
62 | -keep interface okhttp3.** { *; }
63 | -dontwarn okhttp3.**
64 |
65 | # okio
66 |
67 | -keep class sun.misc.Unsafe { *; }
68 | -dontwarn java.nio.file.*
69 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
70 | -dontwarn okio.**
71 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
13 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/java/com/shudan/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.shudan;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 | public class MainActivity extends ReactActivity {
6 |
7 | /**
8 | * Returns the name of the main component registered from JavaScript.
9 | * This is used to schedule rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "ShuDan";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/java/com/shudan/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.shudan;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.react.ReactApplication;
6 | import com.facebook.react.ReactNativeHost;
7 | import com.facebook.react.ReactPackage;
8 | import com.facebook.react.shell.MainReactPackage;
9 | import com.facebook.soloader.SoLoader;
10 |
11 | import java.util.Arrays;
12 | import java.util.List;
13 |
14 | public class MainApplication extends Application implements ReactApplication {
15 |
16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
17 | @Override
18 | public boolean getUseDeveloperSupport() {
19 | return BuildConfig.DEBUG;
20 | }
21 |
22 | @Override
23 | protected List getPackages() {
24 | return Arrays.asList(
25 | new MainReactPackage()
26 | );
27 | }
28 |
29 | @Override
30 | protected String getJSMainModuleName() {
31 | return "index";
32 | }
33 | };
34 |
35 | @Override
36 | public ReactNativeHost getReactNativeHost() {
37 | return mReactNativeHost;
38 | }
39 |
40 | @Override
41 | public void onCreate() {
42 | super.onCreate();
43 | SoLoader.init(this, /* native exopackage */ false);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/mipmap-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/app/src/main/res/mipmap-xhdpi/logo.png
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/mipmap-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/app/src/main/res/mipmap-xxhdpi/logo.png
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShuDan
3 |
4 |
--------------------------------------------------------------------------------
/Chapter_5/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chapter_5/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | mavenLocal()
18 | jcenter()
19 | maven {
20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21 | url "$rootDir/../node_modules/react-native/android"
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Chapter_5/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | android.useDeprecatedNdk=true
21 | STORE_FILE=../../shudan.keystore
22 | KEY_ALIAS=shudan-alias
23 | STORE_FILE_PASSWORD=123456
24 | KEY_ALIAS_PASSWORD=123456
--------------------------------------------------------------------------------
/Chapter_5/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Chapter_5/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
6 |
--------------------------------------------------------------------------------
/Chapter_5/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Chapter_5/android/keystores/BUCK:
--------------------------------------------------------------------------------
1 | keystore(
2 | name = "debug",
3 | properties = "debug.keystore.properties",
4 | store = "debug.keystore",
5 | visibility = [
6 | "PUBLIC",
7 | ],
8 | )
9 |
--------------------------------------------------------------------------------
/Chapter_5/android/keystores/debug.keystore.properties:
--------------------------------------------------------------------------------
1 | key.store=debug.keystore
2 | key.alias=androiddebugkey
3 | key.store.password=android
4 | key.alias.password=android
5 |
--------------------------------------------------------------------------------
/Chapter_5/android/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Tue Jan 15 21:34:52 CST 2019
8 | sdk.dir=D\:\\mySpace\\android\\android-sdk
9 |
--------------------------------------------------------------------------------
/Chapter_5/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'ShuDan'
2 |
3 | include ':app'
4 |
--------------------------------------------------------------------------------
/Chapter_5/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ShuDan",
3 | "displayName": "ShuDan"
4 | }
--------------------------------------------------------------------------------
/Chapter_5/app/common/CommonStyle.js:
--------------------------------------------------------------------------------
1 | import{StyleSheet}from'react-native';
2 |
3 | const CommonStyle= StyleSheet.create({
4 | root:{
5 | flex:1,
6 | backgroundColor:'#F4F4F4'
7 | }
8 | });
9 |
10 | export default CommonStyle;
--------------------------------------------------------------------------------
/Chapter_5/app/common/Constant.js:
--------------------------------------------------------------------------------
1 | import{Dimensions}from'react-native';
2 |
3 | const Constant={
4 | screenWidth:Dimensions.get('window').width,
5 | screenHeight:Dimensions.get('window').height,
6 | baseUrl:'http://renyugang.io/api/read.php?'
7 | }
8 |
9 | export default Constant;
--------------------------------------------------------------------------------
/Chapter_5/app/component/BaseComponent.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { BackHandler } from 'react-native';
3 | class BaseComponent extends Component {
4 | constructor(props) {
5 | super(props);
6 | this.backHandler = BackHandler.addEventListener('hardwareBackPress', this._onBackAndroid);
7 | }
8 | componentWillMount() {
9 |
10 | }
11 | componentWillUnmount() {
12 | this.backHandler && this.backHandler.remove();
13 | }
14 |
15 | _onBackAndroid = () => {
16 | if (!this.props.navigation) {
17 | return false;
18 | }
19 | let { routeName } = this.props.navigation.state;
20 | if (routeName == "Login" || routeName == 'ShuDan'||routeName=='Me') {
21 | BackHandler.exitApp()
22 | return true;
23 | }else{
24 | this.props.navigation.goBack();
25 | return true;
26 | }
27 | }
28 |
29 | }
30 |
31 | export default BaseComponent;
--------------------------------------------------------------------------------
/Chapter_5/app/img/default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/default.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/default_icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/default_icon@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/default_icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/default_icon@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_arrow@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_arrow@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_arrow@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_arrow@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_icon1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_icon1@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_icon1@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_icon1@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_icon2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_icon2@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_icon2@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_icon2@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_icon3@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_icon3@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/drawer_icon3@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/drawer_icon3@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/home_unselect@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/home_unselect@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/home_unselect@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/home_unselect@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/icon1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/icon1@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/icon1@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/icon1@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/icon2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/icon2@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/icon2@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/icon2@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/icon3@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/icon3@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/icon3@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/icon3@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/login_btn@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/login_btn@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/login_btn@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/login_btn@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_dianzan@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_dianzan@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_dianzan@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_dianzan@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_header@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_header@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_header@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_header@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_like@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_like@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_like@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_like@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_lingqu@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_lingqu@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_lingqu@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_lingqu@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_rect@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_rect@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_rect@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_rect@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_selected@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_selected@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_selected@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_selected@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_setting@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_setting@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_setting@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_setting@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_shoucang@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_shoucang@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/me_shoucang@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/me_shoucang@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/register_btn@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/register_btn@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/register_btn@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/register_btn@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/register_header@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/register_header@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/register_header@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/register_header@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/right_arrow.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_dianzan@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_dianzan@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_dianzan@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_dianzan@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_shoucang@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_shoucang@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_shoucang@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_shoucang@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_underline@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_underline@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_underline@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_underline@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_unshoucang@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_unshoucang@2x.png
--------------------------------------------------------------------------------
/Chapter_5/app/img/shudan_unshoucang@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/app/img/shudan_unshoucang@3x.png
--------------------------------------------------------------------------------
/Chapter_5/app/navigate/AppStack.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Image, Text, View } from 'react-native';
3 | import { createBottomTabNavigator, createDrawerNavigator, createStackNavigator, } from 'react-navigation';
4 | import ShuDanView from '../view/shudan/ShuDanView';
5 | import MeView from '../view/account/MeView';
6 | import SplashView from '../view/login/SplashView';
7 | import LoginView from '../view/login/LoginView';
8 | import RegisterView from '../view/login/RegisterView';
9 | import ShuDanDetailView from '../view/shudan/ShuDanDetailView';
10 | import DrawerView from '../view/drawer/DrawerView';
11 | import Constant from '../common/Constant';
12 |
13 | export const TabBottomBar = createBottomTabNavigator({
14 | ShuDan: {
15 | screen: ShuDanView,
16 | navigationOptions: {
17 | tabBarPosition: 'bottom',
18 | tabBarLabel: '首页',
19 |
20 | tabBarIcon: ({ focused, tintColor }) => {
21 | let imgSource = focused ? require('../img/icon2.png') : require('../img/home_unselect.png');
22 | return ;
24 | }
25 | }
26 | },
27 | Me: {
28 | screen: MeView,
29 | navigationOptions: {
30 | tabBarPosition: 'bottom',
31 | tabBarLabel: '我的',
32 |
33 | tabBarIcon: ({ focused, tintColor }) => {
34 | let imgSource = focused ? require('../img/me_selected.png') : require('../img/icon3.png');
35 | return ;
36 | },
37 | }
38 | }
39 | },
40 | {
41 | tabBarOptions: {
42 | activeTintColor: ' #636362',
43 | }
44 | }
45 | );
46 |
47 |
48 |
49 |
50 |
51 | export const StackNavigator = createStackNavigator(
52 | {
53 | Splash: {
54 | screen: SplashView,
55 | navigationOptions: {
56 | header: null
57 | }
58 | },
59 | Login: {
60 | screen: LoginView,
61 | navigationOptions: {
62 | header: null
63 | }
64 | },
65 | Register: {
66 | screen: RegisterView,
67 | navigationOptions: {
68 | title: '注册'
69 | }
70 | },
71 | ShuDanDetail: {
72 | screen: ShuDanDetailView,
73 | navigationOptions: {
74 | title: '书单详情'
75 | }
76 | },
77 | Tab: {
78 | screen: TabBottomBar,
79 | navigationOptions: {
80 | header: null
81 | }
82 | }
83 | },
84 | {
85 | initialRouteName: 'Splash',
86 | navigationOptions: {
87 | headerStyle: {
88 | backgroundColor: '#353535',
89 | height: 44
90 | },
91 | headerTintColor: '#FFFFFF',
92 | headerTitleStyle: {
93 | fontWeight: 'bold',
94 | flex: 1,
95 | textAlign: 'center',
96 | fontSize: 18
97 | },
98 | headerRight:
99 | }
100 | }
101 | );
102 |
103 | export const RootStack = createDrawerNavigator({
104 | Tab: {
105 | screen: StackNavigator,
106 | navigationOptions: {
107 | drawerLabel:
108 | }
109 | }
110 | })
111 |
--------------------------------------------------------------------------------
/Chapter_5/app/util/AsyncStorageUtil.js:
--------------------------------------------------------------------------------
1 | import { AsyncStorage } from 'react-native';
2 | /**
3 | * 持久存储工具
4 | */
5 |
6 | var AsyncStorageUtil = {
7 | setValue: function (key, value, callBcak) {
8 | if (value) {
9 | return AsyncStorage.setItem(key, value, (error) => callBcak(error));
10 | }
11 | },
12 | setValues: function (multiParis, callBcak) {
13 | if (multiParis) {
14 | return AsyncStorage.multiSet(multiParis, (errors) => callBcak(errors));
15 | }
16 | },
17 | getValue: function (key, callBcak) {
18 |
19 | return AsyncStorage.getItem(key, (error, result) => callBcak(error, result));
20 | },
21 | removeValue: function (key, callBcak) {
22 |
23 | return AsyncStorage.removeItem(key, (error) => callBcak(error));
24 | }
25 | }
26 |
27 | export default AsyncStorageUtil;
28 |
--------------------------------------------------------------------------------
/Chapter_5/app/util/HttpUtil.js:
--------------------------------------------------------------------------------
1 | import { toastShort } from './ToastUtil';
2 |
3 | function httpFetch(url, method, formData, callBack) {
4 |
5 | let headParams = {
6 | 'Content-Type': 'application/x-www-form-urlencoded',
7 | 'Param-Decode': 'false',
8 | }
9 | let paramsArray = [];
10 |
11 | if (formData) {
12 | Object.keys(formData).forEach(key => {
13 | formData[key] ? paramsArray.push(key + '=' + encodeURIComponent(formData[key])) : ''
14 | });
15 | }
16 | let parms = {
17 | method: method,
18 | headers: headParams,
19 | timeout: 10 * 1000,
20 | body: method === 'GET' ? null : paramsArray.join('&'),
21 | }
22 |
23 |
24 | fetch(url, parms).then((response) => {
25 | if (response.ok) {
26 |
27 | return response.json();
28 | } else {
29 | if (callBack.onError) {
30 | callBack.onError(response.code, "")
31 | } else {
32 | toastShort(response.code, false)
33 | }
34 | }
35 | }).then((responseJson) => {
36 | // console.log("http:" + url + "response:" + JSON.parse(responseJson));
37 | if (responseJson&&responseJson.code==0) {
38 | callBack.onSuccess(responseJson);
39 | }else{
40 | if(callBack.onError){
41 | callBack.onError(responseJson.code,responseJson.message);
42 | }
43 | }
44 | }).catch((error) => {
45 | // console.log("http:" + url + "response:" + error);
46 | let errMsg = error.toString();
47 | if (callBack.onError) {
48 | callBack.onError("-1", errMsg);
49 | } else {
50 | toastShort(errMsg, false);
51 | }
52 | })
53 | }
54 |
55 | export { httpFetch };
--------------------------------------------------------------------------------
/Chapter_5/app/util/StringUtil.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 判断是否未空
3 | * @param {*字符串} str
4 | */
5 | export function isEmpity(str){
6 | if(str==null||str==""||str.legth==0){
7 | return true;
8 | }
9 | return false;
10 | }
--------------------------------------------------------------------------------
/Chapter_5/app/util/ToastUtil.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * 弹框的工具类
4 | */
5 | import { Alert, ToastAndroid, Platform } from 'react-native';
6 |
7 | export const toastShort = (content, isAlert) => {
8 | if (isAlert || Platform.OS === 'ios') {
9 | setTimeout(() => { Alert.alert('提示', content.toString()) }, 500);
10 | } else {
11 | ToastAndroid.show(content.toString(), ToastAndroid.SHORT);
12 | }
13 | };
14 |
15 | export const promptEvent = (content, isAlert) => {
16 | if (isAlert || Platform.OS === 'ios') {
17 | setTimeout(() => { Alert.alert('提示', content.toString()) }, 500);
18 | } else {
19 | ToastAndroid.show(content.toString(), ToastAndroid.SHORT);
20 | }
21 | };
22 |
23 | export const toastLong = (content, isAlert) => {
24 | if (isAlert || Platform.OS === 'ios') {
25 | Alert.alert('提示', content.toString());
26 | } else {
27 | ToastAndroid.show(content.toString(), ToastAndroid.LONG);
28 | }
29 | };
--------------------------------------------------------------------------------
/Chapter_5/app/view/drawer/DrawerView.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Text, View, StyleSheet, BackHandler, Image, TouchableOpacity, ImageBackground } from 'react-native';
3 | import CommonStyle from '../../common/CommonStyle';
4 |
5 | class DrawerView extends Component {
6 | render() {
7 | return (
8 |
9 |
10 |
11 |
14 |
15 |
16 | Jack
17 |
18 | 送给程序员的爱心书单
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | );
32 | }
33 | }
34 | const styles = StyleSheet.create({
35 | imgbackground: {
36 | width: '100%',
37 | height: 185,
38 | marginTop: 10,
39 | marginBottom: 10,
40 | justifyContent: 'center'
41 | },
42 | text_name: {
43 | flexDirection: 'row',
44 | alignItems: 'center',
45 | marginLeft: 16
46 | },
47 | img: {
48 | position: 'absolute',
49 | bottom: 0,
50 | right: 0
51 | },
52 | text_desc: {
53 | color: '#FFFFFF',
54 | fontSize: 14, marginTop: 16,
55 | marginLeft: 16
56 | },
57 | top_text: {
58 | color: '#FFFFFF',
59 | fontSize: 14,
60 | marginLeft: 10
61 | },
62 | bottom_view: {
63 | borderBottomColor: '#828181',
64 | borderBottomWidth: 0.5,
65 | flexDirection: 'row',
66 | justifyContent: 'space-between',
67 | marginTop: 42,
68 | paddingBottom: 16,
69 | marginLeft: 8,
70 | marginRight: 8
71 | },
72 | top_view: {
73 | flexDirection: 'row',
74 | alignItems: 'center',
75 | marginLeft: 16
76 |
77 | }
78 | })
79 | export default DrawerView;
--------------------------------------------------------------------------------
/Chapter_5/app/view/login/SplashView.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { View, Text, StyleSheet, Image } from 'react-native';
3 | import BaseComponent from '../../component/BaseComponent';
4 | import AsyncStorageUtil from '../../util/AsyncStorageUtil';
5 | class SplashView extends BaseComponent {
6 | static navigationOptions = {
7 | headerStyle: {
8 | height: 0
9 | }
10 |
11 | };
12 | /**
13 | * 设置定时器
14 | */
15 | componentDidMount() {
16 | this.timer = setTimeout(() => {
17 | AsyncStorageUtil.getValue("userName", (error, result) => {
18 | if (result) {
19 | this.props.navigation.navigate('Tab');
20 | }else{
21 | this.props.navigation.navigate('Login');
22 | }
23 | });
24 |
25 | }, 1000);
26 | }
27 | /**
28 | * 清除定时器
29 | */
30 | componentWillUnmount() {
31 | this.timer && clearTimeout(this.timer);
32 | }
33 | render() {
34 | return (
35 |
36 |
37 |
38 | );
39 | }
40 | }
41 |
42 |
43 | const styles = StyleSheet.create({
44 | root: {
45 | alignItems: "center",
46 | justifyContent: "center",
47 | backgroundColor:'#FFFFFF',
48 | flex:1
49 | }
50 | })
51 |
52 | export default SplashView
--------------------------------------------------------------------------------
/Chapter_5/app/view/shudan/ShanDanListView.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Text, View, StyleSheet, FlatList, TouchableOpacity, Image } from 'react-native';
3 | import Constant from '../../common/Constant';
4 | import { httpFetch } from '../../util/HttpUtil';
5 | class ShanDanListView extends Component {
6 |
7 | constructor(props) {
8 | super(props);
9 | this.state = {
10 | shuDanItemArray: [],
11 | }
12 | }
13 | /**
14 | * item的点击事件,在该方法中调用书单组件的onPress()方法
15 | */
16 | onPress = (id) => {
17 | this.props.onPress(id);
18 | }
19 |
20 | componentDidMount = () => {
21 | this.getList();
22 | }
23 |
24 | getList = () => {
25 | let url = Constant.baseUrl + 'action=list&q=' + this.props.tabLabel;
26 | let _this = this;
27 | let callBack = {
28 | onSuccess(resultObject) {
29 | _this.setState({
30 | shuDanItemArray: _this.state.shuDanItemArray.concat(resultObject.data)
31 | });
32 | },
33 | onError(code, errorMsg) {
34 |
35 | }
36 | };
37 | httpFetch(url, 'GET', null, callBack);
38 | }
39 | /**
40 | * 返回每个Item的布局
41 | */
42 | renderItem = ({ item }) => {
43 | let imageSource = require('../../img/default.png');
44 | if (item.image) {
45 | imageSource = { uri: item.image };
46 | }
47 | return ( this.onPress(item.id)}>
48 |
49 |
50 | {item.name}
51 | )
52 | }
53 |
54 | render() {
55 | return (
56 |
62 | );
63 | }
64 | }
65 | const styles = StyleSheet.create({
66 | item_root: {
67 | alignItems: 'center',
68 | marginTop: 42
69 | },
70 | img: {
71 | width: 100,
72 | height: 140,
73 | borderWidth: 1,
74 | backgroundColor: '#FFFFFF',
75 | borderColor: '#B9B9BB'
76 | },
77 | text: {
78 | color: '#343434',
79 | fontSize: 12,
80 | marginTop: 12
81 | }
82 |
83 | })
84 |
85 | export default ShanDanListView;
--------------------------------------------------------------------------------
/Chapter_5/app/view/shudan/ShuDanView.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Text, View, StyleSheet, FlatList, TouchableOpacity, Image } from 'react-native';
3 | import ScrollableTabView, { ScrollableTabBar } from 'react-native-scrollable-tab-view';
4 | import ShanDanListView from './ShanDanListView';
5 | import BaseComponent from '../../component/BaseComponent';
6 | import { httpFetch } from '../../util/HttpUtil';
7 | import Constant from '../../common/Constant';
8 | import CommonStyle from '../../common/CommonStyle';
9 | class ShuDanView extends BaseComponent {
10 |
11 |
12 | constructor(props) {
13 | super(props);
14 | this.state = {
15 | shuDanTabsArray: []
16 | }
17 | }
18 |
19 | componentDidMount = () => {
20 | this.getTabs();
21 | }
22 |
23 | getTabs = () => {
24 | let url = Constant.baseUrl + 'action=category';
25 | let _this = this;
26 | let callBack = {
27 | onSuccess(resultObject) {
28 | _this.setState({
29 | shuDanTabsArray: _this.state.shuDanTabsArray.concat(resultObject.data)
30 | });
31 |
32 | },
33 | onError(code, errorMsg) {
34 |
35 | }
36 | };
37 | httpFetch(url, 'GET', null, callBack);
38 | }
39 | /**
40 | * 点击列表Item的回调并调用路由的跳转方法,第二个参数是传递到下一个页面的参数
41 | */
42 | onPress = (id) => {
43 | this.props.navigation.navigate('ShuDanDetail', { id: id });
44 | }
45 |
46 | /**
47 | * 返回列表组件
48 | */
49 | renderList = () => {
50 | return (
51 | this.state.shuDanTabsArray.map((value, index) => {
52 | return this.onPress(id)}
55 | />
56 | })
57 | )
58 | }
59 |
60 |
61 | render() {
62 | return (
63 |
64 |
65 |
66 | 首页
67 |
68 |
69 |
70 | }
73 | style={{ flex: 1, backgroundColor: '#EAE9E7' }}
74 | tabBarBackgroundColor="#FFFFFF"
75 | tabBarActiveTextColor="#636362"
76 | tabBarUnderlineStyle={styles.line_view}
77 | >
78 | {
79 | this.renderList()
80 | }
81 |
82 |
83 |
84 | );
85 | }
86 | }
87 |
88 | const styles = StyleSheet.create({
89 | header_layout: {
90 | flexDirection: 'row',
91 | alignItems: 'center',
92 | justifyContent: 'space-between',
93 | height: 44,
94 | backgroundColor: '#353535',
95 | paddingLeft: 20,
96 | paddingRight: 20
97 | },
98 | header_text: { color: '#FFFFFF',
99 | fontSize: 18, alignSelf: 'center' },
100 | line_view: { backgroundColor: '#636362', height: 2 }
101 | })
102 | export default ShuDanView;
--------------------------------------------------------------------------------
/Chapter_5/index.js:
--------------------------------------------------------------------------------
1 | import { AppRegistry } from 'react-native';
2 | import App from './App';
3 |
4 | AppRegistry.registerComponent('ShuDan', () => App);
5 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan-tvOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UIViewControllerBasedStatusBarAppearance
38 |
39 | NSLocationWhenInUseUsageDescription
40 |
41 | NSAppTransportSecurity
42 |
43 |
44 | NSExceptionDomains
45 |
46 | localhost
47 |
48 | NSExceptionAllowsInsecureHTTPLoads
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan-tvOSTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 |
10 | @interface AppDelegate : UIResponder
11 |
12 | @property (nonatomic, strong) UIWindow *window;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import "AppDelegate.h"
9 |
10 | #import
11 | #import
12 |
13 | @implementation AppDelegate
14 |
15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16 | {
17 | NSURL *jsCodeLocation;
18 |
19 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
20 |
21 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
22 | moduleName:@"ShuDan"
23 | initialProperties:nil
24 | launchOptions:launchOptions];
25 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
26 |
27 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
28 | UIViewController *rootViewController = [UIViewController new];
29 | rootViewController.view = rootView;
30 | self.window.rootViewController = rootViewController;
31 | [self.window makeKeyAndVisible];
32 | return YES;
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "icon-20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "icon-20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-29@2x.png",
19 | "scale" : "2x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "icon-29@3x.png",
25 | "scale" : "3x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-40@2x.png",
31 | "scale" : "2x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "icon-40@3x.png",
37 | "scale" : "3x"
38 | },
39 | {
40 | "size" : "60x60",
41 | "idiom" : "iphone",
42 | "filename" : "icon-60@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-60@3x.png",
49 | "scale" : "3x"
50 | },
51 | {
52 | "size" : "1024x1024",
53 | "idiom" : "ios-marketing",
54 | "filename" : "icon-1024.png",
55 | "scale" : "1x"
56 | }
57 | ],
58 | "info" : {
59 | "version" : 1,
60 | "author" : "xcode"
61 | }
62 | }
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-1024.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-20@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-20@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-29@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-29@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-40@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-40@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-60@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/AppIcon.appiconset/icon-60@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Images.xcassets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/ShuDan/Images.xcassets/logo.png
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ShuDan
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UIViewControllerBasedStatusBarAppearance
40 |
41 | NSLocationWhenInUseUsageDescription
42 |
43 | NSAppTransportSecurity
44 |
45 | NSAllowsArbitraryLoads
46 |
47 | NSExceptionDomains
48 |
49 | localhost
50 |
51 | NSExceptionAllowsInsecureHTTPLoads
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDan/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 |
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDanTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Chapter_5/ios/ShuDanTests/ShuDanTests.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 | #import
10 |
11 | #import
12 | #import
13 |
14 | #define TIMEOUT_SECONDS 600
15 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
16 |
17 | @interface ShuDanTests : XCTestCase
18 |
19 | @end
20 |
21 | @implementation ShuDanTests
22 |
23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
24 | {
25 | if (test(view)) {
26 | return YES;
27 | }
28 | for (UIView *subview in [view subviews]) {
29 | if ([self findSubviewInView:subview matching:test]) {
30 | return YES;
31 | }
32 | }
33 | return NO;
34 | }
35 |
36 | - (void)testRendersWelcomeScreen
37 | {
38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
40 | BOOL foundElement = NO;
41 |
42 | __block NSString *redboxError = nil;
43 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
44 | if (level >= RCTLogLevelError) {
45 | redboxError = message;
46 | }
47 | });
48 |
49 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
50 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
51 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
52 |
53 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
54 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
55 | return YES;
56 | }
57 | return NO;
58 | }];
59 | }
60 |
61 | RCTSetLogFunction(RCTDefaultLogFunction);
62 |
63 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
64 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
65 | }
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/default.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/default_icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/default_icon@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/default_icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/default_icon@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_arrow@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_arrow@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_arrow@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_arrow@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_icon1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_icon1@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_icon1@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_icon1@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_icon2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_icon2@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_icon2@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_icon2@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_icon3@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_icon3@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/drawer_icon3@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/drawer_icon3@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/home_unselect@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/home_unselect@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/home_unselect@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/home_unselect@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/icon1@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/icon1@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/icon1@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/icon1@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/icon2@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/icon2@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/icon2@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/icon2@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/icon3@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/icon3@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/icon3@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/icon3@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/login_btn@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/login_btn@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/login_btn@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/login_btn@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_dianzan@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_dianzan@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_dianzan@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_dianzan@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_header@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_header@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_header@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_header@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_like@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_like@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_like@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_like@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_lingqu@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_lingqu@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_lingqu@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_lingqu@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_rect@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_rect@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_rect@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_rect@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_selected@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_selected@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_selected@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_selected@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_setting@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_setting@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_setting@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_setting@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_shoucang@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_shoucang@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/me_shoucang@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/me_shoucang@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/register_btn@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/register_btn@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/register_btn@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/register_btn@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/register_header@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/register_header@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/register_header@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/register_header@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/shudan_dianzan@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/shudan_dianzan@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/shudan_dianzan@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/shudan_dianzan@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/shudan_shoucang@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/shudan_shoucang@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/shudan_shoucang@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/shudan_shoucang@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/shudan_underline@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/shudan_underline@2x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/assets/app/img/shudan_underline@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/assets/app/img/shudan_underline@3x.png
--------------------------------------------------------------------------------
/Chapter_5/ios/bundle/index.jsbundle.meta:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/ios/bundle/index.jsbundle.meta
--------------------------------------------------------------------------------
/Chapter_5/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ShuDanApp",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node node_modules/react-native/local-cli/cli.js start",
7 | "test": "jest",
8 | "bundle-ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file index.js --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle"
9 | },
10 | "dependencies": {
11 | "react": "16.3.0-alpha.0",
12 | "react-native": "0.55.0",
13 | "react-native-scrollable-tab-view": "^0.8.0",
14 | "react-navigation": "^2.11.2"
15 | },
16 | "devDependencies": {
17 | "babel-jest": "23.4.2",
18 | "babel-preset-react-native": "4.0.0",
19 | "jest": "23.5.0",
20 | "react-test-renderer": "16.3.0-alpha.0"
21 | },
22 | "jest": {
23 | "preset": "react-native"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Chapter_5/shudan.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_5/shudan.keystore
--------------------------------------------------------------------------------
/Chapter_6/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 |
5 | },
6 | globalData: {
7 | }
8 | })
--------------------------------------------------------------------------------
/Chapter_6/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/tab1/tab1",
4 | "pages/container-view/container-view",
5 | "pages/container-scroll-view/container-scroll-view",
6 | "pages/container-swiper/container-swiper",
7 | "pages/container-base/container-base",
8 | "pages/container-form/container-form",
9 | "pages/container-media/container-media",
10 | "pages/container-map/container-map",
11 | "pages/container-web-view/container-web-view"
12 | ],
13 | "window": {
14 | "backgroundTextStyle": "light",
15 | "navigationBarBackgroundColor": "#fff",
16 | "navigationBarTitleText": "DEMO",
17 | "navigationBarTextStyle": "black"
18 | }
19 | }
--------------------------------------------------------------------------------
/Chapter_6/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-base/container-base.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 | text: "这是一个 text!"
5 | },
6 | onLoad: function (options) {
7 |
8 | },
9 | onReady: function () {
10 |
11 | },
12 | onShow: function () {
13 |
14 | },
15 | onHide: function () {
16 |
17 | },
18 | onUnload: function () {
19 |
20 | }
21 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-base/container-base.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "基础组件"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-base/container-base.wxml:
--------------------------------------------------------------------------------
1 |
2 | text
3 |
4 | {{text}}
5 | {{text}}
6 | {{text}}
7 |
8 | progress
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-base/container-base.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | }
4 |
5 | .title {
6 | height: 100rpx;
7 | color: #808080;
8 | line-height: 100rpx;
9 | font-size: 32rpx;
10 | margin: 20rpx 40rpx;
11 | }
12 |
13 | .item-container {
14 | margin: 20rpx 40rpx;
15 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-form/container-form.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data: {
3 | checkBoxItems: [
4 | { name: 'USA', value: '美国' },
5 | { name: 'CHN', value: '中国', checked: 'true' },
6 | { name: 'BRA', value: '巴西' },
7 | { name: 'JPN', value: '日本' },
8 | { name: 'ENG', value: '英国' },
9 | { name: 'TUR', value: '法国' }],
10 | radioItems: [
11 | { name: '男', value: '1' },
12 | { name: '女', value: '2', checked: 'true' }],
13 | array: ['美国', '中国', '巴西', '日本'],
14 | index: 1
15 | },
16 | onLoad: function (options) {
17 |
18 |
19 | },
20 | onReady: function () {
21 |
22 | },
23 | onShow: function () {
24 |
25 | },
26 | onHide: function () {
27 |
28 | },
29 | onUnload: function () {
30 |
31 | },
32 | checkboxChange: function (e) {
33 | console.log('checkbox 发生 change 事件,携带 value 值为:', e.detail.value);
34 | },
35 | radioChange: function (e) {
36 | console.log('radio 发生 change 事件,携带 value 值为:', e.detail.value);
37 | },
38 | formSubmit: function () {
39 | console.log('表单提交 formSubmit');
40 | },
41 | formReset: function () {
42 | console.log('表单重置 formReset');
43 | },
44 | sliderChange: function (e) {
45 | console.log('slider 发生 change 事件,携带 value 值为:', e.detail.value);
46 | },
47 | switchChange: function (e) {
48 | console.log('switch 发生 change 事件,携带 value 值为:', e.detail.value);
49 | }
50 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-form/container-form.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "表单组件"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-form/container-form.wxml:
--------------------------------------------------------------------------------
1 |
2 | button
3 |
4 |
5 |
6 |
7 |
8 | checkbox
9 |
10 |
11 |
15 |
16 |
17 | radio
18 |
19 |
20 |
24 |
25 |
26 | input
27 |
28 |
29 |
30 | textarea
31 |
32 |
33 |
34 | form
35 |
36 |
40 |
41 | slider
42 |
43 |
44 |
45 | switch
46 |
47 |
48 |
49 | picker
50 |
51 |
52 | 当前选择:{{array[index]}}
53 |
54 |
55 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-form/container-form.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | }
4 |
5 | .title {
6 | height: 100rpx;
7 | color: #808080;
8 | line-height: 100rpx;
9 | font-size: 32rpx;
10 | margin: 20rpx 40rpx;
11 | }
12 |
13 | .item-container {
14 | margin: 20rpx 40rpx;
15 | }
16 |
17 | button {
18 | margin-top: 20rpx;
19 | }
20 |
21 | input, textarea {
22 | background-color: #ffffff;
23 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-map/container-map.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 | },
5 | onLoad: function (options) {
6 |
7 | },
8 | onReady: function () {
9 |
10 | },
11 | onShow: function () {
12 |
13 | },
14 | onHide: function () {
15 |
16 | },
17 | onUnload: function () {
18 |
19 | }
20 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-map/container-map.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "map"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-map/container-map.wxml:
--------------------------------------------------------------------------------
1 |
2 | map
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-map/container-map.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | }
4 |
5 | .title {
6 | height: 100rpx;
7 | color: #808080;
8 | line-height: 100rpx;
9 | font-size: 32rpx;
10 | margin: 20rpx 40rpx;
11 | }
12 |
13 | .item-container {
14 | margin: 20rpx 40rpx;
15 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-media/container-media.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 | poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
5 | name: '此时此刻',
6 | author: '许巍',
7 | audioSrc: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46',
8 | },
9 | onLoad: function (options) {
10 |
11 | },
12 | onReady: function () {
13 | // 使用 wx.createAudioContext 获取 audio 上下文 context
14 | this.audioCtx = wx.createAudioContext('myAudio')
15 |
16 | // 使用 wx.createVideoContext 获取 video 上下文 context
17 | this.videoContext = wx.createVideoContext('myVideo')
18 | },
19 | onShow: function () {
20 |
21 | },
22 | onHide: function () {
23 |
24 | },
25 | onUnload: function () {
26 |
27 | },
28 | audioPlay: function () {
29 | this.audioCtx.play()
30 | },
31 | audioPause: function () {
32 | this.audioCtx.pause()
33 | },
34 | audio14: function () {
35 | this.audioCtx.seek(14)
36 | },
37 | audioStart: function () {
38 | this.audioCtx.seek(0)
39 | },
40 | bindButtonTap: function () {
41 | var that = this
42 | wx.chooseVideo({
43 | sourceType: ['album', 'camera'],
44 | maxDuration: 60,
45 | camera: ['front', 'back'],
46 | success: function (res) {
47 | that.setData({
48 | src: res.tempFilePath
49 | })
50 | }
51 | })
52 | }
53 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-media/container-media.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "媒体组件"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-media/container-media.wxml:
--------------------------------------------------------------------------------
1 |
2 | image
3 |
4 |
5 |
6 | audio
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | video
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-media/container-media.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | }
4 |
5 | .title {
6 | height: 100rpx;
7 | color: #808080;
8 | line-height: 100rpx;
9 | font-size: 32rpx;
10 | margin: 20rpx 40rpx;
11 | }
12 |
13 | .item-container {
14 | margin: 20rpx 40rpx;
15 | }
16 |
17 | button {
18 | margin-top: 20rpx;
19 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-scroll-view/container-scroll-view.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 |
5 | },
6 | onLoad: function (options) {
7 |
8 | },
9 | onReady: function () {
10 |
11 | },
12 | onShow: function () {
13 |
14 | },
15 | onHide: function () {
16 |
17 | },
18 | onUnload: function () {
19 |
20 | }
21 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-scroll-view/container-scroll-view.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "scroll-view"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-scroll-view/container-scroll-view.wxml:
--------------------------------------------------------------------------------
1 |
2 | 横向滚动
3 |
4 |
5 | A
6 | B
7 | C
8 |
9 |
10 | 纵向滚动
11 |
12 |
13 | A
14 | B
15 | C
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-scroll-view/container-scroll-view.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | padding: 40rpx;
4 | }
5 |
6 | .title {
7 | height: 100rpx;
8 | color: #808080;
9 | line-height: 100rpx;
10 | font-size: 32rpx;
11 | margin-top: 20rpx;
12 | }
13 |
14 | .scroll-view {
15 | width: 500rpx;
16 | height: 300rpx;
17 | }
18 |
19 | .flex-row {
20 | width: 1200rpx;
21 | height: 300rpx;
22 | display: flex;
23 | flex-direction: row;
24 | flex-wrap: nowrap;
25 | justify-content: center;
26 | align-content: center;
27 | align-items: center;
28 | }
29 |
30 | .flex-row view {
31 | width: 400rpx;
32 | height: 300rpx;
33 | text-align: center;
34 | line-height: 300rpx;
35 | }
36 |
37 | .flex-column {
38 | width: 500rpx;
39 | height: 600rpx;
40 | }
41 |
42 | .flex-column view {
43 | width: 500rpx;
44 | height: 200rpx;
45 | text-align: center;
46 | line-height: 200rpx;
47 | }
48 |
49 | .a {
50 | background-color: chocolate;
51 | }
52 |
53 | .b {
54 | background-color: bisque;
55 | }
56 |
57 | .c {
58 | background-color: cadetblue;
59 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-swiper/container-swiper.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 |
5 | },
6 | onLoad: function (options) {
7 |
8 | },
9 | onReady: function () {
10 |
11 | },
12 | onShow: function () {
13 |
14 | },
15 | onHide: function () {
16 |
17 | },
18 | onUnload: function () {
19 |
20 | }
21 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-swiper/container-swiper.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "swiper"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-swiper/container-swiper.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-swiper/container-swiper.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | padding: 40rpx 0;
4 | }
5 |
6 | swiper {
7 | width: 100%;
8 | height: 400rpx;
9 | }
10 |
11 | .a {
12 | width: 100%;
13 | height: 400rpx;
14 | background-color: chocolate;
15 | }
16 |
17 | .b {
18 | width: 100%;
19 | height: 400rpx;
20 | background-color: bisque;
21 | }
22 |
23 | .c {
24 | width: 100%;
25 | height: 400rpx;
26 | background-color: cadetblue;
27 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-view/container-view.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 |
5 | },
6 | onLoad: function (options) {
7 |
8 | },
9 | onReady: function () {
10 |
11 | },
12 | onShow: function () {
13 |
14 | },
15 | onHide: function () {
16 |
17 | },
18 | onUnload: function () {
19 |
20 | }
21 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-view/container-view.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "view"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-view/container-view.wxml:
--------------------------------------------------------------------------------
1 |
2 | 横向布局
3 |
4 | A
5 | B
6 | C
7 |
8 | 纵向布局
9 |
10 | A
11 | B
12 | C
13 |
14 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-view/container-view.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | padding: 40rpx;
4 | }
5 |
6 | .title {
7 | height: 100rpx;
8 | color: #808080;
9 | line-height: 100rpx;
10 | font-size: 32rpx;
11 | margin-top: 20rpx;
12 | }
13 |
14 | .flex-row {
15 | display: flex;
16 | flex-direction: row;
17 | flex-wrap: nowrap;
18 | justify-content: center;
19 | align-content: center;
20 | align-items: center;
21 | }
22 |
23 | .flex-row view {
24 | width: 150rpx;
25 | height: 300rpx;
26 | text-align: center;
27 | line-height: 300rpx;
28 | }
29 |
30 | .flex-column {
31 | display: flex;
32 | flex-direction: column;
33 | flex-wrap: nowrap;
34 | justify-content: center;
35 | align-content: center;
36 | align-items: center;
37 | }
38 |
39 | .flex-column view {
40 | width: 300rpx;
41 | height: 150rpx;
42 | text-align: center;
43 | line-height: 150rpx;
44 | }
45 |
46 | .a {
47 | background-color: chocolate;
48 | }
49 |
50 | .b {
51 | background-color: bisque;
52 | }
53 |
54 | .c {
55 | background-color: cadetblue;
56 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-web-view/container-web-view.js:
--------------------------------------------------------------------------------
1 | Page({
2 |
3 | data: {
4 | },
5 | onLoad: function (options) {
6 |
7 | },
8 | onReady: function () {
9 |
10 | },
11 | onShow: function () {
12 |
13 | },
14 | onHide: function () {
15 |
16 | },
17 | onUnload: function () {
18 |
19 | }
20 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/container-web-view/container-web-view.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "web-view"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/container-web-view/container-web-view.wxml:
--------------------------------------------------------------------------------
1 |
2 | web-view
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Chapter_6/pages/container-web-view/container-web-view.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | background-color: #f2f2f2;
3 | }
4 |
5 | .title {
6 | height: 100rpx;
7 | color: #808080;
8 | line-height: 100rpx;
9 | font-size: 32rpx;
10 | margin: 20rpx 40rpx;
11 | }
12 |
13 | .item-container {
14 | margin: 20rpx 40rpx;
15 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/tab1/tab1.js:
--------------------------------------------------------------------------------
1 | // pages/tab1/tab1.js
2 | Page({
3 |
4 | data: {
5 |
6 | },
7 | onLoad: function (options) {
8 |
9 | },
10 | onReady: function () {
11 |
12 | },
13 | onShow: function () {
14 |
15 | },
16 | onHide: function () {
17 |
18 | },
19 | onUnload: function () {
20 |
21 | },
22 | toView: function () {
23 | wx.navigateTo({ url: '/pages/container-view/container-view' });
24 | },
25 | toScrollView: function () {
26 | wx.navigateTo({ url: '/pages/container-scroll-view/container-scroll-view' });
27 | },
28 | toSwiper: function () {
29 | wx.navigateTo({ url: '/pages/container-swiper/container-swiper' });
30 | },
31 | toBase: function () {
32 | wx.navigateTo({ url: '/pages/container-base/container-base' });
33 | },
34 | toForm: function () {
35 | wx.navigateTo({ url: '/pages/container-form/container-form' });
36 | },
37 | toMedia: function () {
38 | wx.navigateTo({ url: '/pages/container-media/container-media' });
39 | },
40 | toMap: function () {
41 | wx.navigateTo({ url: '/pages/container-map/container-map' });
42 | },
43 | toWebView: function () {
44 | wx.navigateTo({ url: '/pages/container-web-view/container-web-view' });
45 | },
46 | })
--------------------------------------------------------------------------------
/Chapter_6/pages/tab1/tab1.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "常用组件"
3 | }
--------------------------------------------------------------------------------
/Chapter_6/pages/tab1/tab1.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 视图容器
5 | view
6 | scroll-view
7 | swiper
8 |
9 |
10 | 基础内容
11 | text
12 | progress
13 |
14 |
15 | 表单组件
16 | button
17 | checkbox
18 | radio
19 | input
20 | textarea
21 | form
22 | slider
23 | switch
24 | picker
25 |
26 |
27 | 媒体组件
28 | image
29 | audio
30 | video
31 |
32 |
33 | 地图
34 | map
35 |
36 |
37 | 开放能力
38 | web-view
39 |
40 |
--------------------------------------------------------------------------------
/Chapter_6/pages/tab1/tab1.wxss:
--------------------------------------------------------------------------------
1 | /* pages/tab1/tab1.wxss */
2 |
3 | page {
4 | background-color: #f2f2f2;
5 | padding-bottom: 40rpx;
6 | }
7 |
8 | .item-container {
9 | background-color: #fff;
10 | margin: 20rpx 40rpx 0;
11 | padding: 10rpx 40rpx;
12 | }
13 |
14 | .item-container .title {
15 | height: 100rpx;
16 | color: #808080;
17 | line-height: 100rpx;
18 | font-size: 32rpx;
19 | }
20 |
21 | .item-container .item {
22 | height: 100rpx;
23 | line-height: 100rpx;
24 | font-size: 42rpx;
25 | border-top: 2rpx solid #f2f2f2;
26 | }
--------------------------------------------------------------------------------
/Chapter_6/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件",
3 | "packOptions": {
4 | "ignore": []
5 | },
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": true,
9 | "postcss": true,
10 | "minified": true,
11 | "newFeature": true
12 | },
13 | "compileType": "miniprogram",
14 | "libVersion": "2.3.2",
15 | "appid": "wxb718b9428af58220",
16 | "projectname": "Demo",
17 | "debugOptions": {
18 | "hidedInDevtools": []
19 | },
20 | "isGameTourist": false,
21 | "condition": {
22 | "search": {
23 | "current": -1,
24 | "list": []
25 | },
26 | "conversation": {
27 | "current": -1,
28 | "list": []
29 | },
30 | "game": {
31 | "currentL": -1,
32 | "list": []
33 | },
34 | "miniprogram": {
35 | "current": -1,
36 | "list": []
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Chapter_7/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 |
5 | },
6 | globalData: {
7 | userInfo: null
8 | }
9 | })
--------------------------------------------------------------------------------
/Chapter_7/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/home/home",
4 | "pages/sign-in/sign-in",
5 | "pages/sign-up/sign-up",
6 | "pages/settings/settings",
7 | "pages/mine/mine",
8 | "pages/detail/detail",
9 | "pages/favorite/favorite"
10 | ],
11 | "window": {
12 | "backgroundTextStyle": "light",
13 | "navigationBarBackgroundColor": "#353535",
14 | "navigationBarTitleText": "WeChat",
15 | "navigationBarTextStyle": "white"
16 | },
17 | "tabBar": {
18 | "color": "#636362",
19 | "selectedColor": "#636362",
20 | "backgroundColor": "#EAE9E7",
21 | "borderStyle": "white",
22 | "list": [
23 | {
24 | "pagePath": "pages/home/home",
25 | "iconPath": "images/tabbar/ic_home_normal_2x.png",
26 | "selectedIconPath": "images/tabbar/ic_home_selected_2x.png",
27 | "text": "首页"
28 | },
29 | {
30 | "pagePath": "pages/mine/mine",
31 | "iconPath": "images/tabbar/ic_mine_normal_2x.png",
32 | "selectedIconPath": "images/tabbar/ic_mine_selected_2x.png",
33 | "text": "我的"
34 | }
35 | ]
36 | },
37 | "sitemapLocation": "sitemap.json"
38 | }
--------------------------------------------------------------------------------
/Chapter_7/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 |
3 | page, view, scroll-view, swiper, icon, text, progress, button, checkbox, form, input, label, picker, picker-view, radio, slider, switch, textarea, navigator, image, map, canvas, web-view, cover-view {
4 | box-sizing: border-box;
5 | }
6 |
7 | page {
8 | background-color: #eae9e7;
9 | font-family: PingFangSC-Regular;
10 | }
--------------------------------------------------------------------------------
/Chapter_7/config/api.js:
--------------------------------------------------------------------------------
1 | let host = "http://renyugang.io/api/read.php";
2 |
3 |
4 | module.exports = {
5 | host: host,
6 |
7 | };
--------------------------------------------------------------------------------
/Chapter_7/config/config.js:
--------------------------------------------------------------------------------
1 | // pages/config/config.js
2 |
3 | module.exports = {
4 | cacheKey: { //配置缓存中的key,方便统一管理
5 | userInfo: "userInfo",
6 | username: "username",
7 | password: "password",
8 | favoriteBooks: "favoriteBooks",
9 | }
10 | };
--------------------------------------------------------------------------------
/Chapter_7/images/book.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/book.jpg
--------------------------------------------------------------------------------
/Chapter_7/images/detail/ic_agree_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/detail/ic_agree_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/detail/ic_favorite_normal_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/detail/ic_favorite_normal_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/detail/ic_favorite_selected_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/detail/ic_favorite_selected_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/logo.png
--------------------------------------------------------------------------------
/Chapter_7/images/mine/bg_mine_hot_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/mine/bg_mine_hot_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/mine/btn_get_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/mine/btn_get_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/mine/ic_agree_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/mine/ic_agree_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/mine/ic_collect_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/mine/ic_collect_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/mine/ic_favorite_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/mine/ic_favorite_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/sign_in/btn_sign_in_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/sign_in/btn_sign_in_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/sign_up/bg_avatar_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/sign_up/bg_avatar_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/sign_up/btn_sign_up_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/sign_up/btn_sign_up_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/tabbar/ic_home_normal_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/tabbar/ic_home_normal_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/tabbar/ic_home_selected_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/tabbar/ic_home_selected_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/tabbar/ic_mine_normal_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/tabbar/ic_mine_normal_2x.png
--------------------------------------------------------------------------------
/Chapter_7/images/tabbar/ic_mine_selected_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_7/images/tabbar/ic_mine_selected_2x.png
--------------------------------------------------------------------------------
/Chapter_7/pages/detail/detail.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "图书详情"
3 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/detail/detail.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | {{bookInfo.name}}
8 | {{isMarked?'已收藏':'收藏'}}
9 |
10 | {{bookInfo.introduce}}
11 |
12 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Chapter_7/pages/favorite/favorite.js:
--------------------------------------------------------------------------------
1 | // pages/favorite/favorite.js
2 | import config from '../../config/config.js';
3 |
4 | Page({
5 | data: {
6 | dataList: []
7 | },
8 | onLoad: function (query) {
9 | //读取收藏的图书列表
10 | let favoriteBooks = wx.getStorageSync(config.cacheKey.favoriteBooks);
11 | this.setData({
12 | dataList: favoriteBooks
13 | });
14 | },
15 | onItemClick: function (e) {//图书点击跳转到详情页
16 | let item = e.currentTarget.dataset.item;
17 | wx.navigateTo({
18 | url: "/pages/detail/detail?id=" + item.id + "&name=" + item.name
19 | });
20 | }
21 | })
--------------------------------------------------------------------------------
/Chapter_7/pages/favorite/favorite.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "收藏"
3 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/favorite/favorite.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | {{item.name}}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Chapter_7/pages/favorite/favorite.wxss:
--------------------------------------------------------------------------------
1 | /* pages/favorite/favorite.wxss */
2 |
3 | .list-container {
4 | width: 100%;
5 | padding: 40rpx 0;
6 | }
7 |
8 | .list-container .item {
9 | width: 100%;
10 | height: 200rpx;
11 | padding: 0 80rpx;
12 | line-height: 200rpx;
13 | margin-top: 10rpx;
14 | background-color: #ffffff;
15 | /* 使用 flex 布局 */
16 | display: flex;
17 | /* 方向为纵向 */
18 | flex-direction: row;
19 | /* 设置为不可换行 */
20 | flex-wrap: nowrap;
21 | /* 从左边开始布局 */
22 | justify-content: flex-start;
23 | /* 垂直居中 */
24 | align-content: center;
25 | align-items: center;
26 | }
27 |
28 | .list-container .item .cover {
29 | width: 160rpx;
30 | height: 160rpx;
31 | }
32 |
33 | .list-container .item .title {
34 | margin-left: 20rpx;
35 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/home/home.js:
--------------------------------------------------------------------------------
1 | // pages/home/home.js
2 | import config from '../../config/config.js';
3 | import data from '../../utils/data.js';
4 |
5 | Page({
6 | data: {
7 | tabList: [],
8 | currentTabIndex: 0, //当前选择的 tab
9 | dataList: []
10 | },
11 | onLoad: function (options) {
12 | //读取用户登录信息
13 | let userInfo = wx.getStorageSync(config.cacheKey.userInfo);
14 | if (userInfo) { //用户已登录,则直将用户信息保存到全局变量中
15 | getApp().globalData.userInfo = userInfo;
16 | this.toLoadData();
17 | } else {
18 | wx.reLaunch({ //用户未登录,则直接跳转至登录页面
19 | url: "/pages/sign-in/sign-in"
20 | });
21 | }
22 | },
23 | toLoadData: function () {
24 | this.setData({
25 | tabList: data.home.tabList,
26 | dataList: data.home.dataList
27 | });
28 | },
29 | onTabItemClick: function (e) {
30 | console.error(e);
31 | let item = e.currentTarget.dataset.item;
32 | let index = e.currentTarget.dataset.index;
33 | this.setData({
34 | currentTabIndex: index
35 | });
36 | },
37 | onItemClick: function (e) {
38 | let item = e.currentTarget.dataset.item;
39 | wx.navigateTo({ //通过 url 传递参数,是不是跟 html 很像?
40 | url: "/pages/detail/detail?id=" + item.id + "&name=" + item.name
41 | });
42 | }
43 | });
--------------------------------------------------------------------------------
/Chapter_7/pages/home/home.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "首页"
3 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/home/home.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | {{item.name}}
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Chapter_7/pages/home/home.wxss:
--------------------------------------------------------------------------------
1 | /* pages/home/home.wxss */
2 |
3 | page {
4 | background-color: #F4F4F4;
5 | }
6 |
7 | .tab-menu {
8 | min-width: 750rpx;
9 | height: 104rpx;
10 | background-color: #EAE9E7;
11 | /* 使用 flex 布局 */
12 | display: flex;
13 | /* 方向为纵向 */
14 | flex-direction: row;
15 | /* 设置为不可换行 */
16 | flex-wrap: nowrap;
17 | /* 从左边开始布局 */
18 | justify-content: flex-start;
19 | /* 垂直居中 */
20 | align-content: center;
21 | align-items: center;
22 | padding: 0 34rpx;
23 | }
24 |
25 | .tab-menu .item {
26 | height: 74rpx;
27 | line-height: 74rpx;
28 | padding: 0 10rpx;
29 | margin-right: 34rpx;
30 | font-size: 28rpx;
31 | font-family: SourceHanSansCN-Medium;
32 | font-weight: bold;
33 | color: rgba(99, 99, 98, 1);
34 | }
35 |
36 | .tab-menu .active {
37 | border-bottom: #636362 solid 4rpx;
38 | }
39 |
40 | .list-container {
41 | width: 100%;
42 | padding: 60rpx 0 60rpx 60rpx;
43 | /* 使用 flex 布局 */
44 | display: flex;
45 | /* 方向为纵向 */
46 | flex-direction: row;
47 | /* 设置为可换行 */
48 | flex-wrap: wrap;
49 | /* 从左边开始布局 */
50 | justify-content: flex-start;
51 | /* 垂直居中 */
52 | align-content: center;
53 | align-items: center;
54 | }
55 |
56 | .list-container .item {
57 | /* 这里使用到了 css 中的 calc 计算函数,详见下面介绍 */
58 | width: calc((100% - 180rpx) / 3);
59 | margin-right: 60rpx;
60 | margin-top: 20rpx;
61 | border-radius: 10rpx;
62 | padding: 5rpx;
63 | }
64 |
65 | .list-container .item .cover {
66 | width: 100%;
67 | height: 240rpx;
68 | border: 2rpx solid #B9B9BB;
69 | background-color: #ffffff;
70 | border-radius: 6rpx;
71 | }
72 |
73 | .list-container .item .cover image {
74 | width: 100%;
75 | height: 100%;
76 | }
77 |
78 | .list-container .item .name {
79 | text-align: center;
80 | height: 70rpx;
81 | font-size: 24rpx;
82 | font-family: SourceHanSansCN-Medium;
83 | font-weight: 500;
84 | color: rgba(52, 52, 52, 1);
85 | line-height: 70rpx;
86 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/mine/mine.js:
--------------------------------------------------------------------------------
1 | // pages/mine/mine.js
2 |
3 | Page({
4 | data: {
5 | userInfo: null
6 | },
7 | onLoad: function (options) {
8 | this.setData({ //读取全局数据保存到当前页面中
9 | userInfo: getApp().globalData.userInfo
10 | });
11 | },
12 | onReady: function () { },
13 | onShow: function () { },
14 | onHide: function () { },
15 | onUnload: function () { },
16 | toFavorite: function () {
17 | wx.navigateTo({
18 | url: '/pages/favorite/favorite'
19 | });
20 | },
21 | toSettings: function () {
22 | wx.navigateTo({
23 | url: '/pages/settings/settings'
24 | });
25 | }
26 | })
--------------------------------------------------------------------------------
/Chapter_7/pages/mine/mine.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "我的"
3 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/mine/mine.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{userInfo.username}}
5 |
6 |
7 |
8 |
9 |
10 | 强力推荐卡
11 | 最给力的书单都在这里
12 |
13 |
14 |
15 |
16 |
17 |
18 | 我想要的书籍
19 | 我收藏的书籍
20 | 设置
21 |
22 |
--------------------------------------------------------------------------------
/Chapter_7/pages/mine/mine.wxss:
--------------------------------------------------------------------------------
1 | /* pages/mine/mine.wxss */
2 |
3 | .info-container {
4 | background-color: #ffffff;
5 | }
6 |
7 | .info-container .username {
8 | height: 90rpx;
9 | font-size: 36rpx;
10 | line-height: 90rpx;
11 | font-family: SourceHanSansCN-Medium;
12 | font-weight: 500;
13 | color: rgba(53, 53, 53, 1);
14 | text-align: center;
15 | }
16 |
17 | .info-container .avatar-container {
18 | text-align: center;
19 | }
20 |
21 | .info-container .avatar {
22 | width: 169rpx;
23 | height: 169rpx;
24 | margin: 0 auto;
25 | border-radius: 169rpx;
26 | }
27 |
28 | .info-container .card-container {
29 | width: 715rpx;
30 | height: 280rpx;
31 | margin: 8rpx auto;
32 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/mine/bg_mine_hot_2x.png);
33 | background-repeat: no-repeat;
34 | background-size: 715rpx 280rpx;
35 | /* 使用 flex 布局 */
36 | display: flex;
37 | /* 方向为纵向 */
38 | flex-direction: row;
39 | /* 设置为可换行 */
40 | flex-wrap: wrap;
41 | /* 水平居中 */
42 | justify-content: center;
43 | /* 垂直居中 */
44 | align-content: center;
45 | align-items: center;
46 | }
47 |
48 | .info-container .card-container .title {
49 | font-size: 33rpx;
50 | font-family: SourceHanSansCN-Medium;
51 | font-weight: bold;
52 | color: rgba(255, 255, 255, 1);
53 | line-height: 64rpx;
54 | }
55 |
56 | .info-container .card-container .tips {
57 | font-size: 28rpx;
58 | font-family: SourceHanSansCN-Medium;
59 | font-weight: 500;
60 | color: rgba(255, 255, 255, 1);
61 | line-height: 64rpx;
62 | }
63 |
64 | .info-container .card-container .button {
65 | margin-left: 120rpx;
66 | width: 203rpx;
67 | height: 63rpx;
68 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/mine/btn_get_2x.png);
69 | background-repeat: no-repeat;
70 | background-size: 203rpx 63rpx;
71 | }
72 |
73 | .list-container {
74 | width: 100%;
75 | }
76 |
77 | .list-container .item {
78 | width: 100%;
79 | height: 160rpx;
80 | padding: 0 91rpx;
81 | line-height: 160rpx;
82 | margin-top: 16rpx;
83 | background-color: rgba(255, 255, 255, 1);
84 | font-size: 28rpx;
85 | font-family: SourceHanSansCN-Medium;
86 | font-weight: 500;
87 | color: rgba(99, 99, 98, 1);
88 | }
89 |
90 | .list-container .favorite {
91 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/mine/ic_favorite_2x.png);
92 | background-repeat: no-repeat;
93 | background-size: 44rpx 38rpx;
94 | background-position: 31rpx center;
95 | }
96 |
97 | .list-container .collection {
98 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/mine/ic_collect_2x.png);
99 | background-repeat: no-repeat;
100 | background-size: 30rpx 41rpx;
101 | background-position: 31rpx center;
102 | }
103 |
104 | .list-container .settings {
105 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/mine/ic_agree_2x.png);
106 | background-repeat: no-repeat;
107 | background-size: 43rpx 43rpx;
108 | background-position: 31rpx center;
109 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/settings/settings.js:
--------------------------------------------------------------------------------
1 | // pages/settings/settings.js
2 | import config from '../../config/config.js';
3 | Page({
4 | data: {
5 |
6 | },
7 | onLoad: function (options) {},
8 | onReady: function () {},
9 | onShow: function () {},
10 | onHide: function () {},
11 | onUnload: function () {},
12 | toSignOut: function () {
13 | let that = this;
14 | wx.showModal({
15 | title: '提示',
16 | content: '确定要退出登录吗?',
17 | success: function (res) {
18 | if (res.confirm) {
19 | that.doSignOut();
20 | }
21 | }
22 | });
23 | },
24 | doSignOut: function () {
25 | wx.removeStorageSync(config.cacheKey.userInfo);
26 | wx.showToast({
27 | title: "退出登录成功!",
28 | icon: "success",
29 | mask: true
30 | });
31 | wx.reLaunch({
32 | url: '/pages/sign-in/sign-in'
33 | });
34 | }
35 | })
--------------------------------------------------------------------------------
/Chapter_7/pages/settings/settings.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 退出登录
5 | 关于
6 |
7 |
--------------------------------------------------------------------------------
/Chapter_7/pages/settings/settings.wxss:
--------------------------------------------------------------------------------
1 | /* pages/settings/settings.wxss */
2 |
3 | .list-container {
4 | width: 100%;
5 | margin-top: 80rpx;
6 | }
7 |
8 | .list-container .item {
9 | width: 100%;
10 | height: 120rpx;
11 | padding: 0 80rpx;
12 | margin-top: 10rpx;
13 | line-height: 120rpx;
14 | background-color: #ffffff;
15 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-in/sign-in.js:
--------------------------------------------------------------------------------
1 | // pages/sign-in/sign-in.js
2 | import config from '../../config/config.js';
3 | Page({
4 | data: {
5 | username: "",
6 | password: ""
7 | },
8 | onLoad: function (options) {}, //生命周期回调函数
9 | onReady: function () {}, //生命周期回调函数
10 | onShow: function () {}, //生命周期回调函数
11 | onHide: function () {}, //生命周期回调函数
12 | onUnload: function () {}, //生命周期回调函数
13 | onUsernameInput: function (e) { //上面为输入框绑定的键盘事件监听回调函数
14 | // e.detail.value 是取到键盘输入的值
15 | this.setData({
16 | username: e.detail.value
17 | });
18 | },
19 | onPasswordInput: function (e) {
20 | this.setData({
21 | password: e.detail.value
22 | });
23 | },
24 | toSignIn: function () { //上面为按钮绑定的点击事件回调函数
25 | if (!this.data.username) { //用户名为空
26 | wx.showToast({ //吐司以下提示用户输入用户名
27 | title: "请输入用户名!",
28 | icon: "none",
29 | mask: true
30 | });
31 | return;
32 | }
33 | if (!this.data.password) {
34 | wx.showToast({
35 | title: "请输入密码!",
36 | icon: "none",
37 | mask: true
38 | });
39 | return;
40 | }
41 | //读取本地已经存入的用户注册的信息
42 | let authUsername = wx.getStorageSync(config.cacheKey.username);
43 | let authPassword = wx.getStorageSync(config.cacheKey.password);
44 | if (this.data.username != authUsername) {
45 | wx.showToast({
46 | title: "用户名不正确!",
47 | icon: "none",
48 | mask: true
49 | });
50 | return;
51 | }
52 | if (this.data.password != authPassword) {
53 | wx.showToast({
54 | title: "密码不正确!",
55 | icon: "none",
56 | mask: true
57 | });
58 | return;
59 | }
60 | //将用户登录的信息记录下
61 | wx.setStorageSync(config.cacheKey.userInfo, {
62 | username: this.data.username
63 | });
64 | //跳转到首页,并关闭当前以及其他页面
65 | wx.reLaunch({
66 | url: '/pages/home/home'
67 | });
68 | },
69 | toSignUp: function () {
70 | //跳转到注册页面,不关闭当前页面
71 | wx.navigateTo({
72 | url: '/pages/sign-up/sign-up'
73 | });
74 | }
75 | })
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-in/sign-in.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "登录"
3 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-in/sign-in.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 您好!
6 | 欢迎来到登录页面
7 |
8 |
9 |
10 |
11 |
12 | 没有账号?注册一个吧
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-in/sign-in.wxss:
--------------------------------------------------------------------------------
1 | /* pages/sign-in/sign-in.wxss */
2 |
3 | page {
4 | background-color: #ffffff;
5 | }
6 |
7 | .container {
8 | /* 组合使用开始,使用绝对定位 */
9 | position: absolute;
10 | top: 50%;
11 | left: 50%;
12 | /* 使用 transform 将 view 在屏幕上垂直水平居中*/
13 | transform: translate(-50%, -50%);
14 | /* 组合使用结束 */
15 | width: 100%;
16 | padding: 0 80rpx;
17 | }
18 |
19 | .tips-container {
20 | text-align: center;
21 | font-family: SourceHanSansCN-Medium;
22 | font-weight: 500;
23 | color: rgba(99, 99, 98, 1);
24 | line-height: 64rpx;
25 | }
26 |
27 | .tips-container .title {
28 | font-size: 36rpx;
29 | }
30 |
31 | .tips-container .tips {
32 | font-size: 44rpx;
33 | }
34 |
35 | .input-username, .input-password {
36 | width: 100%;
37 | height: 80rpx;
38 | background: rgba(229, 229, 229, 1);
39 | border-radius: 15rpx;
40 | font-size: 28rpx;
41 | font-family: SourceHanSansCN-Medium;
42 | font-weight: 500;
43 | color: rgba(130, 129, 129, 1);
44 | line-height: 80rpx;
45 | padding: 0 15rpx;
46 | }
47 |
48 | .input-username {
49 | margin-top: 84rpx;
50 | }
51 |
52 | .input-password {
53 | margin-top: 20rpx;
54 | }
55 |
56 | .sign-up-container {
57 | width: 100%;
58 | height: 80rpx;
59 | margin-top: 20rpx;
60 | position: relative;
61 | }
62 |
63 | .sign-up-container .btn-sign-up {
64 | height: 70rpx;
65 | position: absolute;
66 | left: 0;
67 | line-height: 70rpx;
68 | font-size: 28rpx;
69 | font-family: SourceHanSansCN-Medium;
70 | font-weight: 500;
71 | color: rgba(89, 193, 227, 1);
72 | }
73 |
74 | .btn-sign-in {
75 | margin: 52rpx auto 111rpx;
76 | width: 303rpx;
77 | height: 81rpx;
78 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/sign_in/btn_sign_in_2x.png);
79 | background-repeat: no-repeat;
80 | background-size: 303rpx 81rpx;
81 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-up/sign-up.js:
--------------------------------------------------------------------------------
1 | // pages/sign-up/sign-up.js
2 | import config from '../../config/config.js';
3 | Page({
4 | data: {
5 | username: "",
6 | password: ""
7 | },
8 | onUsernameInput: function (e) {//当用户名输入框有内容输入时被回调
9 | this.setData({//将输入内容保存到 username 中
10 | username: e.detail.value
11 | });
12 | },
13 | onPasswordInput: function (e) {//当密码输入框有内容输入时被回调
14 | this.setData({//将输入内容保存到 password 中
15 | password: e.detail.value
16 | });
17 | },
18 | toSignUp: function () {//当注册按钮点击时被调用
19 | if (!this.data.username) {//用户名为空,提示用户输入用户名
20 | wx.showToast({
21 | title: "请输入用户名!",
22 | icon: "none",
23 | mask: true
24 | });
25 | return;
26 | }
27 | if (!this.data.password) {//密码为空,提示用户输入密码
28 | wx.showToast({
29 | title: "请输入密码!",
30 | icon: "none",
31 | mask: true
32 | });
33 | return;
34 | }
35 | //分别将用户名,密码保存到 local storage 中
36 | wx.setStorageSync(config.cacheKey.username, this.data.username);
37 | wx.setStorageSync(config.cacheKey.password, this.data.password);
38 | wx.showToast({
39 | title: "注册成功请登录",
40 | icon: "success",
41 | mask: true
42 | });
43 | wx.reLaunch({//关闭所有页面,并打开登录页面
44 | url: '/pages/sign-in/sign-in'
45 | });
46 | }
47 | })
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-up/sign-up.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "注册"
3 | }
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-up/sign-up.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 您好!
9 | 欢迎来到注册页面
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Chapter_7/pages/sign-up/sign-up.wxss:
--------------------------------------------------------------------------------
1 | /* pages/sign-up/sign-up.wxss */
2 |
3 | page {
4 | background-color: #ffffff;
5 | }
6 |
7 | .container {
8 | /* 设置为绝对定位 */
9 | position: absolute;
10 | top: 50%;
11 | left: 50%;
12 | /* 使用 transform 将 image 向上和向左偏移 50% */
13 | transform: translate(-50%, -50%);
14 | width: 100%;
15 | padding: 0 80rpx;
16 | }
17 |
18 | .logo-container {
19 | text-align: center;
20 | }
21 |
22 | .logo {
23 | width: 200rpx;
24 | height: 200rpx;
25 | }
26 |
27 | .tips-container {
28 | text-align: center;
29 | font-family: SourceHanSansCN-Medium;
30 | font-weight: 500;
31 | color: rgba(99, 99, 98, 1);
32 | line-height: 64rpx;
33 | }
34 |
35 | .tips-container .title {
36 | font-size: 36rpx;
37 | }
38 |
39 | .tips-container .tips {
40 | font-size: 28rpx;
41 | }
42 |
43 | .input-username, .input-password {
44 | width: 100%;
45 | height: 80rpx;
46 | border-bottom: 4rpx dashed rgba(130, 129, 129, 1);
47 | font-size: 28rpx;
48 | font-family: SourceHanSansCN-Medium;
49 | font-weight: 500;
50 | color: rgba(130, 129, 129, 1);
51 | line-height: 80rpx;
52 | }
53 |
54 | .input-password {
55 | margin-top: 40rpx;
56 | }
57 |
58 | .btn-sign-up {
59 | margin: 117rpx auto 111rpx;
60 | width: 303rpx;
61 | height: 81rpx;
62 | background-image: url(https://raw.githubusercontent.com/jeanboydev/GBook/master/images/sign_up/btn_sign_up_2x.png);
63 | background-repeat: no-repeat;
64 | background-size: 303rpx 81rpx;
65 | }
--------------------------------------------------------------------------------
/Chapter_7/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件。",
3 | "packOptions": {
4 | "ignore": []
5 | },
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": true,
9 | "postcss": true,
10 | "minified": true,
11 | "newFeature": true
12 | },
13 | "compileType": "miniprogram",
14 | "libVersion": "2.0.4",
15 | "appid": "wx6f4dd17ad695f91f",
16 | "projectname": "GBook",
17 | "isGameTourist": false,
18 | "simulatorType": "wechat",
19 | "simulatorPluginLibVersion": {},
20 | "condition": {
21 | "search": {
22 | "current": -1,
23 | "list": []
24 | },
25 | "conversation": {
26 | "current": -1,
27 | "list": []
28 | },
29 | "game": {
30 | "currentL": -1,
31 | "list": []
32 | },
33 | "miniprogram": {
34 | "current": -1,
35 | "list": []
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Chapter_7/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/Chapter_7/utils/money.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 格式化余额保留两位小数
3 | *
4 | * @param {*} money 分
5 | */
6 | function formatMoney(money) {
7 | let last = money % 100;
8 | let index = 2;
9 | if (last == 0) {
10 | index = 0;
11 | } else if (last % 10 == 0) {
12 | index = 1;
13 | }
14 | return (money / 100).toFixed(index);
15 | }
16 |
17 | module.exports = {
18 | formatMoney: formatMoney
19 | };
--------------------------------------------------------------------------------
/Chapter_9/README.md:
--------------------------------------------------------------------------------
1 | # read
2 |
3 | A new Flutter application.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.io/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/Chapter_9/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26 |
27 | android {
28 | compileSdkVersion 27
29 |
30 | lintOptions {
31 | disable 'InvalidPackage'
32 | }
33 |
34 | defaultConfig {
35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36 | applicationId "com.yugangtalk.read"
37 | minSdkVersion 16
38 | targetSdkVersion 27
39 | versionCode flutterVersionCode.toInteger()
40 | versionName flutterVersionName
41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
42 | }
43 |
44 | buildTypes {
45 | release {
46 | // TODO: Add your own signing config for the release build.
47 | // Signing with the debug keys for now, so `flutter run --release` works.
48 | signingConfig signingConfigs.debug
49 | }
50 | }
51 | }
52 |
53 | flutter {
54 | source '../..'
55 | }
56 |
57 | dependencies {
58 | testImplementation 'junit:junit:4.12'
59 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
61 | }
62 |
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
15 |
19 |
26 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/java/com/yugangtalk/read/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.yugangtalk.read;
2 |
3 | import android.os.Bundle;
4 | import io.flutter.app.FlutterActivity;
5 | import io.flutter.plugins.GeneratedPluginRegistrant;
6 |
7 | public class MainActivity extends FlutterActivity {
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | GeneratedPluginRegistrant.registerWith(this);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/mipmap-xxhdpi/icon_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/android/app/src/main/res/mipmap-xxhdpi/icon_logo.png
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Chapter_9/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/Chapter_9/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.2.1'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | google()
15 | jcenter()
16 | }
17 | }
18 |
19 | rootProject.buildDir = '../build'
20 | subprojects {
21 | project.buildDir = "${rootProject.buildDir}/${project.name}"
22 | }
23 | subprojects {
24 | project.evaluationDependsOn(':app')
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/Chapter_9/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 |
--------------------------------------------------------------------------------
/Chapter_9/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
7 |
--------------------------------------------------------------------------------
/Chapter_9/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/Chapter_9/images/icon_arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_arrow_right.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_collection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_collection.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_home.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_home_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_home_default.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_love.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_love.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_love_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_love_card.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_my.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_my_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_my_default.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_praise.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_praise.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_setting.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_star.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_star_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_star_checked.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_star_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_star_default.png
--------------------------------------------------------------------------------
/Chapter_9/images/icon_user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/icon_user.png
--------------------------------------------------------------------------------
/Chapter_9/images/img_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_bg.png
--------------------------------------------------------------------------------
/Chapter_9/images/img_book_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_book_card.png
--------------------------------------------------------------------------------
/Chapter_9/images/img_book_yskf.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_book_yskf.jpg
--------------------------------------------------------------------------------
/Chapter_9/images/img_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_card.png
--------------------------------------------------------------------------------
/Chapter_9/images/img_header.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_header.jpeg
--------------------------------------------------------------------------------
/Chapter_9/images/img_login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_login.png
--------------------------------------------------------------------------------
/Chapter_9/images/img_register.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/images/img_register.png
--------------------------------------------------------------------------------
/Chapter_9/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Podfile:
--------------------------------------------------------------------------------
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
70 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildSystemType
6 | Original
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "size" : "29x29",
15 | "idiom" : "iphone",
16 | "filename" : "icon_logo58.png",
17 | "scale" : "2x"
18 | },
19 | {
20 | "size" : "29x29",
21 | "idiom" : "iphone",
22 | "filename" : "icon_logo87.png",
23 | "scale" : "3x"
24 | },
25 | {
26 | "idiom" : "iphone",
27 | "size" : "40x40",
28 | "scale" : "2x"
29 | },
30 | {
31 | "idiom" : "iphone",
32 | "size" : "40x40",
33 | "scale" : "3x"
34 | },
35 | {
36 | "idiom" : "iphone",
37 | "size" : "60x60",
38 | "scale" : "2x"
39 | },
40 | {
41 | "idiom" : "iphone",
42 | "size" : "60x60",
43 | "scale" : "3x"
44 | },
45 | {
46 | "idiom" : "ipad",
47 | "size" : "20x20",
48 | "scale" : "1x"
49 | },
50 | {
51 | "idiom" : "ipad",
52 | "size" : "20x20",
53 | "scale" : "2x"
54 | },
55 | {
56 | "idiom" : "ipad",
57 | "size" : "29x29",
58 | "scale" : "1x"
59 | },
60 | {
61 | "idiom" : "ipad",
62 | "size" : "29x29",
63 | "scale" : "2x"
64 | },
65 | {
66 | "idiom" : "ipad",
67 | "size" : "40x40",
68 | "scale" : "1x"
69 | },
70 | {
71 | "idiom" : "ipad",
72 | "size" : "40x40",
73 | "scale" : "2x"
74 | },
75 | {
76 | "idiom" : "ipad",
77 | "size" : "76x76",
78 | "scale" : "1x"
79 | },
80 | {
81 | "idiom" : "ipad",
82 | "size" : "76x76",
83 | "scale" : "2x"
84 | },
85 | {
86 | "idiom" : "ipad",
87 | "size" : "83.5x83.5",
88 | "scale" : "2x"
89 | },
90 | {
91 | "idiom" : "ios-marketing",
92 | "size" : "1024x1024",
93 | "scale" : "1x"
94 | }
95 | ],
96 | "info" : {
97 | "version" : 1,
98 | "author" : "xcode"
99 | }
100 | }
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon_logo58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon_logo58.png
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon_logo87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon_logo87.png
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-exchange/cross-platform-guide/e52f6fcc90f3a63e0e8fac01d2b57f81d48689d2/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "ipad",
6 | "minimum-system-version" : "7.0",
7 | "extent" : "full-screen",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "landscape",
12 | "idiom" : "ipad",
13 | "minimum-system-version" : "7.0",
14 | "extent" : "full-screen",
15 | "scale" : "1x"
16 | },
17 | {
18 | "orientation" : "landscape",
19 | "idiom" : "ipad",
20 | "minimum-system-version" : "7.0",
21 | "extent" : "full-screen",
22 | "scale" : "2x"
23 | },
24 | {
25 | "orientation" : "portrait",
26 | "idiom" : "iphone",
27 | "minimum-system-version" : "7.0",
28 | "scale" : "2x"
29 | },
30 | {
31 | "orientation" : "portrait",
32 | "idiom" : "iphone",
33 | "minimum-system-version" : "7.0",
34 | "subtype" : "retina4",
35 | "scale" : "2x"
36 | },
37 | {
38 | "orientation" : "portrait",
39 | "idiom" : "ipad",
40 | "minimum-system-version" : "7.0",
41 | "extent" : "full-screen",
42 | "scale" : "1x"
43 | }
44 | ],
45 | "info" : {
46 | "version" : 1,
47 | "author" : "xcode"
48 | }
49 | }
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | read
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Chapter_9/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Chapter_9/lib/api/Api.dart:
--------------------------------------------------------------------------------
1 | class Api {
2 |
3 |
4 | static final String HOST = "http://renyugang.io/api/read.php";
5 | // 资讯列表
6 | static final String BOOK_LIST = HOST+"?action=list";
7 |
8 | static final String BOOK_TAB = HOST;
9 | static final String BOOK_DETAIL = HOST+"?action=detail&q=";
10 |
11 |
12 | }
--------------------------------------------------------------------------------
/Chapter_9/lib/api/NetUtils.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'package:http/http.dart' as http;
3 |
4 | class NetUtils {
5 | static Future get(String url, {Map params}) async {
6 | if (params != null && params.isNotEmpty) {
7 | StringBuffer sb = new StringBuffer('?');
8 | params.forEach((key, value) {
9 | sb.write('$key' + '=' + '$value' + '&');
10 | });
11 | String paramStr = sb.toString();
12 | paramStr = paramStr.substring(0, paramStr.length - 1);
13 | url += paramStr;
14 | }
15 | http.Response res = await http.get(url);
16 | return res.body;
17 | }
18 |
19 | static Future post(String url, {Map params}) async {
20 | http.Response res = await http.post(url, body: params);
21 | return res.body;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Chapter_9/lib/common/ColorsUtil.dart:
--------------------------------------------------------------------------------
1 | class ColorsUtil{
2 | static int THEME_BLACK = 0XFF353535;
3 | static int TYPEFACE_BLACK = 0XFF636362;
4 | static int TYPEFACE_BLUE = 0XFF36BAE0;
5 | }
--------------------------------------------------------------------------------
/Chapter_9/lib/common/DbProvider.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:path/path.dart';
5 | import 'package:read/models/Book.dart';
6 | import 'package:read/models/Comment.dart';
7 | import 'package:sqflite/sqflite.dart';
8 |
9 | class DbProvider {
10 | String tableComment = "tableComment";
11 | String tableCollectBook = "tableCollectBook1";
12 |
13 | static const columnImg = "img";
14 | static const columnId = "_id";
15 | static const columnName = "name";
16 | static const columnContent = "content";
17 | static const columnBookId = "book_id";
18 | static const columnBook = "book";
19 | String dbName = 'read.db';
20 |
21 | Future getPath() async {
22 | var databasesPath = await getDatabasesPath();
23 | String path = join(databasesPath, dbName);
24 | return path;
25 | }
26 |
27 | Future createDb(String dbName) async {
28 | String path = await getPath();
29 | if (await new Directory(path).exists()) {
30 | await deleteDatabase(path);
31 | } else {
32 | try {
33 | await new Directory(dirname(path)).create(recursive: true);
34 | } catch (e) {
35 | print(e);
36 | }
37 | }
38 | return path;
39 | }
40 |
41 | create() async {
42 | var dbPath = await createDb(dbName);
43 | Database db = await openDatabase(dbPath);
44 | String sqlCreateTable =
45 | "create table if not exists $tableComment($columnId integer primary key autoincrement,$columnName text,$columnContent text ,$columnBook text)";
46 | String sqlCreateTableCollect =
47 | "create table if not exists $tableCollectBook($columnId integer primary key autoincrement,$columnName text,$columnBookId text,$columnImg text )";
48 | await db.execute(sqlCreateTable);
49 | await db.execute(sqlCreateTableCollect);
50 | await db.close();
51 | }
52 |
53 | //插入
54 | insert(Comment comment) async {
55 | String path = await getPath();
56 | Database db = await openDatabase(path);
57 | comment.id = await db.insert(tableComment, comment.toMap());
58 | // await db.close();
59 | }
60 |
61 | //插入
62 | insertBook(Book book) async {
63 | if(await isCollcetBook(book.name)){
64 |
65 | }else{
66 | String path = await getPath();
67 | Database db = await openDatabase(path);
68 | await db.insert(tableCollectBook, book.toMap());
69 | }
70 |
71 | // await db.close();
72 | }
73 |
74 | Future isCollcetBook(String bookName) async {
75 | String path = await getPath();
76 | Database db = await openDatabase(path);
77 |
78 | List