├── .gitignore
├── .metadata
├── LICENSE.txt
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── android-user.jks
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── cn
│ │ │ │ └── aries
│ │ │ │ └── freadhub
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MyApplication.java
│ │ └── res
│ │ │ ├── drawable
│ │ │ ├── launch_background.xml
│ │ │ └── launch_background_night.xml
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_logo_big.png
│ │ │ ├── ic_logo_round.webp
│ │ │ ├── ic_powered.webp
│ │ │ └── ic_slogan.webp
│ │ │ ├── values
│ │ │ └── styles.xml
│ │ │ └── xml
│ │ │ └── network_security_config.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── assets
├── fonts
│ └── iconfont.ttf
└── images
│ ├── ic_logo_round.webp
│ ├── ic_powered.webp
│ ├── ic_slogan.webp
│ ├── pay.png
│ ├── share
│ ├── ic_browser.png
│ ├── ic_card.png
│ ├── ic_copy_link.png
│ ├── ic_ding_talk.png
│ ├── ic_more.png
│ ├── ic_qq.png
│ ├── ic_we_chat.png
│ ├── ic_we_chat_timeline.png
│ ├── ic_we_work.png
│ └── ic_wei_bo.png
│ ├── title.png
│ └── user.jpg
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ ├── Flutter.podspec
│ └── Release.xcconfig
├── Podfile
├── Podfile.lock
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── WorkspaceSettings.xcsettings
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-1024.png
│ │ ├── Icon-40.png
│ │ ├── Icon-40@2x.png
│ │ ├── Icon-40@3x.png
│ │ ├── Icon-60@2x.png
│ │ ├── Icon-60@3x.png
│ │ ├── Icon-72.png
│ │ ├── Icon-72@2x.png
│ │ ├── Icon-76.png
│ │ ├── Icon-76@2x.png
│ │ ├── Icon-83.5@2x.png
│ │ ├── Icon-Small-50.png
│ │ ├── Icon-Small-50@2x.png
│ │ ├── Icon-Small.png
│ │ ├── Icon-Small@2x.png
│ │ ├── Icon-Small@3x.png
│ │ ├── Icon.png
│ │ └── Icon@2x.png
│ ├── Contents.json
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage-dark-ipad@3x.png.png
│ │ ├── LaunchImage-dark-iphone.png
│ │ ├── LaunchImage-dark-iphone@2x.png
│ │ ├── LaunchImage-dark-iphone@3x.png
│ │ ├── LaunchImage-ipad@3x.png
│ │ ├── LaunchImage-iphone.png
│ │ ├── LaunchImage-iphone@2x.png
│ │ └── LaunchImage-iphone@3x.png
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── Runner-Bridging-Header.h
├── lib
├── basis
│ ├── basis_highlight_view_model.dart
│ ├── basis_list_view_model.dart
│ ├── basis_provider_widget.dart
│ ├── basis_refresh_list_view_model.dart
│ ├── basis_scroll_top_controller.dart
│ ├── basis_view_model.dart
│ ├── view_state.dart
│ └── view_state_widget.dart
├── data
│ ├── article_http.dart
│ ├── article_repository.dart
│ ├── basis_http.dart
│ ├── poem_http.dart
│ ├── poem_repository.dart
│ ├── update_http.dart
│ └── update_repository.dart
├── dialog
│ ├── author_dialog.dart
│ ├── basis_dialog.dart
│ ├── card_share_dialog.dart
│ ├── text_share_dialog.dart
│ ├── theme_dialog.dart
│ └── url_share_dialog.dart
├── enum
│ ├── share_card_style.dart
│ └── share_type.dart
├── generated
│ ├── intl
│ │ ├── messages_all.dart
│ │ ├── messages_en.dart
│ │ └── messages_zh.dart
│ └── l10n.dart
├── helper
│ ├── path_helper.dart
│ ├── permission_helper.dart
│ ├── provider_helper.dart
│ ├── save_image_helper.dart
│ ├── share_helper.dart
│ └── sp_helper.dart
├── l10n
│ ├── intl_en.arb
│ └── intl_zh.arb
├── main.dart
├── manager
│ └── router_manger.dart
├── model
│ ├── app_update_model.dart
│ ├── article_model.dart
│ ├── poem_sentence_model.dart
│ ├── share_model.dart
│ └── tab_model.dart
├── observer
│ └── app_router_observer.dart
├── page
│ ├── home_page.dart
│ ├── web_view_page.dart
│ └── widget
│ │ ├── article_item_widget.dart
│ │ └── poem_sentence.dart
├── res
│ ├── assets_res.dart
│ └── i_font_res.dart
├── util
│ ├── adaptive.dart
│ ├── dialog_util.dart
│ ├── platform_util.dart
│ ├── resource_util.dart
│ ├── share_util.dart
│ └── toast_util.dart
├── view_model
│ ├── article_view_model.dart
│ ├── locale_view_model.dart
│ ├── poem_sentence_view_model.dart
│ ├── share_view_model.dart
│ ├── theme_view_model.dart
│ └── update_view_model.dart
└── widget
│ ├── animated_switcher_icon_widget.dart
│ ├── capture_image_widget.dart
│ ├── highlight_card_widget.dart
│ ├── keep_alive_widget.dart
│ ├── lifecycle_widget.dart
│ ├── qr_code.dart
│ ├── share_widget.dart
│ ├── skeleton.dart
│ ├── tab_bar_widget.dart
│ └── tooltip_plus.dart
├── macos
├── .gitignore
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── app_icon_1024.png
│ │ ├── app_icon_128.png
│ │ ├── app_icon_16.png
│ │ ├── app_icon_256.png
│ │ ├── app_icon_32.png
│ │ ├── app_icon_512.png
│ │ └── app_icon_64.png
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Configs
│ ├── AppInfo.xcconfig
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── Warnings.xcconfig
│ ├── DebugProfile.entitlements
│ ├── Info.plist
│ ├── MainFlutterWindow.swift
│ └── Release.entitlements
├── plugins
└── flutter_macos_webview
│ ├── README.md
│ ├── lib
│ └── flutter_macos_webview.dart
│ ├── macos
│ ├── Classes
│ │ ├── FlutterMacOSWebViewPlugin.swift
│ │ └── WebViewController.swift
│ └── flutter_macos_webview.podspec
│ ├── pubspec.lock
│ └── pubspec.yaml
├── pubspec.lock
├── pubspec.yaml
├── sample
├── Freadhub-聚合资讯.zip
├── sample.apk
└── sample.ipa
├── test
└── widget_test.dart
├── update
└── macos
├── web
├── favicon.ico
├── favicon.png
├── icons
│ ├── Icon-192.png
│ └── Icon-512.png
├── index.html
└── manifest.json
└── windows
├── .gitignore
├── CMakeLists.txt
├── flutter
├── CMakeLists.txt
├── generated_plugin_registrant.cc
├── generated_plugin_registrant.h
└── generated_plugins.cmake
└── runner
├── CMakeLists.txt
├── Runner.rc
├── flutter_window.cpp
├── flutter_window.h
├── main.cpp
├── resource.h
├── run_loop.cpp
├── run_loop.h
├── runner.exe.manifest
├── utils.cpp
├── utils.h
├── win32_window.cpp
└── win32_window.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | .firebase/
12 | .flutter-plugins-dependencies
13 |
14 | # IntelliJ related
15 | *.iml
16 | *.ipr
17 | *.iws
18 | .idea/
19 |
20 | # The .vscode folder contains launch configuration and tasks you configure in
21 | # VS Code which you may wish to be included in version control, so this line
22 | # is commented out by default.
23 | #.vscode/
24 |
25 | # Flutter/Dart/Pub related
26 | **/doc/api/
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .packages
31 | .pub-cache/
32 | .pub/
33 | /build/
34 | test_goldens/failures/
35 |
36 | # Android related
37 | **/android/**/gradle-wrapper.jar
38 | **/android/.gradle
39 | **/android/captures/
40 | **/android/gradlew
41 | **/android/gradlew.bat
42 | **/android/local.properties
43 | **/android/**/GeneratedPluginRegistrant.java
44 |
45 | # iOS/XCode related
46 | **/ios/**/*.mode1v3
47 | **/ios/**/*.mode2v3
48 | **/ios/**/*.moved-aside
49 | **/ios/**/*.pbxuser
50 | **/ios/**/*.perspectivev3
51 | **/ios/**/*sync/
52 | **/ios/**/.sconsign.dblite
53 | **/ios/**/.tags*
54 | **/ios/**/.vagrant/
55 | **/ios/**/DerivedData/
56 | **/ios/**/Icon?
57 | **/ios/**/Pods/
58 | **/ios/**/.symlinks/
59 | **/ios/**/profile
60 | **/ios/**/xcuserdata
61 | **/ios/.generated/
62 | **/ios/Flutter/.last_build_id
63 | **/ios/Flutter/App.framework
64 | **/ios/Flutter/Flutter.framework
65 | **/ios/Flutter/Generated.xcconfig
66 | **/ios/Flutter/app.flx
67 | **/ios/Flutter/app.zip
68 | **/ios/Flutter/flutter_assets/
69 | **/ios/Flutter/flutter_export_environment.sh
70 | **/ios/ServiceDefinitions.json
71 | **/ios/Runner/GeneratedPluginRegistrant.*
72 |
73 | # Web related
74 | lib/generated_plugin_registrant.dart
75 |
76 | # Exceptions to above rules.
77 | !**/ios/**/default.mode1v3
78 | !**/ios/**/default.mode2v3
79 | !**/ios/**/default.pbxuser
80 | !**/ios/**/default.perspectivev3
81 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
82 |
83 | /macos/Podfile
84 | /macos/Podfile.lock
85 | /macos/Runner.xcworkspace/
86 | /macos/Flutter/
87 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 1946fc4da0f80c522d7e3ae7d4f7309908ed86f2
8 | channel: dev
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | #include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/android/android-user.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/android/android-user.jks
--------------------------------------------------------------------------------
/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 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
14 | if (flutterVersionCode == null) {
15 | flutterVersionCode = '1'
16 | }
17 |
18 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
19 | if (flutterVersionName == null) {
20 | flutterVersionName = '1.0'
21 | }
22 | apply plugin: 'com.android.application'
23 | apply plugin: 'kotlin-android'
24 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
25 |
26 | android {
27 | compileSdkVersion flutter.compileSdkVersion
28 |
29 | sourceSets {
30 | main.java.srcDirs += 'src/main/kotlin'
31 | }
32 |
33 | lintOptions {
34 | disable 'InvalidPackage'
35 | }
36 |
37 | defaultConfig {
38 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
39 | applicationId "cn.aries.freadhub"
40 | minSdkVersion 19
41 | targetSdkVersion 28
42 | versionCode flutterVersionCode.toInteger()
43 | versionName flutterVersionName
44 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
45 | }
46 |
47 | //配置签名
48 | signingConfigs {
49 | release {
50 | storeFile file('../android-user.jks')
51 | storePassword 'android-user123#@!'
52 | keyAlias 'android-user'
53 | keyPassword 'android-user123#@!'
54 | }
55 | }
56 | buildTypes {
57 | debug {
58 | signingConfig signingConfigs.release
59 | }
60 | release {
61 | signingConfig signingConfigs.release
62 | ndk {
63 | // 设置支持的SO库架构
64 | //abiFilters 'arm64-v8a'//,'x86' ,'armeabi', 'x86_64', 'arm64-v8a'
65 | }
66 | }
67 | }
68 | //打包重命名
69 | applicationVariants.all { variant ->
70 | variant.outputs.all {
71 | if (variant.name != "release") {
72 | return
73 | }
74 | outputFileName = "FreadhubV${defaultConfig.versionName}.apk"
75 | }
76 | }
77 | }
78 |
79 | flutter {
80 | source '../..'
81 | }
82 |
83 | dependencies {
84 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
85 | testImplementation 'junit:junit:4.12'
86 | androidTestImplementation 'androidx.test:runner:1.1.1'
87 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
88 | }
89 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
9 |
16 |
23 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
36 |
39 |
40 |
43 |
47 |
48 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/cn/aries/freadhub/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package cn.aries.freadhub
2 |
3 | import android.graphics.Color
4 | import android.graphics.drawable.ColorDrawable
5 | import android.os.Bundle
6 | import io.flutter.embedding.android.FlutterActivity
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | window.setBackgroundDrawable(ColorDrawable(Color.WHITE))
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/cn/aries/freadhub/MyApplication.java:
--------------------------------------------------------------------------------
1 | package cn.aries.freadhub;
2 |
3 | import android.app.Application;
4 |
5 | public class MyApplication extends Application{
6 | @Override
7 | public void onCreate() {
8 | super.onCreate();
9 | }
10 | }
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | -
7 |
10 |
11 | -
12 |
15 |
16 | -
17 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background_night.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | -
7 |
10 |
11 | -
12 |
15 |
16 | -
17 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_logo_big.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/android/app/src/main/res/mipmap-xxxhdpi/ic_logo_big.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_logo_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/android/app/src/main/res/mipmap-xxxhdpi/ic_logo_round.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_powered.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/android/app/src/main/res/mipmap-xxxhdpi/ic_powered.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_slogan.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/android/app/src/main/res/mipmap-xxxhdpi/ic_slogan.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/android/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | jcenter()
7 | // maven { url 'https://maven.aliyun.com/repository/google' }
8 | // maven { url 'https://maven.aliyun.com/repository/jcenter' }
9 | // maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
10 | }
11 |
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:7.1.2'
14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | mavenCentral()
22 | jcenter()
23 | // maven { url 'https://maven.aliyun.com/repository/google' }
24 | // maven { url 'https://maven.aliyun.com/repository/jcenter' }
25 | // maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
26 | }
27 | }
28 |
29 | rootProject.buildDir = '../build'
30 | subprojects {
31 | project.buildDir = "${rootProject.buildDir}/${project.name}"
32 | }
33 | subprojects {
34 | project.evaluationDependsOn(':app')
35 | }
36 |
37 | task clean(type: Delete) {
38 | delete rootProject.buildDir
39 | }
40 | tasks.withType(JavaCompile) {
41 | options.encoding = "UTF-8"
42 | }
43 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/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-7.2-bin.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/assets/fonts/iconfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/fonts/iconfont.ttf
--------------------------------------------------------------------------------
/assets/images/ic_logo_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/ic_logo_round.webp
--------------------------------------------------------------------------------
/assets/images/ic_powered.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/ic_powered.webp
--------------------------------------------------------------------------------
/assets/images/ic_slogan.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/ic_slogan.webp
--------------------------------------------------------------------------------
/assets/images/pay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/pay.png
--------------------------------------------------------------------------------
/assets/images/share/ic_browser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_browser.png
--------------------------------------------------------------------------------
/assets/images/share/ic_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_card.png
--------------------------------------------------------------------------------
/assets/images/share/ic_copy_link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_copy_link.png
--------------------------------------------------------------------------------
/assets/images/share/ic_ding_talk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_ding_talk.png
--------------------------------------------------------------------------------
/assets/images/share/ic_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_more.png
--------------------------------------------------------------------------------
/assets/images/share/ic_qq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_qq.png
--------------------------------------------------------------------------------
/assets/images/share/ic_we_chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_we_chat.png
--------------------------------------------------------------------------------
/assets/images/share/ic_we_chat_timeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_we_chat_timeline.png
--------------------------------------------------------------------------------
/assets/images/share/ic_we_work.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_we_work.png
--------------------------------------------------------------------------------
/assets/images/share/ic_wei_bo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/share/ic_wei_bo.png
--------------------------------------------------------------------------------
/assets/images/title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/title.png
--------------------------------------------------------------------------------
/assets/images/user.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/assets/images/user.jpg
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Generated.xcconfig
20 | Flutter/app.flx
21 | Flutter/app.zip
22 | Flutter/flutter_assets/
23 | Flutter/flutter_export_environment.sh
24 | ServiceDefinitions.json
25 | Runner/GeneratedPluginRegistrant.*
26 |
27 | # Exceptions to above rules.
28 | !default.mode1v3
29 | !default.mode2v3
30 | !default.pbxuser
31 | !default.perspectivev3
32 | /build/
33 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Flutter/Flutter.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # NOTE: This podspec is NOT to be published. It is only used as a local source!
3 | # This is a generated file; do not edit or check into version control.
4 | #
5 |
6 | Pod::Spec.new do |s|
7 | s.name = 'Flutter'
8 | s.version = '1.0.0'
9 | s.summary = 'A UI toolkit for beautiful and fast apps.'
10 | s.homepage = 'https://flutter.dev'
11 | s.license = { :type => 'BSD' }
12 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
13 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
14 | s.ios.deployment_target = '11.0'
15 | # Framework linking is handled by Flutter tooling, not CocoaPods.
16 | # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
17 | s.vendored_frameworks = 'path/to/nothing'
18 | end
19 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '11.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 flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | end
36 |
37 | post_install do |installer|
38 | installer.pods_project.targets.each do |target|
39 | flutter_additional_ios_build_settings(target)
40 | target.build_configurations.each do |config|
41 | # You can remove unused permissions here
42 | # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
43 | # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
44 | config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
45 | '$(inherited)',
46 |
47 | ## dart: PermissionGroup.calendar
48 | 'PERMISSION_EVENTS=1',
49 |
50 | ## dart: PermissionGroup.reminders
51 | 'PERMISSION_REMINDERS=1',
52 |
53 | ## dart: PermissionGroup.contacts
54 | 'PERMISSION_CONTACTS=1',
55 |
56 | ## dart: PermissionGroup.camera
57 | 'PERMISSION_CAMERA=1',
58 |
59 | ## dart: PermissionGroup.microphone
60 | 'PERMISSION_MICROPHONE=1',
61 |
62 | ## dart: PermissionGroup.speech
63 | 'PERMISSION_SPEECH_RECOGNIZER=1',
64 |
65 | ## dart: PermissionGroup.photos
66 | 'PERMISSION_PHOTOS=1',
67 |
68 | ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
69 | 'PERMISSION_LOCATION=1',
70 |
71 | ## dart: PermissionGroup.notification
72 | 'PERMISSION_NOTIFICATIONS=1',
73 |
74 | ## dart: PermissionGroup.mediaLibrary
75 | 'PERMISSION_MEDIA_LIBRARY=1',
76 |
77 | ## dart: PermissionGroup.sensors
78 | 'PERMISSION_SENSORS=1',
79 |
80 | ## dart: PermissionGroup.bluetooth
81 | 'PERMISSION_BLUETOOTH=1',
82 |
83 | ## dart: PermissionGroup.appTrackingTransparency
84 | 'PERMISSION_APP_TRACKING_TRANSPARENCY=1'
85 | ]
86 | end
87 | end
88 | end
89 |
90 |
91 |
--------------------------------------------------------------------------------
/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - device_info_plus (0.0.1):
3 | - Flutter
4 | - Flutter (1.0.0)
5 | - FMDB (2.7.5):
6 | - FMDB/standard (= 2.7.5)
7 | - FMDB/standard (2.7.5)
8 | - package_info_plus (0.4.5):
9 | - Flutter
10 | - path_provider_foundation (0.0.1):
11 | - Flutter
12 | - FlutterMacOS
13 | - permission_handler_apple (9.0.4):
14 | - Flutter
15 | - share (0.0.1):
16 | - Flutter
17 | - share_plus (0.0.1):
18 | - Flutter
19 | - shared_preferences_foundation (0.0.1):
20 | - Flutter
21 | - FlutterMacOS
22 | - sqflite (0.0.2):
23 | - Flutter
24 | - FMDB (>= 2.7.5)
25 | - url_launcher_ios (0.0.1):
26 | - Flutter
27 | - webview_flutter_wkwebview (0.0.1):
28 | - Flutter
29 |
30 | DEPENDENCIES:
31 | - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
32 | - Flutter (from `Flutter`)
33 | - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
34 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
35 | - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
36 | - share (from `.symlinks/plugins/share/ios`)
37 | - share_plus (from `.symlinks/plugins/share_plus/ios`)
38 | - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
39 | - sqflite (from `.symlinks/plugins/sqflite/ios`)
40 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
41 | - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
42 |
43 | SPEC REPOS:
44 | trunk:
45 | - FMDB
46 |
47 | EXTERNAL SOURCES:
48 | device_info_plus:
49 | :path: ".symlinks/plugins/device_info_plus/ios"
50 | Flutter:
51 | :path: Flutter
52 | package_info_plus:
53 | :path: ".symlinks/plugins/package_info_plus/ios"
54 | path_provider_foundation:
55 | :path: ".symlinks/plugins/path_provider_foundation/ios"
56 | permission_handler_apple:
57 | :path: ".symlinks/plugins/permission_handler_apple/ios"
58 | share:
59 | :path: ".symlinks/plugins/share/ios"
60 | share_plus:
61 | :path: ".symlinks/plugins/share_plus/ios"
62 | shared_preferences_foundation:
63 | :path: ".symlinks/plugins/shared_preferences_foundation/ios"
64 | sqflite:
65 | :path: ".symlinks/plugins/sqflite/ios"
66 | url_launcher_ios:
67 | :path: ".symlinks/plugins/url_launcher_ios/ios"
68 | webview_flutter_wkwebview:
69 | :path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
70 |
71 | SPEC CHECKSUMS:
72 | device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
73 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
74 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
75 | package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
76 | path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
77 | permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
78 | share: 0b2c3e82132f5888bccca3351c504d0003b3b410
79 | share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
80 | shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
81 | sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
82 | url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
83 | webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f
84 |
85 | PODFILE CHECKSUM: 80774e1e4c981ad6cfa8e6cf41319b1ac5da26c0
86 |
87 | COCOAPODS: 1.11.3
88 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "filename" : "Icon-Small.png",
15 | "idiom" : "iphone",
16 | "scale" : "1x",
17 | "size" : "29x29"
18 | },
19 | {
20 | "filename" : "Icon-Small@2x.png",
21 | "idiom" : "iphone",
22 | "scale" : "2x",
23 | "size" : "29x29"
24 | },
25 | {
26 | "filename" : "Icon-Small@3x.png",
27 | "idiom" : "iphone",
28 | "scale" : "3x",
29 | "size" : "29x29"
30 | },
31 | {
32 | "filename" : "Icon-40@2x.png",
33 | "idiom" : "iphone",
34 | "scale" : "2x",
35 | "size" : "40x40"
36 | },
37 | {
38 | "filename" : "Icon-40@3x.png",
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "40x40"
42 | },
43 | {
44 | "filename" : "Icon.png",
45 | "idiom" : "iphone",
46 | "scale" : "1x",
47 | "size" : "57x57"
48 | },
49 | {
50 | "filename" : "Icon@2x.png",
51 | "idiom" : "iphone",
52 | "scale" : "2x",
53 | "size" : "57x57"
54 | },
55 | {
56 | "filename" : "Icon-60@2x.png",
57 | "idiom" : "iphone",
58 | "scale" : "2x",
59 | "size" : "60x60"
60 | },
61 | {
62 | "filename" : "Icon-60@3x.png",
63 | "idiom" : "iphone",
64 | "scale" : "3x",
65 | "size" : "60x60"
66 | },
67 | {
68 | "idiom" : "ipad",
69 | "scale" : "1x",
70 | "size" : "20x20"
71 | },
72 | {
73 | "idiom" : "ipad",
74 | "scale" : "2x",
75 | "size" : "20x20"
76 | },
77 | {
78 | "filename" : "Icon-Small.png",
79 | "idiom" : "ipad",
80 | "scale" : "1x",
81 | "size" : "29x29"
82 | },
83 | {
84 | "filename" : "Icon-Small@2x.png",
85 | "idiom" : "ipad",
86 | "scale" : "2x",
87 | "size" : "29x29"
88 | },
89 | {
90 | "filename" : "Icon-40.png",
91 | "idiom" : "ipad",
92 | "scale" : "1x",
93 | "size" : "40x40"
94 | },
95 | {
96 | "filename" : "Icon-40@2x.png",
97 | "idiom" : "ipad",
98 | "scale" : "2x",
99 | "size" : "40x40"
100 | },
101 | {
102 | "filename" : "Icon-Small-50.png",
103 | "idiom" : "ipad",
104 | "scale" : "1x",
105 | "size" : "50x50"
106 | },
107 | {
108 | "filename" : "Icon-Small-50@2x.png",
109 | "idiom" : "ipad",
110 | "scale" : "2x",
111 | "size" : "50x50"
112 | },
113 | {
114 | "filename" : "Icon-72.png",
115 | "idiom" : "ipad",
116 | "scale" : "1x",
117 | "size" : "72x72"
118 | },
119 | {
120 | "filename" : "Icon-72@2x.png",
121 | "idiom" : "ipad",
122 | "scale" : "2x",
123 | "size" : "72x72"
124 | },
125 | {
126 | "filename" : "Icon-76.png",
127 | "idiom" : "ipad",
128 | "scale" : "1x",
129 | "size" : "76x76"
130 | },
131 | {
132 | "filename" : "Icon-76@2x.png",
133 | "idiom" : "ipad",
134 | "scale" : "2x",
135 | "size" : "76x76"
136 | },
137 | {
138 | "filename" : "Icon-83.5@2x.png",
139 | "idiom" : "ipad",
140 | "scale" : "2x",
141 | "size" : "83.5x83.5"
142 | },
143 | {
144 | "filename" : "Icon-1024.png",
145 | "idiom" : "ios-marketing",
146 | "scale" : "1x",
147 | "size" : "1024x1024"
148 | }
149 | ],
150 | "info" : {
151 | "author" : "xcode",
152 | "version" : 1
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-1024.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-72.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "filename": "LaunchImage-iphone.png",
5 | "idiom": "iphone",
6 | "scale": "1x"
7 | },
8 | {
9 | "appearances": [
10 | {
11 | "appearance": "luminosity",
12 | "value": "dark"
13 | }
14 | ],
15 | "filename": "LaunchImage-dark-iphone.png",
16 | "idiom": "iphone",
17 | "scale": "1x"
18 | },
19 | {
20 | "filename": "LaunchImage-iphone@2x.png",
21 | "idiom": "iphone",
22 | "scale": "2x"
23 | },
24 | {
25 | "appearances": [
26 | {
27 | "appearance": "luminosity",
28 | "value": "dark"
29 | }
30 | ],
31 | "filename": "LaunchImage-dark-iphone@2x.png",
32 | "idiom": "iphone",
33 | "scale": "2x"
34 | },
35 | {
36 | "filename": "LaunchImage-iphone@3x.png",
37 | "idiom": "iphone",
38 | "scale": "3x"
39 | },
40 | {
41 | "appearances": [
42 | {
43 | "appearance": "luminosity",
44 | "value": "dark"
45 | }
46 | ],
47 | "filename": "LaunchImage-dark-iphone@3x.png",
48 | "idiom": "iphone",
49 | "scale": "3x"
50 | },
51 | {
52 | "filename": "LaunchImage-ipad@3x.png",
53 | "idiom": "ipad",
54 | "scale": "1x"
55 | },
56 | {
57 | "appearances": [
58 | {
59 | "appearance": "luminosity",
60 | "value": "dark"
61 | }
62 | ],
63 | "filename": "LaunchImage-dark-ipad@3x.png",
64 | "idiom": "ipad",
65 | "scale": "1x"
66 | },
67 | {
68 | "filename": "LaunchImage-ipad@3x.png",
69 | "idiom": "ipad",
70 | "scale": "2x"
71 | },
72 | {
73 | "appearances": [
74 | {
75 | "appearance": "luminosity",
76 | "value": "dark"
77 | }
78 | ],
79 | "filename": "LaunchImage-dark-ipad@3x.png",
80 | "idiom": "ipad",
81 | "scale": "2x"
82 | },
83 | {
84 | "filename": "LaunchImage-ipad@3x.png",
85 | "idiom": "ipad",
86 | "scale": "3x"
87 | },
88 | {
89 | "appearances": [
90 | {
91 | "appearance": "luminosity",
92 | "value": "dark"
93 | }
94 | ],
95 | "filename": "LaunchImage-dark-ipad@3x.png",
96 | "idiom": "ipad",
97 | "scale": "3x"
98 | }
99 | ],
100 | "info": {
101 | "author": "xcode",
102 | "version": 1
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-ipad@3x.png.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-ipad@3x.png.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-iphone.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-iphone@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-iphone@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-iphone@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-dark-iphone@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-ipad@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-ipad@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-iphone.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-iphone@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-iphone@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-iphone@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage-iphone@3x.png
--------------------------------------------------------------------------------
/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 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | Freadhub
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(MARKETING_VERSION)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSAllowsArbitraryLoads
28 |
29 |
30 | NSAppleMusicUsageDescription
31 | 是否允许App访问您的媒体资料库
32 | NSCalendarsUsageDescription
33 | 是否允许App访问您的日历
34 | NSCameraUsageDescription
35 | camera
36 | NSContactsUsageDescription
37 | 是否允许App访问您的联系人
38 | NSLocationAlwaysUsageDescription
39 | 是否允许App访问访问您的位置
40 | NSLocationWhenInUseUsageDescription
41 | 是否允许App访问访问您的位置
42 | NSMotionUsageDescription
43 | 是否允许App访问您的运动健康
44 | NSPhotoLibraryUsageDescription
45 | 是否允许App访问您的本地图库
46 | NSSpeechRecognitionUsageDescription
47 | 是否允许App访问您的语音识别
48 | UILaunchStoryboardName
49 | LaunchScreen
50 | UIMainStoryboardFile
51 | Main
52 | UIRequiresFullScreen
53 |
54 | UISupportedInterfaceOrientations
55 |
56 | UIInterfaceOrientationPortrait
57 | UIInterfaceOrientationLandscapeLeft
58 | UIInterfaceOrientationLandscapeRight
59 |
60 | UISupportedInterfaceOrientations~ipad
61 |
62 | UIInterfaceOrientationPortrait
63 | UIInterfaceOrientationPortraitUpsideDown
64 | UIInterfaceOrientationLandscapeLeft
65 | UIInterfaceOrientationLandscapeRight
66 |
67 | UIViewControllerBasedStatusBarAppearance
68 |
69 | io.flutter.embedded_views_preview
70 |
71 | CADisableMinimumFrameDurationOnPhone
72 |
73 | UIApplicationSupportsIndirectInputEvents
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
--------------------------------------------------------------------------------
/lib/basis/basis_highlight_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'basis_view_model.dart';
4 |
5 | ///高亮变化
6 | class BasisHighlightViewModel extends BasisViewModel {
7 | bool _highlight = false;
8 |
9 | bool get highlight => _highlight;
10 |
11 | ValueChanged get onHighlightChanged => (highlight) {
12 | _highlight = highlight;
13 | setSuccess();
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/lib/basis/basis_list_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_readhub/basis/basis_scroll_top_controller.dart';
2 |
3 | import 'basis_view_model.dart';
4 |
5 | /// 一次性获取列表数据
6 | abstract class BasisListViewModel extends BasisViewModel {
7 | ///ScrollController用于控制滚动逻辑
8 | BasisScrollTopController scrollTopController =
9 | BasisScrollTopController.defaultTopController();
10 |
11 | /// 页面数据
12 | List list = [];
13 |
14 | /// 第一次进入页面loading skeleton
15 | initData() async {
16 | setLoading();
17 | await refresh(init: true);
18 | }
19 |
20 | /// 下拉刷新
21 | refresh({bool init = false}) async {
22 | try {
23 | List data = (await loadData())!;
24 | if (data.isEmpty) {
25 | list.clear();
26 | setEmpty();
27 | } else {
28 | onCompleted(data);
29 | list.clear();
30 | list.addAll(data);
31 | setSuccess();
32 | }
33 | } catch (e, s) {
34 | if (init) list.clear();
35 | setError(e, s);
36 | }
37 | }
38 |
39 | /// 加载数据
40 | Future?> loadData();
41 |
42 | onCompleted(List data) {}
43 |
44 | @override
45 | void dispose() {
46 | scrollTopController.scrollController.dispose();
47 | super.dispose();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/lib/basis/basis_refresh_list_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 | import 'package:flutter/foundation.dart';
3 | import 'package:flutter_readhub/basis/basis_list_view_model.dart';
4 | import 'package:pull_to_refresh/pull_to_refresh.dart';
5 |
6 | /// 下拉刷新及上拉加载更多封装
7 | abstract class BasisRefreshListViewModel extends BasisListViewModel {
8 |
9 | /// 分页第一页页码
10 | int pageNumFirst = 0;
11 |
12 | /// 分页条目数量
13 | int pageSize = 12;
14 |
15 | /// 当前页码
16 | int _currentPage = 0;
17 |
18 | int get currentPage => _currentPage;
19 | RefreshController _refreshController =
20 | RefreshController(initialRefresh: false);
21 |
22 | RefreshController get refreshController => _refreshController;
23 |
24 | /// 下拉刷新
25 | ///
26 | /// [init] 是否是第一次加载
27 | /// true: Error时,需要跳转页面
28 | /// false: Error时,不需要跳转页面,直接给出提示
29 | Future?> refresh({bool init = false}) async {
30 | try {
31 | _currentPage = pageNumFirst;
32 | var data = await loadData(pageNum: pageNumFirst);
33 | if (data!.isEmpty) {
34 | refreshController.refreshCompleted(resetFooterState: true);
35 | list.clear();
36 | setEmpty();
37 | } else {
38 | onCompleted(data);
39 | list.clear();
40 | list.addAll(data);
41 | refreshController.refreshCompleted();
42 | /// 小于分页的数量,禁止上拉加载更多
43 | if (data.length < pageSize) {
44 | refreshController.loadNoData();
45 | } else {
46 | ///防止上次上拉加载更多失败,需要重置状态
47 | refreshController.loadComplete();
48 | }
49 | setSuccess();
50 | }
51 | return data;
52 | } catch (e, s) {
53 | /// 页面已经加载了数据,如果刷新报错,不应该直接跳转错误页面
54 | /// 而是显示之前的页面数据.给出错误提示
55 | if (init) list.clear();
56 | refreshController.refreshFailed();
57 | setError(e, s);
58 | return null;
59 | }
60 | }
61 |
62 | /// 上拉加载更多
63 | Future?> loadMore() async {
64 | try {
65 | var data = await loadData(pageNum: ++_currentPage);
66 | if (data!.isEmpty) {
67 | _currentPage--;
68 | refreshController.loadNoData();
69 | } else {
70 | onCompleted(data);
71 | list.addAll(data);
72 | if (data.length < pageSize) {
73 | refreshController.loadNoData();
74 | } else {
75 | refreshController.loadComplete();
76 | }
77 | notifyListeners();
78 | }
79 | return data;
80 | } catch (e, s) {
81 | _currentPage--;
82 | refreshController.loadFailed();
83 | debugPrint('error--->\n' + e.toString());
84 | debugPrint('statck--->\n' + s.toString());
85 | return null;
86 | }
87 | }
88 |
89 | /// 加载数据
90 | Future?> loadData({int? pageNum});
91 |
92 | @override
93 | void dispose() {
94 | _refreshController.dispose();
95 | super.dispose();
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/lib/basis/basis_scroll_top_controller.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | ///滚动回顶部
4 | class BasisScrollTopController {
5 | ///滚动控制器
6 | ScrollController scrollController;
7 |
8 | ///滚动高度阈值
9 | late double _height;
10 |
11 | ///是否滚动到达阈值
12 | bool _showTopBtn = false;
13 |
14 | ///是否显示滚动到顶部
15 | bool _canScrollToTop = true;
16 |
17 | bool get showTopBtn => _showTopBtn && _canScrollToTop;
18 |
19 | ///是否显示
20 | bool get canScrollToTop => _canScrollToTop;
21 |
22 | ///通知回到顶部Widget 刷新
23 | ValueNotifier scrollWidgetNotifier = ValueNotifier(false);
24 |
25 | BasisScrollTopController({
26 | required this.scrollController,
27 | double? height,
28 | bool canScrollToTop= true,
29 | }) {
30 | _height = height ?? 500;
31 | _canScrollToTop = canScrollToTop;
32 | }
33 |
34 | static BasisScrollTopController defaultTopController() =>
35 | BasisScrollTopController(
36 | scrollController: ScrollController(),
37 | );
38 |
39 | setCanScrollTop(bool can) {
40 | _canScrollToTop = can;
41 | scrollWidgetNotifier.value = showTopBtn;
42 | }
43 |
44 | ///初始化滚动监听-一般在initState
45 | initListener() {
46 | scrollController.addListener(() {
47 | bool show = scrollController.offset >= _height;
48 | if (show != _showTopBtn) {
49 | _showTopBtn = show;
50 | scrollWidgetNotifier.value = showTopBtn;
51 | }
52 | });
53 | }
54 |
55 | ///滚动到某个位置
56 | scrollTo({double? offset, Duration? duration, Curve? curve}) {
57 | if (!scrollController.hasClients) {
58 | return;
59 | }
60 | scrollController.animateTo(
61 | offset ?? 0,
62 | duration: duration ?? Duration(milliseconds: 500),
63 | curve: curve ?? Curves.easeInCirc,
64 | );
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/lib/basis/basis_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:dio/dio.dart';
4 | import 'package:flutter/material.dart';
5 | import 'package:flutter_readhub/basis/view_state.dart';
6 | import 'package:flutter_readhub/main.dart';
7 | import 'package:flutter_readhub/util/toast_util.dart';
8 |
9 | ///基础ViewModel
10 | class BasisViewModel with ChangeNotifier {
11 | ///是否销毁
12 | bool isDisposed = false;
13 |
14 | /// 当前的页面状态,默认为loading,可在viewModel的构造方法中指定;
15 | ViewState _viewState;
16 |
17 | /// 根据状态构造
18 | /// 子类可以在构造函数指定需要的页面状态
19 | BasisViewModel({ViewState? viewState})
20 | : _viewState = viewState ?? ViewState.success;
21 |
22 | ViewState get viewState => _viewState;
23 |
24 | set viewState(ViewState viewState) {
25 | _viewStateError = null;
26 | _viewState = viewState;
27 |
28 | ///状态改变通知页面刷新
29 | notifyListeners();
30 | }
31 |
32 | ViewStateError? _viewStateError;
33 |
34 | ViewStateError? get viewStateError => _viewStateError;
35 |
36 | String? get errorMessage => _viewStateError?.message;
37 |
38 | /// 以下变量是为了代码书写方便,加入的get方法.严格意义上讲,并不严谨
39 |
40 | bool get loading => viewState == ViewState.loading;
41 |
42 | bool get success => viewState == ViewState.success;
43 |
44 | bool get empty => viewState == ViewState.empty;
45 |
46 | bool get error => viewState == ViewState.error;
47 |
48 | void setSuccess() {
49 | viewState = ViewState.success;
50 | }
51 |
52 | void setLoading() {
53 | viewState = ViewState.loading;
54 | }
55 |
56 | void setEmpty() {
57 | viewState = ViewState.empty;
58 | }
59 |
60 | /// 未授权的回调
61 | void onUnAuthorizedException() {}
62 |
63 | /// [e]分类Error和Exception两种
64 | void setError(e, stackTrace, {String? message}) {
65 | ErrorType errorType = ErrorType.normal;
66 | if (e is DioError) {
67 | e = e.error;
68 | if (e is HttpException) {
69 | stackTrace = null;
70 | message = e.message;
71 | } else {
72 | errorType = ErrorType.network;
73 | }
74 | }
75 | viewState = ViewState.error;
76 | _viewStateError = ViewStateError(
77 | errorType,
78 | message: message,
79 | errorMessage: e.toString(),
80 | );
81 | printErrorStack(e, stackTrace);
82 | }
83 |
84 | /// 显示错误消息
85 | showErrorMessage(context, {String? message}) {
86 | if (viewStateError != null && message != null) {
87 | if (viewStateError!.isNetworkError) {
88 | message = appString.viewStateNetworkError;
89 | } else {
90 | message = viewStateError!.message;
91 | }
92 | Future.microtask(() {
93 | ToastUtil.show(message!);
94 | });
95 | }
96 | }
97 |
98 | @override
99 | String toString() {
100 | return 'BaseModel{_viewState: $viewState, _viewStateError: $_viewStateError}';
101 | }
102 |
103 | @override
104 | void dispose() {
105 | super.dispose();
106 | isDisposed = true;
107 | }
108 |
109 | @override
110 | void notifyListeners() {
111 | if (isDisposed) {
112 | return;
113 | }
114 | super.notifyListeners();
115 | }
116 | }
117 |
118 | /// [e]为错误类型 :可能为 Error , Exception ,String
119 | /// [s]为堆栈信息
120 | printErrorStack(e, s) {
121 | debugPrint('''
122 | <-----↓↓↓↓↓↓↓↓↓↓-----error-----↓↓↓↓↓↓↓↓↓↓----->
123 | $e
124 | <-----↑↑↑↑↑↑↑↑↑↑-----error-----↑↑↑↑↑↑↑↑↑↑----->''');
125 | if (s != null) debugPrint('''
126 | <-----↓↓↓↓↓↓↓↓↓↓-----trace-----↓↓↓↓↓↓↓↓↓↓----->
127 | $s
128 | <-----↑↑↑↑↑↑↑↑↑↑-----trace-----↑↑↑↑↑↑↑↑↑↑----->
129 | ''');
130 | }
131 |
--------------------------------------------------------------------------------
/lib/basis/view_state.dart:
--------------------------------------------------------------------------------
1 | /// 页面状态类型
2 | enum ViewState {
3 | ///加载中
4 | loading,
5 |
6 | ///暂无数据
7 | empty,
8 |
9 | ///加载失败
10 | error,
11 |
12 | ///成功
13 | success,
14 | }
15 |
16 | /// 错误类型
17 | enum ErrorType {
18 | ///普通错误
19 | normal,
20 |
21 | ///网络错误
22 | network,
23 | }
24 |
25 | class ViewStateError {
26 | ErrorType errorType;
27 | String? message;
28 | String? errorMessage;
29 |
30 | ViewStateError(this.errorType, {this.message, this.errorMessage}) {
31 | errorType = ErrorType.normal;
32 | message ??= errorMessage;
33 | }
34 |
35 | bool get isNetworkError => errorType == ErrorType.network;
36 |
37 | @override
38 | String toString() {
39 | return 'ViewStateError{errorType: $errorType, message: $message, errorMessage: $errorMessage}';
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/data/article_http.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter_readhub/data/basis_http.dart';
3 |
4 | final ArticleHttp http = ArticleHttp();
5 |
6 | ///ReadHub http请求基础处理
7 | class ArticleHttp extends BasisHttp {
8 | ///热门话题
9 | static const String API_TOPIC = "topic";
10 |
11 | ///科技动态--news lab
12 | static const String API_NEWS = "news";
13 |
14 | ///技术资讯
15 | static const String API_TECH_NEWS = "technews";
16 |
17 | ///区块链
18 | static const String API_BLOCK_CHAIN = "blockchain";
19 |
20 | @override
21 | void init() {
22 | options.baseUrl = 'https://api.readhub.me/';
23 | interceptors.add(LogInterceptor(
24 | requestBody: true,
25 | responseBody: true,
26 | ));
27 | interceptors..add(ApiInterceptor());
28 | }
29 | }
30 |
31 | class ApiInterceptor extends InterceptorsWrapper {
32 | @override
33 | onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
34 | LogUtil.v('---article-request--->url--> ${options.baseUrl}${options.path}' +
35 | ' queryParameters: ${options.queryParameters}');
36 | super.onRequest(options, handler);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/data/article_repository.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flustars/flustars.dart';
4 | import 'package:flutter/foundation.dart';
5 | import 'package:flutter_readhub/data/article_http.dart';
6 | import 'package:flutter_readhub/data/basis_http.dart';
7 | import 'package:flutter_readhub/model/article_model.dart';
8 | import 'package:flutter_readhub/util/platform_util.dart';
9 |
10 | ///Readhub 文章接口调用
11 | class ArticleRepository {
12 | static Dio _dio = Dio();
13 |
14 | ///根据传入URL获取首页数据--根据是否传递 lastCursor标识第一页
15 | ///查证只支持每页最多20个
16 | static Future getArticleList(
17 | String url, {
18 | String? lastCursor,
19 | int pageSize = 20,
20 | }) async {
21 | Map? param = lastCursor != null && lastCursor.isNotEmpty
22 | ? {
23 | "lastCursor": lastCursor,
24 | "pageSize": pageSize,
25 | }
26 | : null;
27 | Response response;
28 | if (!PlatformUtil.isWeb) {
29 | response = await http.get(
30 | url,
31 | queryParameters: param,
32 | );
33 | } else {
34 | String targetUrl = 'https://api.readhub.me/$url?pageSize=$pageSize';
35 | if (ObjectUtil.isNotEmpty(lastCursor)) {
36 | targetUrl += '&lastCursor=$lastCursor';
37 | }
38 | if (kIsWeb) {
39 | targetUrl =
40 | 'http://192.168.100.239:9000/common/requestHttpGet?url=$targetUrl';
41 | }
42 | response = await _dio.get(
43 | targetUrl,
44 | );
45 | }
46 | return ArticleModel.fromJson(json.decode(json.encode(response.data)));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/lib/data/basis_http.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:dio/dio.dart';
4 | import 'package:flustars/flustars.dart';
5 | import 'package:flutter/foundation.dart';
6 | import 'package:flutter_readhub/helper/sp_helper.dart';
7 |
8 | export 'package:dio/dio.dart';
9 |
10 | /// 必须是顶层函数
11 | _parseAndDecode(String response) {
12 | return jsonDecode(response);
13 | }
14 |
15 | parseJson(String text) {
16 | return compute(_parseAndDecode, text);
17 | }
18 |
19 | ///网络请求基类--Native使用
20 | abstract class BasisHttp with DioMixin implements Dio {
21 | BasisHttp() {
22 | options = BaseOptions();
23 | httpClientAdapter = HttpClientAdapter();
24 | // (transformer as HttpClientAdapter).jsonDecodeCallback = parseJson;
25 | interceptors..add(HeaderInterceptor());
26 | init();
27 | }
28 |
29 | void init();
30 | }
31 |
32 | /// 添加常用Header
33 | class HeaderInterceptor extends InterceptorsWrapper {
34 | @override
35 | void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
36 | options.connectTimeout = const Duration(seconds: 15);
37 | options.receiveTimeout = const Duration(seconds: 15);
38 | options.responseType = ResponseType.json;
39 | options.contentType = Headers.jsonContentType;
40 | Map headers = options.headers;
41 | if (!TextUtil.isEmpty(SpHelper.getPoemToken())) {
42 | headers.putIfAbsent('X-User-Token', () => SpHelper.getPoemToken());
43 | }
44 | options.headers = headers;
45 | super.onRequest(options, handler);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/data/poem_http.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_readhub/data/basis_http.dart';
2 |
3 | final PoemHttp http = PoemHttp();
4 |
5 | ///诗歌 http请求基础处理
6 | class PoemHttp extends BasisHttp {
7 | @override
8 | void init() {
9 | options.baseUrl = 'https://v2.jinrishici.com/';
10 | interceptors.add(LogInterceptor(
11 | requestBody: true,
12 | responseBody: true,
13 | ));
14 | interceptors..add(ApiInterceptor());
15 | }
16 | }
17 |
18 | class ApiInterceptor extends InterceptorsWrapper {
19 | @override
20 | onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
21 | super.onRequest(options, handler);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/data/poem_repository.dart:
--------------------------------------------------------------------------------
1 | import 'dart:collection';
2 |
3 | import 'package:dio/dio.dart';
4 | import 'package:flustars/flustars.dart';
5 | import 'package:flutter_readhub/data/poem_http.dart';
6 | import 'package:flutter_readhub/helper/sp_helper.dart';
7 | import 'package:flutter_readhub/model/poem_sentence_model.dart';
8 | import 'package:flutter_readhub/util/platform_util.dart';
9 |
10 | ///诗歌
11 | class PoemRepository {
12 | ///获取token
13 | static Future getPoemToken() async {
14 | Response response;
15 | if (!PlatformUtil.isWeb) {
16 | response = await http.get(
17 | 'token',
18 | );
19 | } else {
20 | response = await Dio().get('https://v2.jinrishici.com/token');
21 | }
22 | String token = response.data['data'];
23 | if (!TextUtil.isEmpty(token)) {
24 | SpHelper.setPoemToken(token);
25 | }
26 | return token;
27 | }
28 |
29 | ///获取推荐诗歌
30 | static Future getPoemSentence() async {
31 | Response response;
32 |
33 | ///无token
34 | if (TextUtil.isEmpty(SpHelper.getPoemToken())) {
35 | await getPoemToken();
36 | }
37 | if (!PlatformUtil.isWeb) {
38 | response = await http.get(
39 | 'sentence',
40 | );
41 | } else {
42 | Map headers = LinkedHashMap();
43 | if (!TextUtil.isEmpty(SpHelper.getPoemToken())) {
44 | headers.putIfAbsent('X-User-Token', () => SpHelper.getPoemToken());
45 | }
46 | response = await Dio().get(
47 | 'https://v2.jinrishici.com/sentence',
48 | options: Options(
49 | headers: headers,
50 | ),
51 | );
52 | }
53 | return PoemSentenceModel.fromJson(response.data['data']);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/lib/data/update_http.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flustars/flustars.dart';
4 | import 'package:flutter_readhub/data/basis_http.dart';
5 | import 'package:flutter_readhub/util/platform_util.dart';
6 |
7 | final UpdateHttp http = UpdateHttp();
8 |
9 | ///检查版本更新
10 | class UpdateHttp extends BasisHttp {
11 | @override
12 | void init() {
13 | options.baseUrl = 'https://www.pgyer.com/apiv2/';
14 | interceptors.add(UpdateInterceptor());
15 | interceptors.add(LogInterceptor(
16 | requestBody: true,
17 | responseBody: true,
18 | ));
19 | }
20 | }
21 |
22 | /// App相关 API
23 | class UpdateInterceptor extends InterceptorsWrapper {
24 | @override
25 | void onRequest(
26 | RequestOptions options, RequestInterceptorHandler handler) async {
27 | if (PlatformUtil.isMobile) {
28 | options.queryParameters['_api_key'] = 'f4d7dae2132cf8715c99ca79043deefb';
29 | options.queryParameters['appKey'] = PlatformUtil.isAndroid
30 | ? '9d5adc8a82bdcf48a905d8d5aa7f19e3'
31 | : '430e714ebb8fb7c3f2ab72fa5c5009dc';
32 | }
33 | options.queryParameters['buildVersion'] =
34 | await PlatformUtil.getAppVersion();
35 | options.queryParameters['buildBuildVersion'] =
36 | await PlatformUtil.getBuildNumber();
37 | LogUtil.v(
38 | '---UpdateHttp-UpdateInterceptor-request--->url--> ${options.baseUrl}${options.path}' +
39 | ' queryParameters: ${options.queryParameters}');
40 | super.onRequest(options, handler);
41 | }
42 |
43 | @override
44 | void onResponse(Response response, ResponseInterceptorHandler handler) {
45 | LogUtil.v(
46 | 'UpdateHttp-response:$response;${response.requestOptions.queryParameters['String']}');
47 | ResponseData respData;
48 | ///桌面端检查新版特殊处理
49 | if (response.requestOptions.queryParameters.containsKey('String')) {
50 | respData = ResponseData();
51 | respData.code = 0;
52 | respData.data = json.decode('$response');
53 | } else {
54 | respData = ResponseData.fromJson(response.data);
55 | }
56 | LogUtil.v('UpdateHttp-UpdateInterceptor-onResponse:$respData');
57 | if (respData.success) {
58 | response.data = respData.data;
59 | return handler.resolve(response);
60 | } else {
61 | handler.reject(DioError(requestOptions: response.requestOptions));
62 | }
63 | }
64 | }
65 |
66 | class ResponseData {
67 | int? code = 0;
68 | String? message;
69 | dynamic data;
70 |
71 | bool get success => code == 0;
72 |
73 | ResponseData();
74 |
75 | ResponseData.fromJson(Map json) {
76 | code = json['code'];
77 | message = json['message'];
78 | data = json['data'];
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/lib/data/update_repository.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flustars/flustars.dart';
3 | import 'package:flutter_readhub/data/update_http.dart';
4 | import 'package:flutter_readhub/model/app_update_model.dart';
5 | import 'package:flutter_readhub/util/platform_util.dart';
6 |
7 | import 'basis_http.dart';
8 |
9 | /// App更新相关接口
10 | class UpdateRepository {
11 | ///检查app版本升级
12 | static Future checkUpdate() async {
13 | Response response;
14 | if (PlatformUtil.isMobile) {
15 | response = await http.post('app/check');
16 | } else if (PlatformUtil.isMacOS) {
17 | response = await checkDesktopUpdate();
18 | } else {
19 | return null;
20 | }
21 | var result = AppUpdateModel.fromJson(response.data);
22 |
23 | ///此处如此处理主要因iOS-buildVersion
24 | ///蒲公英判断出错 貌似根据 buildBuildVersion-判断
25 | if (PlatformUtil.isMobile) {
26 | result.buildHaveNewVersion = true == result.buildHaveNewVersion &&
27 | await PlatformUtil.getBuildNumber() != result.buildVersionNo;
28 | } else {
29 | result.buildHaveNewVersion =
30 | await PlatformUtil.getBuildNumber() != result.buildVersionNo;
31 | }
32 | if (result.buildHaveNewVersion!) {
33 | LogUtil.v('checkUpdate-发现新版本->${result.buildVersion}');
34 | return result;
35 | }
36 | return null;
37 | }
38 |
39 | ///检测桌面版本新版
40 | static Future checkDesktopUpdate() async {
41 | return await http.get(
42 | 'https://gitee.com/AriesHoo/flutter_readhub/raw/master/update/macos',
43 | queryParameters: {'String': true},
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/dialog/basis_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:flustars/flustars.dart';
4 | import 'package:flutter/material.dart';
5 | import 'package:flutter_readhub/util/platform_util.dart';
6 |
7 | ///基础Dialog
8 | class BasisDialog extends Dialog {
9 | final Widget? kid;
10 | final double maxWidth;
11 | final double minWidth;
12 | final AlignmentGeometry alignment;
13 |
14 | BasisDialog({
15 | Key? key,
16 | this.kid,
17 | this.maxWidth = 360.0,
18 | this.minWidth = 280.0,
19 | this.alignment = Alignment.center,
20 | });
21 |
22 | @override
23 | EdgeInsets? get insetPadding => EdgeInsets.only(
24 | left: 20,
25 | right: 20,
26 | bottom: MediaQueryData.fromWindow(window).padding.bottom + 20,
27 | top: PlatformUtil.isMobile
28 | ? MediaQueryData.fromWindow(window).padding.top
29 | : 20,
30 | );
31 |
32 | @override
33 | Widget? get child => SingleChildScrollView(
34 | physics: ClampingScrollPhysics(),
35 | child: kid,
36 | );
37 |
38 | @override
39 | Clip get clipBehavior => Clip.antiAliasWithSaveLayer;
40 |
41 | @override
42 | Widget build(BuildContext context) {
43 | final DialogTheme dialogTheme = DialogTheme.of(context);
44 | final EdgeInsets effectivePadding =
45 | MediaQuery.of(context).viewInsets + (insetPadding ?? EdgeInsets.zero);
46 | LogUtil.v('insetPadding:$insetPadding');
47 | final Widget childWidget = AnimatedPadding(
48 | padding: effectivePadding,
49 | duration: insetAnimationDuration,
50 | curve: insetAnimationCurve,
51 | child: MediaQuery.removeViewInsets(
52 | removeLeft: true,
53 | removeTop: true,
54 | removeRight: true,
55 | removeBottom: true,
56 | context: context,
57 | child: Align(
58 | alignment: alignment,
59 | child: Material(
60 | color: backgroundColor ??
61 | dialogTheme.backgroundColor ??
62 | Theme.of(context).dialogBackgroundColor,
63 | elevation: elevation ?? dialogTheme.elevation ?? 0,
64 | shape: shape ?? dialogTheme.shape,
65 | type: MaterialType.card,
66 | clipBehavior: clipBehavior,
67 | child: ConstrainedBox(
68 | constraints: BoxConstraints(
69 | minWidth: minWidth,
70 | maxWidth: maxWidth,
71 | ),
72 |
73 | /// 特殊处理点击child部分不响应关闭事件
74 | ///即:点击半透明部分才关闭Dialog
75 | child: GestureDetector(
76 | onTap: () => LogUtil.v('点击child'),
77 | child: child,
78 | ),
79 | ),
80 | ),
81 | ),
82 | ),
83 | );
84 |
85 | ///ModalBottomSheet 特殊处理点击非child部分关闭
86 | return Material(
87 | color: Colors.transparent,
88 | child: InkWell(
89 | hoverColor: Colors.transparent,
90 | highlightColor: Colors.transparent,
91 | splashColor: Colors.transparent,
92 | focusColor: Colors.transparent,
93 | onTap: () => Navigator.of(context).pop(),
94 | child: childWidget,
95 | ),
96 | );
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/lib/dialog/theme_dialog.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_readhub/dialog/basis_dialog.dart';
4 | import 'package:flutter_readhub/helper/provider_helper.dart';
5 | import 'package:flutter_readhub/util/dialog_util.dart';
6 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
7 |
8 | ///弹出颜色选择框
9 | Future showThemeDialog(BuildContext context) async {
10 | DialogUtil.showModalBottomSheetDialog(
11 | context,
12 | clipBehavior: Clip.antiAliasWithSaveLayer,
13 | shape: RoundedRectangleBorder(
14 | borderRadius: BorderRadius.vertical(
15 | top: Radius.circular(12),
16 | ),
17 | ),
18 | barrierColor: Colors.black54.withOpacity(0.2),
19 | // backgroundColor: Colors.transparent,
20 | child: ThemeDialog(),
21 | );
22 | }
23 |
24 | ///主题选择Dialog
25 | class ThemeDialog extends BasisDialog {
26 | @override
27 | double get minWidth => double.infinity;
28 |
29 | @override
30 | double get maxWidth => double.infinity;
31 |
32 | @override
33 | EdgeInsets? get insetPadding => EdgeInsets.zero;
34 |
35 | @override
36 | AlignmentGeometry get alignment => Alignment.bottomLeft;
37 |
38 | @override
39 | ShapeBorder? get shape => RoundedRectangleBorder(
40 | borderRadius: BorderRadius.only(
41 | topLeft: Radius.circular(12),
42 | topRight: Radius.circular(12),
43 | ),
44 | );
45 |
46 | @override
47 | Widget? get kid => Builder(builder: (context) {
48 | ///单个Button最终宽度
49 | double finalWidth = 200;
50 |
51 | ///单个Button最小宽度
52 | double minWidth = 200;
53 |
54 | ///Button间水平间距
55 | double spacing = 24;
56 |
57 | ///Button可用屏幕宽度-屏幕宽度减去 整个区域水平边界
58 | double screenWidth = MediaQuery.of(context).size.width - 24;
59 |
60 | int count = screenWidth ~/ (minWidth + spacing);
61 |
62 | if (count > 4) {
63 | count = 4;
64 | }
65 |
66 | ///只够显示一个
67 | if (count <= 1) {
68 | finalWidth = double.infinity;
69 | } else {
70 | finalWidth = (screenWidth - count * spacing) / count;
71 | }
72 | return Padding(
73 | padding: EdgeInsets.only(
74 | left: 24,
75 | right: count <= 1 ? 24 : 0,
76 | top: 24,
77 | bottom: 24,
78 | ),
79 |
80 | ///所有颜色按钮垂直排列
81 | child: Wrap(
82 | runSpacing: count <= 1 ? 12 : 16,
83 | spacing: spacing,
84 | children: ThemeViewModel.themeValueList.map((color) {
85 | int index = ThemeViewModel.themeValueList.indexOf(color);
86 | return Material(
87 | borderRadius: BorderRadius.circular(12),
88 | clipBehavior: Clip.hardEdge,
89 | color: ThemeViewModel.getThemeColor(i: index),
90 | child: InkWell(
91 | onTap: () {
92 | var model = ProviderHelper.of(context);
93 | model.switchTheme(themeIndex: index);
94 | Navigator.of(context).pop();
95 | },
96 | splashColor: Colors.black.withAlpha(50),
97 | child: Stack(
98 | alignment: AlignmentDirectional.center,
99 | children: [
100 | Container(
101 | width: finalWidth,
102 | height: count > 1 ? 52 : 46,
103 | child: Center(
104 | child: Text(
105 | ThemeViewModel.themeName(i: index),
106 | textScaleFactor: ThemeViewModel.textScaleFactor,
107 | style: TextStyle(
108 | fontWeight: FontWeight.normal,
109 | color: Colors.white,
110 | fontSize: 15,
111 | ),
112 | ),
113 | ),
114 | ),
115 | Padding(
116 | padding: EdgeInsets.only(left: 120),
117 | child: Icon(
118 | Icons.check,
119 | size: 22,
120 | color: index ==
121 | ProviderHelper.of(context)
122 | .themeIndex
123 | ? Colors.white
124 | : Colors.transparent,
125 | ),
126 | ),
127 | ],
128 | ),
129 | ),
130 | );
131 | }).toList(),
132 | ),
133 | );
134 | });
135 | }
136 |
--------------------------------------------------------------------------------
/lib/dialog/url_share_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_readhub/dialog/basis_dialog.dart';
5 | import 'package:flutter_readhub/dialog/card_share_dialog.dart';
6 | import 'package:flutter_readhub/enum/share_type.dart';
7 | import 'package:flutter_readhub/helper/share_helper.dart';
8 | import 'package:flutter_readhub/main.dart';
9 | import 'package:flutter_readhub/model/share_model.dart';
10 | import 'package:flutter_readhub/util/adaptive.dart';
11 | import 'package:flutter_readhub/util/dialog_util.dart';
12 | import 'package:flutter_readhub/util/platform_util.dart';
13 | import 'package:flutter_readhub/util/share_util.dart';
14 | import 'package:flutter_readhub/view_model/share_view_model.dart';
15 | import 'package:flutter_readhub/widget/share_widget.dart';
16 |
17 | ///webView分享url dialog
18 | class UrlShareDialog extends BasisDialog {
19 | ///打开分享dialog
20 | static start(CardShareModel model) {
21 | DialogUtil.showModalBottomSheetDialog(
22 | navigatorKey.currentContext!,
23 | settings: RouteSettings(name: 'url_share_dialog'),
24 | childOutside: true,
25 | child: UrlShareDialog(model: model),
26 | backgroundColor: Colors.transparent,
27 | barrierColor: Colors.black54.withOpacity(0.2),
28 | );
29 | }
30 |
31 | UrlShareDialog({
32 | Key? key,
33 | required this.model,
34 | });
35 |
36 | ///分享实体
37 | final CardShareModel model;
38 |
39 | @override
40 | double get maxWidth => smallDisplay ? double.infinity : 460;
41 |
42 | @override
43 | double? get elevation => 0;
44 |
45 | @override
46 | EdgeInsets? get insetPadding => smallDisplay
47 | ? EdgeInsets.only(
48 | top: PlatformUtil.isMobile
49 | ? MediaQueryData.fromWindow(window).padding.top
50 | : 20,
51 | )
52 | : super.insetPadding;
53 |
54 | @override
55 | ShapeBorder? get shape => RoundedRectangleBorder(
56 | borderRadius: smallDisplay
57 | ? BorderRadius.only(
58 | topLeft: Radius.circular(12),
59 | topRight: Radius.circular(12),
60 | )
61 | : BorderRadius.circular(12),
62 | );
63 |
64 | @override
65 | AlignmentGeometry get alignment =>
66 | smallDisplay ? Alignment.bottomCenter : Alignment.bottomRight;
67 |
68 | @override
69 | Widget? get kid => ShareBottomWidget(
70 | model: ShareUrlViewModel(),
71 | safeAreaBottom: smallDisplay,
72 | onClick: _onShareClick,
73 | );
74 |
75 | ///点击分享
76 | _onShareClick(type, ctx) {
77 | if (smallDisplay) {
78 | Navigator.of(navigatorKey.currentContext!).pop();
79 | }
80 | final box = ctx.findRenderObject() as RenderBox?;
81 | final rect = box!.localToGlobal(Offset.zero) & box.size;
82 | switch (type) {
83 |
84 | ///卡片分享
85 | case ShareType.card:
86 | CardShareDialog.show(navigatorKey.currentContext!, model);
87 | break;
88 |
89 | ///微信好友
90 | case ShareType.weChatFriend:
91 | ShareUtil.shareTextToWeChatFriend(model.text!, rect: rect);
92 | break;
93 |
94 | ///QQ好友
95 | case ShareType.qqFriend:
96 | ShareUtil.shareTextToQQFriend(model.text!, rect: rect);
97 | break;
98 |
99 | ///微博内容
100 | case ShareType.weiBoTimeLine:
101 | ShareUtil.shareTextToWeiBoTimeLine(model.text!, rect: rect);
102 | break;
103 |
104 | ///钉钉
105 | case ShareType.dingTalk:
106 | ShareUtil.shareTextToDingTalk(model.text!, rect: rect);
107 | break;
108 |
109 | ///企业微信
110 | case ShareType.weWork:
111 | ShareUtil.shareTextToWeWork(model.text!, rect: rect);
112 | break;
113 |
114 | ///复制链接
115 | case ShareType.copyLink:
116 | ShareHelper.singleton.shareTextToClipboard(model.url);
117 | break;
118 |
119 | ///浏览器打开
120 | case ShareType.browser:
121 | ShareHelper.singleton
122 | .shareTextOpenByBrowser(model.showUrl ?? model.url);
123 | break;
124 |
125 | ///所有可选
126 | case ShareType.more:
127 | ShareUtil.shareText(
128 | model.text!,
129 | subject: appString.saveImageShareTip,
130 | rect: rect,
131 | );
132 | break;
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/lib/enum/share_card_style.dart:
--------------------------------------------------------------------------------
1 | ///分享卡片样式
2 | enum ShareCardStyle {
3 | ///app内置样式
4 | app,
5 |
6 | ///掘金样式
7 | gold,
8 | }
9 |
--------------------------------------------------------------------------------
/lib/enum/share_type.dart:
--------------------------------------------------------------------------------
1 | ///分享类型
2 | enum ShareType {
3 | ///卡片分享
4 | card,
5 |
6 | ///微信好友
7 | weChatFriend,
8 |
9 | ///微信朋友圈
10 | weChatTimeLine,
11 |
12 | ///QQ好友
13 | qqFriend,
14 |
15 | ///微博内容
16 | weiBoTimeLine,
17 |
18 | ///钉钉
19 | dingTalk,
20 |
21 | ///企业微信
22 | weWork,
23 |
24 | ///复制链接
25 | copyLink,
26 |
27 | ///浏览器打开
28 | browser,
29 |
30 | ///更多
31 | more,
32 |
33 | ///icon
34 | icon,
35 | }
36 |
--------------------------------------------------------------------------------
/lib/generated/intl/messages_all.dart:
--------------------------------------------------------------------------------
1 | // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2 | // This is a library that looks up messages for specific locales by
3 | // delegating to the appropriate library.
4 |
5 | // Ignore issues from commonly used lints in this file.
6 | // ignore_for_file:implementation_imports, file_names, unnecessary_new
7 | // ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
8 | // ignore_for_file:argument_type_not_assignable, invalid_assignment
9 | // ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
10 | // ignore_for_file:comment_references
11 |
12 | import 'dart:async';
13 |
14 | import 'package:intl/intl.dart';
15 | import 'package:intl/message_lookup_by_library.dart';
16 | import 'package:intl/src/intl_helpers.dart';
17 |
18 | import 'messages_en.dart' as messages_en;
19 | import 'messages_zh.dart' as messages_zh;
20 |
21 | typedef Future LibraryLoader();
22 | Map _deferredLibraries = {
23 | 'en': () => new Future.value(null),
24 | 'zh': () => new Future.value(null),
25 | };
26 |
27 | MessageLookupByLibrary? _findExact(String localeName) {
28 | switch (localeName) {
29 | case 'en':
30 | return messages_en.messages;
31 | case 'zh':
32 | return messages_zh.messages;
33 | default:
34 | return null;
35 | }
36 | }
37 |
38 | /// User programs should call this before using [localeName] for messages.
39 | Future initializeMessages(String localeName) async {
40 | var availableLocale = Intl.verifiedLocale(
41 | localeName, (locale) => _deferredLibraries[locale] != null,
42 | onFailure: (_) => null);
43 | if (availableLocale == null) {
44 | return new Future.value(false);
45 | }
46 | var lib = _deferredLibraries[availableLocale];
47 | await (lib == null ? new Future.value(false) : lib());
48 | initializeInternalMessageLookup(() => new CompositeMessageLookup());
49 | messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
50 | return new Future.value(true);
51 | }
52 |
53 | bool _messagesExistFor(String locale) {
54 | try {
55 | return _findExact(locale) != null;
56 | } catch (e) {
57 | return false;
58 | }
59 | }
60 |
61 | MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
62 | var actualLocale =
63 | Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
64 | if (actualLocale == null) return null;
65 | return _findExact(actualLocale);
66 | }
67 |
--------------------------------------------------------------------------------
/lib/generated/intl/messages_zh.dart:
--------------------------------------------------------------------------------
1 | // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
2 | // This is a library that provides messages for a zh locale. All the
3 | // messages from the main program should be duplicated here with the same
4 | // function name.
5 |
6 | // Ignore issues from commonly used lints in this file.
7 | // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
8 | // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
9 | // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
10 | // ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
11 | // ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes
12 |
13 | import 'package:intl/intl.dart';
14 | import 'package:intl/message_lookup_by_library.dart';
15 |
16 | final messages = new MessageLookup();
17 |
18 | typedef String MessageIfAbsent(String messageStr, List args);
19 |
20 | class MessageLookup extends MessageLookupByLibrary {
21 | String get localeName => 'zh';
22 |
23 | final messages = _notInlinedMessages(_notInlinedMessages);
24 | static Map _notInlinedMessages(_) => {};
25 | }
26 |
--------------------------------------------------------------------------------
/lib/helper/path_helper.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter_readhub/util/platform_util.dart';
3 | import 'package:path_provider/path_provider.dart';
4 |
5 | ///文件路径帮助类
6 | class PathHelper {
7 | // /// 获取存储路径
8 | // static Future getLocalPath() async {
9 | // /// 因为Apple没有外置存储,所以第一步我们需要先对所在平台进行判断
10 | // /// 如果是android,使用getExternalStorageDirectory
11 | // /// 如果是iOS,使用getApplicationSupportDirectory
12 | // // final directory = PlatformUtil.isAndroid
13 | // // ? await getExternalStorageDirectory()
14 | // // : await getApplicationSupportDirectory();
15 | // final directory = await getTemporaryDirectory();
16 | // return directory.path;
17 | // }
18 |
19 | /// 获取存储路径
20 | static Future getLocalPath() async {
21 | /// 因为Apple没有外置存储,所以第一步我们需要先对所在平台进行判断
22 | /// 如果是android,使用getExternalStorageDirectory
23 | /// 如果是iOS,使用getApplicationDocumentsDirectory
24 | final directory = PlatformUtil.isAndroid
25 | ? await getExternalStorageDirectory()
26 | : await getApplicationDocumentsDirectory();
27 | return directory!.path;
28 | }
29 |
30 | /// 斜杠'/'打头
31 | static Future getFilePath(String path) async {
32 | /// 获取存储路径
33 | var _localPath = (await getLocalPath()) + path;
34 | var _savedDir = Directory(_localPath);
35 |
36 | /// 判断路径是否存在
37 | bool hasExisted = await _savedDir.exists();
38 |
39 | /// 不存在就新建路径
40 | if (!hasExisted) {
41 | _savedDir.create();
42 | }
43 | return _savedDir.path;
44 | }
45 |
46 | ///获取分享图片截图
47 | static Future getImagePath() async {
48 | return getFilePath('/ShareScreenShots');
49 | }
50 |
51 | ///获取分享图片路径-保存图片分享
52 | static Future getShareImage() async {
53 | return getFilePath('/ShareImage');
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/lib/helper/permission_helper.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_readhub/util/platform_util.dart';
2 | import 'package:permission_handler/permission_handler.dart';
3 |
4 | ///权限获取帮助类
5 | class PermissionHelper {
6 | /// 申请权限
7 | static Future checkPermission(Permission permission) async {
8 | PermissionStatus status = await permission.status;
9 | if (status != PermissionStatus.granted) {
10 | status = await permission.request();
11 | return status == PermissionStatus.granted;
12 | } else {
13 | return true;
14 | }
15 | }
16 |
17 | ///文件读写android storage iOS photos
18 | static Future checkStoragePermission() async {
19 | if (!PlatformUtil.isMobile) {
20 | return Future.value(true);
21 | }
22 | return checkPermission(
23 | PlatformUtil.isAndroid ? Permission.storage : Permission.storage);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lib/helper/provider_helper.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 | import 'package:provider/provider.dart';
4 |
5 | ///Provider帮助类
6 | class ProviderHelper{
7 |
8 | static T of(BuildContext context, {bool listen = false}){
9 | return Provider.of(context,listen: listen);
10 | }
11 | }
--------------------------------------------------------------------------------
/lib/helper/save_image_helper.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 | import 'dart:ui';
3 |
4 | import 'package:flustars/flustars.dart';
5 | import 'package:flutter/rendering.dart';
6 | import 'package:flutter/widgets.dart';
7 | import 'package:flutter_readhub/helper/path_helper.dart';
8 | import 'package:flutter_readhub/helper/permission_helper.dart';
9 | import 'package:flutter_readhub/main.dart';
10 | import 'package:flutter_readhub/util/dialog_util.dart';
11 | import 'package:flutter_readhub/util/platform_util.dart';
12 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
13 | import 'package:permission_handler/permission_handler.dart';
14 |
15 | ///保存图片到本地存储
16 | class SaveImageHelper {
17 | ///已保存图片的路径
18 | String? _fileImage;
19 | Uint8List? _pngBytes;
20 | GlobalKey? _globalKey;
21 | bool? _darkModel;
22 |
23 | Future getImagePath(String imageName) async {
24 | File fileImage = await PathHelper.getShareImage()
25 | .then((value) => File('$value/$imageName'));
26 | return fileImage.path;
27 | }
28 |
29 | ///保存图片
30 | Future saveImage(
31 | BuildContext context, GlobalKey globalKey, String imageName) async {
32 | ///key相等才有可能是同一图像
33 | ///明暗主题相同
34 | if (globalKey == _globalKey &&
35 | ThemeViewModel.darkMode == _darkModel &&
36 | _fileImage != null &&
37 | _fileImage!.isNotEmpty &&
38 | File(_fileImage!).existsSync()) {
39 | ///已经存在
40 | return _fileImage!;
41 | }
42 | _globalKey = globalKey;
43 | _darkModel = ThemeViewModel.darkMode;
44 | _fileImage = null;
45 |
46 | ///直接获取读写文件权限
47 | if (!await PermissionHelper.checkStoragePermission()) {
48 | DialogUtil.showAlertDialog(
49 | context,
50 | title: PlatformUtil.isIOS ? appString.dialogTitle : null,
51 | content: appString.shareImageNeedInvite +
52 | (PlatformUtil.isIOS ? appString.photo : appString.fileStorage),
53 | cancel: appString.noPermission,
54 | ensure: appString.goPermission,
55 | ).then((value) {
56 | if (value == 1) {
57 | openAppSettings();
58 | }
59 | });
60 | return null;
61 | }
62 | RenderRepaintBoundary boundary =
63 | globalKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
64 |
65 | ///弹框宽度与屏幕宽度比值避免截图出来比预览更大
66 | ///分辨率通过获取设备的devicePixelRatio以达到清晰度良好
67 | var image = await boundary.toImage(
68 | pixelRatio: (MediaQuery.of(context).devicePixelRatio));
69 |
70 | ///转二进制
71 | ByteData byteData = (await image.toByteData(format: ImageByteFormat.png))!;
72 |
73 | ///图片数据
74 | _pngBytes = byteData.buffer.asUint8List();
75 |
76 | ///保存图片到系统图库
77 | File saveFile = File(await getImagePath(imageName));
78 | LogUtil.v('saveFile:${saveFile.path}');
79 | bool exist = saveFile.existsSync() && saveFile.lengthSync() > 0;
80 | if (!exist) {
81 | if (!saveFile.existsSync()) {
82 | await saveFile.create();
83 | }
84 | File file = await saveFile.writeAsBytes(_pngBytes!);
85 | exist = await file.exists();
86 | }
87 | if (exist) {
88 | _fileImage = saveFile.absolute.path;
89 | return saveImage(context, globalKey, imageName);
90 | }
91 | return null;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/lib/helper/share_helper.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter/services.dart';
3 | import 'package:flutter_readhub/main.dart';
4 | import 'package:flutter_readhub/util/toast_util.dart';
5 | import 'package:url_launcher/url_launcher_string.dart';
6 |
7 | ///分享帮助类
8 | class ShareHelper {
9 | static final ShareHelper _singleton = ShareHelper._internal();
10 |
11 | static ShareHelper get singleton => _singleton;
12 |
13 | ///工厂构造函数
14 | factory ShareHelper() {
15 | return _singleton;
16 | }
17 |
18 | ///构造函数私有化,防止被误创建
19 | ShareHelper._internal();
20 |
21 | ///分享文本到粘贴板
22 | Future shareTextToClipboard(String text, {String? tip}) {
23 | return Clipboard.setData(ClipboardData(text: text)).then(
24 | (value) => ToastUtil.show(tip ?? appString.copyToClipboardSucceed));
25 | }
26 |
27 | ///分享网址-通过系统浏览器打开
28 | void shareTextOpenByBrowser(String url) async {
29 | try {
30 | await launchUrlString(url);
31 | } catch (e) {
32 | LogUtil.v('e:$e}', tag: 'shareTextOpenByBrowser');
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/lib/helper/sp_helper.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter_readhub/model/poem_sentence_model.dart';
3 |
4 | ///SP相关帮助类
5 | class SpHelper {
6 | ///设置上次登录账号当前为手机号
7 | static Future setPoemToken(String value) async {
8 | return await SpUtil.putString('PoemToken', value);
9 | }
10 |
11 | ///获取上次登录账号当前为手机号
12 | static String getPoemToken() {
13 | return SpUtil.getString('PoemToken', defValue: '')!;
14 | }
15 |
16 | ///设置已获取到的推荐诗歌
17 | static Future setPoemSentenceModel(PoemSentenceModel value) async {
18 | return await SpUtil.putObject('PoemSentenceModel', value);
19 | }
20 |
21 | ///获取最近一次缓存诗歌
22 | static PoemSentenceModel? getPoemSentenceModel() {
23 | return SpUtil.getObj('PoemSentenceModel', (v) => PoemSentenceModel.fromJson(v),defValue: null);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lib/l10n/intl_en.arb:
--------------------------------------------------------------------------------
1 | {
2 | "appName": "Freadhub",
3 | "appTitle": "Freadhub-聚合资讯",
4 | "slogan": "做轻便的聚合资讯",
5 | "dialogTitle": "温馨提示",
6 | "choiceTheme": "选择主题",
7 | "red": "网易红",
8 | "orange": "滴滴橙",
9 | "yellow": "闲鱼黄",
10 | "green": "微信绿",
11 | "cyan": "青桔青",
12 | "blue": "掘金蓝",
13 | "purple": "夸克紫",
14 | "monday": "周一",
15 | "tuesday": "周二",
16 | "wednesday": "周三",
17 | "thursday": "周四",
18 | "friday": "周五",
19 | "saturday": "周六",
20 | "sunday": "周日",
21 | "darkMode": "深色主题",
22 | "lightMode": "浅色主题",
23 | "moreSetting": "更多信息",
24 | "loadingWebTitle": "加载中...",
25 | "back": "后退",
26 | "forward": "前进",
27 | "refresh": "刷新",
28 | "share": "分享",
29 | "loadIdle": "上拉或点击加载更多",
30 | "loadFailed": "加载失败",
31 | "loadNoMore": "我也是有底线的",
32 | "quitApp": "再点击一次退出程序",
33 | "viewStateError": "加载失败",
34 | "viewStateNetworkError": "网络好像不给力哟!",
35 | "viewStateEmpty": "空空如也",
36 | "viewStateRefresh": "刷新一下",
37 | "viewStateRetry": "重试",
38 | "settingHideFloatingButton": "隐藏悬浮按钮",
39 | "settingStyle": "样式",
40 | "downloadImage": "保存图片到本地",
41 | "saveImageSucceedInGallery": "已保存至手机",
42 | "saveImagePermissionFailed": "文件读写权限获取失败",
43 | "saveImageFailed": "保存文件失败",
44 | "saveImageShareTip": "分享自「Freadhub」App ",
45 | "cancel": "取消",
46 | "openBySystemBrowser": "浏览器打开-推荐Chrome",
47 | "appCopyright": "软件说明",
48 | "feedback": "意见反馈",
49 | "checkUpdate": "检查版本",
50 | "shareApp": "分享软件",
51 | "currentIsNew": "当前已是最新版本",
52 | "updateNow": "立即更新",
53 | "updateNextTime": "下次再说",
54 | "fontSize": "文字大小",
55 | "appreciateDeveloper": "赞赏开发",
56 | "english": "英语",
57 | "tipSwitchThemeWhenPlatformDark": "当前系统为深色主题",
58 | "tipNoEmailApp": "请安装邮箱app后重试!",
59 | "tooltipScrollTop": "回到顶部",
60 | "copyToClipboardSucceed": "复制成功",
61 | "cardShare": "卡片分享",
62 | "weChatFriend": "微信",
63 | "weChatTimeLine": "朋友圈",
64 | "qqFriend": "QQ",
65 | "weiBoTimeLine": "微博",
66 | "dingTalk": "钉钉",
67 | "weWork": "企业微信",
68 | "copyLink": "复制链接",
69 | "copyShare": "复制去分享",
70 | "openByBrowser": "浏览器打开",
71 | "more": "更多",
72 | "shareToApp": "分享应用",
73 | "aboutUsShareTitle": "分享您一个不错的App",
74 | "scanOrCodeForDetail": "识别二维码查看详情",
75 | "shareForm": "分享自",
76 | "shareImageNeedInvite": "分享功能需使用访问您的",
77 | "photo": "照片",
78 | "fileStorage": "文件存储",
79 | "noPermission": "暂不授权",
80 | "goPermission": "去授权",
81 | "shareCarStyle": "卡片样式",
82 | "shareCarStyleApp": "Freadhub样式",
83 | "shareCarStyleJueJin": "掘金样式",
84 | "shotFailed": "截图失败,请开启访问存储权限",
85 | "weChatNotInstall": "您还未安装微信",
86 | "openDetail": "查看详情",
87 | "forward": "前进",
88 | "back": "后退"
89 | }
--------------------------------------------------------------------------------
/lib/l10n/intl_zh.arb:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/lib/manager/router_manger.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_readhub/model/share_model.dart';
3 | import 'package:flutter_readhub/page/home_page.dart';
4 | import 'package:flutter_readhub/page/web_view_page.dart';
5 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
6 |
7 | class RouteName {
8 | static const String web_view_page = 'web_view_page';
9 | static const String tab = 'tab';
10 | }
11 |
12 | ///用于main MaterialApp配置 onGenerateRoute
13 | class RouterManager {
14 | static Route generateRoute(RouteSettings settings) {
15 | switch (settings.name) {
16 | case RouteName.tab:
17 | return MaterialPageRoute(
18 | settings: RouteSettings(name: settings.name),
19 | fullscreenDialog: true,
20 | builder: (context) => HomePage(),
21 | );
22 | case RouteName.web_view_page:
23 | CardShareModel model = settings.arguments as CardShareModel;
24 | return MaterialPageRoute(
25 | settings: RouteSettings(name: settings.name),
26 | fullscreenDialog: true,
27 | builder: (context) => WebViewPage(
28 | model,
29 | ),
30 | );
31 | default:
32 | return MaterialPageRoute(
33 | builder: (context) => Scaffold(
34 | body: Center(
35 | child: Text(
36 | 'No route defined for ${settings.name}',
37 | textScaleFactor: ThemeViewModel.textScaleFactor,
38 | ),
39 | ),
40 | ));
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/model/app_update_model.dart:
--------------------------------------------------------------------------------
1 | /// CheckApp更新接口
2 | class AppUpdateModel {
3 | String? buildBuildVersion;
4 | bool? buildHaveNewVersion;
5 | String? buildShortcutUrl;
6 | String? buildUpdateDescription;
7 | String? buildVersion;
8 | String? buildVersionNo;
9 | String? downloadURL;
10 | String? forceUpdateVersion;
11 | String? forceUpdateVersionNo;
12 | bool? needForceUpdate;
13 |
14 | AppUpdateModel(
15 | {this.buildBuildVersion,
16 | this.buildHaveNewVersion,
17 | this.buildShortcutUrl,
18 | this.buildUpdateDescription,
19 | this.buildVersion,
20 | this.buildVersionNo,
21 | this.downloadURL,
22 | this.forceUpdateVersion,
23 | this.forceUpdateVersionNo,
24 | this.needForceUpdate});
25 |
26 | factory AppUpdateModel.fromJson(Map json) {
27 | return AppUpdateModel(
28 | buildBuildVersion: json['buildBuildVersion'],
29 | buildHaveNewVersion: json['buildHaveNewVersion'],
30 | buildShortcutUrl: json['buildShortcutUrl'],
31 | buildUpdateDescription: json['buildUpdateDescription'],
32 | buildVersion: json['buildVersion'],
33 | buildVersionNo: json['buildVersionNo'],
34 | downloadURL: json['downloadURL'],
35 | forceUpdateVersion: json['forceUpdateVersion'],
36 | forceUpdateVersionNo: json['forceUpdateVersionNo'],
37 | needForceUpdate: json['needForceUpdate'],
38 | );
39 | }
40 |
41 | Map toJson() {
42 | final Map data = new Map();
43 | data['buildBuildVersion'] = this.buildBuildVersion;
44 | data['buildHaveNewVersion'] = this.buildHaveNewVersion;
45 | data['buildShortcutUrl'] = this.buildShortcutUrl;
46 | data['buildUpdateDescription'] = this.buildUpdateDescription;
47 | data['buildVersion'] = this.buildVersion;
48 | data['buildVersionNo'] = this.buildVersionNo;
49 | data['downloadURL'] = this.downloadURL;
50 | data['forceUpdateVersion'] = this.forceUpdateVersion;
51 | data['forceUpdateVersionNo'] = this.forceUpdateVersionNo;
52 | data['needForceUpdate'] = this.needForceUpdate;
53 | return data;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/lib/model/poem_sentence_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 |
3 | ///推荐诗歌Model
4 | class PoemSentenceModel {
5 | String? cacheAt;
6 | String? content;
7 | String? id;
8 | List? matchTags;
9 | Origin? origin;
10 | int? popularity;
11 | String? recommendedReason;
12 |
13 | PoemSentenceModel(
14 | {this.cacheAt,
15 | this.content,
16 | this.id,
17 | this.matchTags,
18 | this.origin,
19 | this.popularity,
20 | this.recommendedReason});
21 |
22 | factory PoemSentenceModel.fromJson(Map json) {
23 | return PoemSentenceModel(
24 | cacheAt: json['cacheAt'],
25 | content: json['content'],
26 | id: json['id'],
27 | matchTags: json['matchTags'] != null
28 | ? new List.from(json['matchTags'])
29 | : null,
30 | origin: json['origin'] != null ? Origin.fromJson(json['origin']) : null,
31 | popularity: json['popularity'],
32 | recommendedReason: json['recommendedReason'],
33 | );
34 | }
35 |
36 | Map toJson() {
37 | final Map data = new Map();
38 | data['cacheAt'] = this.cacheAt;
39 | data['content'] = this.content;
40 | data['id'] = this.id;
41 | data['popularity'] = this.popularity;
42 | data['recommendedReason'] = this.recommendedReason;
43 | if (this.matchTags != null) {
44 | data['matchTags'] = this.matchTags;
45 | }
46 | if (this.origin != null) {
47 | data['origin'] = this.origin!.toJson();
48 | }
49 | return data;
50 | }
51 |
52 | String getTooltip() {
53 | return origin != null ? origin!.getTooltip() : '';
54 | }
55 |
56 | String get contentStr => origin != null ? origin!.getContentStr() : '';
57 |
58 | String get dynastyAuthor => origin != null ? origin!.dynastyAuthor : '';
59 |
60 | String get translate => origin != null ? origin!.getTranslateStr() : '';
61 |
62 | String get title => origin != null ? '${origin!.title}' : '';
63 | }
64 |
65 | class Origin {
66 | String? author;
67 | List? content;
68 | String? dynasty;
69 | String? title;
70 | List? translate;
71 |
72 | Origin({this.author, this.content, this.dynasty, this.title, this.translate});
73 |
74 | factory Origin.fromJson(Map json) {
75 | return Origin(
76 | author: json['author'],
77 | content: json['content'] != null
78 | ? new List.from(json['content'])
79 | : null,
80 | dynasty: json['dynasty'],
81 | title: json['title'],
82 | translate: json['translate'] != null
83 | ? new List.from(json['translate'])
84 | : null,
85 | );
86 | }
87 |
88 | Map toJson() {
89 | final Map data = new Map();
90 | data['author'] = this.author;
91 | data['dynasty'] = this.dynasty;
92 | data['title'] = this.title;
93 | if (this.content != null) {
94 | data['content'] = this.content;
95 | }
96 | if (this.translate != null) {
97 | data['translate'] = this.translate;
98 | }
99 | return data;
100 | }
101 |
102 | ///
103 | String getTooltip() {
104 | String result = '';
105 | if (!TextUtil.isEmpty(title)) {
106 | result += title!;
107 | }
108 | if (!TextUtil.isEmpty(author)) {
109 | result += !TextUtil.isEmpty(result) ? '\n$dynastyAuthor' : dynastyAuthor;
110 | }
111 | result = getContentStr(result: result);
112 | if (translate != null && translate!.isNotEmpty) {
113 | result += '\n译文:';
114 | translate!.forEach((element) {
115 | result += !TextUtil.isEmpty(result) ? '\n$element' : element;
116 | });
117 | }
118 | return result;
119 | }
120 |
121 | ///朝代+作者
122 | String get dynastyAuthor => TextUtil.isEmpty(author)
123 | ? ''
124 | : TextUtil.isEmpty(dynasty)
125 | ? author!
126 | : '$dynasty•$author';
127 |
128 | ///诗歌全文
129 | String getContentStr({String result = ''}) {
130 | if (content != null && content!.isNotEmpty) {
131 | content!.forEach((element) {
132 | result += !TextUtil.isEmpty(result) ? '\n$element' : element;
133 | });
134 | }
135 | return result;
136 | }
137 |
138 | ///译文
139 | String getTranslateStr({String result = ''}) {
140 | if (translate != null && translate!.isNotEmpty) {
141 | result += !TextUtil.isEmpty(result) ? '译文:' : '译文:';
142 | translate!.forEach((element) {
143 | result += '\n$element';
144 | });
145 | }
146 | return result;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/lib/model/share_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 | import 'package:flutter_readhub/enum/share_type.dart';
3 |
4 | ///分享实体
5 | class ShareModel {
6 | ShareType type;
7 | String text;
8 | String? image;
9 | final IconData? icon;
10 |
11 | ShareModel(this.type, this.text, this.image, {this.icon});
12 | }
13 |
14 | ///卡片分享实体
15 | class CardShareModel {
16 | final String? title;
17 | final String? text;
18 | final String? summary;
19 | final String url;
20 | final String? fileName;
21 | final String? notice;
22 | final String? bottomNotice;
23 | final GlobalKey? globalKey;
24 | final Widget? summaryWidget;
25 | final bool showLogo;
26 |
27 | ///应用内展示url-与外部分享url区分
28 | final String? showUrl;
29 |
30 | CardShareModel({
31 | this.title,
32 | this.summary,
33 | this.text,
34 | required this.url,
35 | this.fileName,
36 | this.notice,
37 | this.bottomNotice,
38 | this.globalKey,
39 | this.summaryWidget,
40 | this.showUrl,
41 | this.showLogo = false,
42 | });
43 | }
44 |
--------------------------------------------------------------------------------
/lib/model/tab_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 |
3 | ///tab实体
4 | class TabModel {
5 | late String label;
6 | late String url;
7 | IconData? icon;
8 |
9 | TabModel(this.label, this.url, {this.icon});
10 | }
11 |
--------------------------------------------------------------------------------
/lib/observer/app_router_observer.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flustars/flustars.dart';
3 | import 'package:flutter/widgets.dart';
4 |
5 | ///应用路由监听
6 | class AppRouteObserver> extends RouteObserver {
7 | String _tag = 'AppRouteObserver';
8 |
9 | @override
10 | void didPush(Route route, Route? previousRoute) {
11 | super.didPush(route, previousRoute);
12 | LogUtil.v(
13 | 'didPush route: $route,previousRoute:$previousRoute,context:${route.navigator?.context}',
14 | tag: _tag);
15 |
16 | ///底部弹框不知为何会影响底部导航栏颜色
17 | // if (PlatformUtil.isAndroid) {
18 | // LogUtil.v('push底部弹框', tag: _tag);
19 | // Future.delayed(Duration(milliseconds: 500),
20 | // () => ThemeViewModel.setSystemBarTheme());
21 | // }
22 | }
23 |
24 | @override
25 | void didPop(Route route, Route? previousRoute) {
26 | super.didPop(route, previousRoute);
27 | LogUtil.v('didPop route: $route,previousRoute:$previousRoute', tag: _tag);
28 | if (route is PageRoute) {
29 | FocusManager.instance.primaryFocus?.unfocus();
30 | }
31 |
32 | ///有从底部到顶部的Route会出现修改导航栏颜色问题-猜测是动画引起的
33 | // if (PlatformUtil.isAndroid) {
34 | // LogUtil.v('pop底部弹框', tag: _tag);
35 | // Future.delayed(Duration(milliseconds: 320),
36 | // () => ThemeViewModel.setSystemBarTheme());
37 | // }
38 | }
39 |
40 | @override
41 | void didReplace({Route? newRoute, Route? oldRoute}) {
42 | super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
43 | LogUtil.v('didReplace newRoute: $newRoute,oldRoute:$oldRoute', tag: _tag);
44 | }
45 |
46 | @override
47 | void didRemove(Route route, Route? previousRoute) {
48 | super.didRemove(route, previousRoute);
49 | LogUtil.v('didRemove route: $route,previousRoute:$previousRoute',
50 | tag: _tag);
51 | }
52 |
53 | @override
54 | void didStartUserGesture(Route route, Route? previousRoute) {
55 | super.didStartUserGesture(route, previousRoute);
56 | LogUtil.v('didStartUserGesture route: $route,previousRoute:$previousRoute',
57 | tag: _tag);
58 | }
59 |
60 | @override
61 | void didStopUserGesture() {
62 | super.didStopUserGesture();
63 | LogUtil.v('didStopUserGesture', tag: _tag);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/lib/res/assets_res.dart:
--------------------------------------------------------------------------------
1 | /// Generated file. Do not edit.
2 |
3 | // ignore_for_file: constant_identifier_names
4 | // ignore_for_file: lines_longer_than_80_chars
5 | class AssetsRes {
6 | static const String PLUGIN_NAME = 'flutter_readhub';
7 | static const String PLUGIN_VERSION = '1.4.0+1400';
8 | }
9 |
--------------------------------------------------------------------------------
/lib/res/i_font_res.dart:
--------------------------------------------------------------------------------
1 | /// Generated file. Do not edit.
2 |
3 | // ignore_for_file: constant_identifier_names
4 | // ignore_for_file: lines_longer_than_80_chars
5 | class FontRes {
6 | static const String ICONFONT = 'iconfont';
7 | }
8 |
--------------------------------------------------------------------------------
/lib/util/adaptive.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Flutter team. All rights reserved.
2 | // Use of this source code is governed by a BSD-style license that can be
3 | // found in the LICENSE file.
4 |
5 | import 'package:adaptive_breakpoints/adaptive_breakpoints.dart';
6 | import 'package:flutter_readhub/main.dart';
7 | import 'package:flutter_readhub/util/platform_util.dart';
8 |
9 | ///获取屏幕尺寸类型
10 | AdaptiveWindowType get windowType =>
11 | getWindowType(navigatorKey.currentContext!);
12 |
13 | ///大屏幕-宽度大于1024-
14 | bool get isDisplayDesktop => PlatformUtil.isMobile
15 | ? windowType >= AdaptiveWindowType.medium
16 | : windowType >= AdaptiveWindowType.small;
17 |
18 | ///中屏幕-宽度600-1023
19 | bool get isDisplaySmallDesktop => PlatformUtil.isMobile
20 | ? windowType == AdaptiveWindowType.medium
21 | : windowType == AdaptiveWindowType.small;
22 |
23 | ///小屏幕--按手机处理宽度小于600
24 | bool get smallDisplay => windowType == AdaptiveWindowType.xsmall;
25 |
--------------------------------------------------------------------------------
/lib/util/platform_util.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:device_info_plus/device_info_plus.dart';
5 | import 'package:flutter/foundation.dart';
6 | import 'package:package_info_plus/package_info_plus.dart';
7 |
8 | export 'dart:io';
9 |
10 | /// 是否是生产环境
11 | const bool inProduction = const bool.fromEnvironment("dart.vm.product");
12 |
13 | class PlatformUtil {
14 | // static Future getAppPackageInfo() {
15 | // return PackageInfo.fromPlatform();
16 | // }
17 |
18 | static Future getAppVersion() async {
19 | PackageInfo packageInfo = await PackageInfo.fromPlatform();
20 | return packageInfo.version;
21 | }
22 |
23 | static Future getBuildNumber() async {
24 | PackageInfo packageInfo = await PackageInfo.fromPlatform();
25 | return packageInfo.buildNumber;
26 | }
27 |
28 | // static Future getPackageName() async {
29 | // PackageInfo packageInfo = await PackageInfo.fromPlatform();
30 | // return packageInfo.packageName;
31 | // }
32 |
33 | // static Future getDeviceInfo() async {
34 | // DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
35 | // if (PlatformUtil.isAndroid) {
36 | // return await deviceInfo.androidInfo;
37 | // } else if (Platform.isIOS) {
38 | // return await deviceInfo.iosInfo;
39 | // } else {
40 | // return null;
41 | // }
42 | // }
43 |
44 | ///Android 6.0及以上-状态栏icon颜色
45 | static Future isStatusColorChange() async {
46 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
47 | if (PlatformUtil.isAndroid) {
48 | AndroidDeviceInfo info = await deviceInfo.androidInfo;
49 | return info.version.sdkInt >= 23;
50 | } else {
51 | return true;
52 | }
53 | }
54 |
55 | ///Android 8.0及以上-底部导航栏icon颜色
56 | static Future isNavigationColorChange() async {
57 | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
58 | if (PlatformUtil.isAndroid) {
59 | AndroidDeviceInfo info = await deviceInfo.androidInfo;
60 | return info.version.sdkInt >= 26;
61 | } else {
62 | return true;
63 | }
64 | }
65 |
66 | ///判断当前是否为web系统
67 | static bool get isWeb => kIsWeb;
68 |
69 | ///是否Linux系统
70 | static bool get isLinux => !isWeb && Platform.isLinux;
71 |
72 | ///是否Mac系统
73 | static bool get isMacOS => !isWeb && Platform.isMacOS;
74 |
75 | ///是否Windows系统
76 | static bool get isWindows => !isWeb && Platform.isWindows;
77 |
78 | ///是否Android系统
79 | static bool get isAndroid => !isWeb && Platform.isAndroid;
80 |
81 | ///是否iOS系统
82 | static bool get isIOS => !isWeb && Platform.isIOS;
83 |
84 | ///是否Fuchsia系统
85 | static bool get isFuchsia => !isWeb && Platform.isFuchsia;
86 |
87 | ///是否手机系统
88 | static bool get isMobile => isAndroid || isIOS;
89 |
90 | ///是否桌面系统
91 | static bool get isDesktop => isLinux || isMacOS || isWindows;
92 | }
93 |
--------------------------------------------------------------------------------
/lib/util/resource_util.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class IconFonts {
4 | IconFonts._();
5 |
6 | static const String fontFamily = 'iconfont';
7 |
8 | static const IconData ic_link = IconData(0xe612, fontFamily: fontFamily);
9 | static const IconData ic_glass = IconData(0xe89a, fontFamily: fontFamily);
10 | }
11 |
12 | ///装饰器工具类
13 | class Decorations {
14 | ///添加边缘线
15 | static BoxBorder lineBoxBorder(
16 | BuildContext context, {
17 | double? width,
18 | Color? color,
19 | bool left = false,
20 | bool top = false,
21 | bool right = false,
22 | bool bottom = false,
23 | }) {
24 | BorderSide side = BorderSide(
25 | width: 0.4,
26 | color: Theme.of(context).hintColor.withOpacity(0.2),
27 | style: BorderStyle.solid,
28 | );
29 | return Border(
30 | left: left ? side : BorderSide.none,
31 | top: top ? side : BorderSide.none,
32 | right: right ? side : BorderSide.none,
33 | bottom: bottom ? side : BorderSide.none,
34 | );
35 | }
36 |
37 | ///添加边缘线
38 | static ShapeBorder lineShapeBorder(
39 | BuildContext context, {
40 | Color? color,
41 | double? lineWidth,
42 | BorderRadiusGeometry borderRadius = BorderRadius.zero,
43 | }) {
44 | return BeveledRectangleBorder(
45 | borderRadius: borderRadius,
46 | side: BorderSide(
47 | width: lineWidth ?? 0.2,
48 | color: color ?? Theme.of(context).hintColor.withOpacity(0.075),
49 | style: BorderStyle.solid,
50 | ),
51 | );
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/lib/util/toast_util.dart:
--------------------------------------------------------------------------------
1 | import 'package:bot_toast/bot_toast.dart';
2 | import 'package:flustars/flustars.dart';
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_readhub/main.dart';
5 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
6 |
7 | ///Toast工具类---初步使用BotToast
8 | class ToastUtil {
9 | ///展示提示
10 | static CancelFunc show(
11 | String text, {
12 | AlignmentGeometry? align,
13 | Duration? duration,
14 | Color? backgroundColor,
15 | Color? textColor,
16 | int? milliseconds,
17 |
18 | ///是否通知形式
19 | bool notification = true,
20 | BorderRadiusGeometry borderRadius = const BorderRadius.all(
21 | Radius.circular(6),
22 | ),
23 | }) {
24 | align ??= Alignment.center;
25 | duration ??= Duration(
26 | milliseconds: milliseconds != null
27 | ? milliseconds
28 | : !TextUtil.isEmpty(text) && text.length > 10
29 | ? 5000
30 | : 2500,
31 | );
32 | LogUtil.v(
33 | 'text:$text'
34 | ';textScaleFactor:${MediaQuery.of((navigatorKey.currentContext)!).textScaleFactor}',
35 | tag: 'showToast');
36 | bool isDark = ThemeViewModel.darkMode;
37 | return notification
38 | ? BotToast.showSimpleNotification(
39 | title: '$text',
40 | titleStyle: Theme.of(navigatorKey.currentContext!)
41 | .textTheme
42 | .titleMedium
43 | ?.copyWith(
44 | fontSize: 16,
45 | color: textColor ?? (isDark ? Colors.black : Colors.white),
46 | ),
47 | hideCloseButton: true,
48 | animationDuration: Duration(milliseconds: 800),
49 | // backgroundColor: backgroundColor ?? Color(0xA0000000),
50 | backgroundColor: backgroundColor ??
51 | (isDark ? Colors.white : Colors.black).withOpacity(0.75),
52 | borderRadius: 6,
53 | duration: duration,
54 |
55 | ///只显示一个
56 | onlyOne: true,
57 | crossPage: true,
58 | )
59 | : BotToast.showText(
60 | text: '$text',
61 | textStyle: TextStyle(
62 | fontSize: 16,
63 | color: Colors.white,
64 | ),
65 | align: align,
66 | backgroundColor: Colors.transparent,
67 | contentColor: backgroundColor ?? Color(0xA0000000),
68 | borderRadius: borderRadius,
69 | contentPadding: EdgeInsets.symmetric(
70 | vertical: 8,
71 | horizontal: 10,
72 | ),
73 | duration: duration,
74 |
75 | ///只显示一个
76 | onlyOne: true,
77 | crossPage: true,
78 | );
79 | }
80 |
81 | ///成功
82 | static CancelFunc showSuccess(
83 | String text, {
84 | AlignmentGeometry? align,
85 | Duration? duration,
86 | Color? textColor,
87 |
88 | ///是否通知形式
89 | bool notification = true,
90 | BorderRadiusGeometry borderRadius = const BorderRadius.all(
91 | Radius.circular(6),
92 | ),
93 | }) {
94 | return show(
95 | text,
96 | align: align,
97 | duration: duration,
98 | backgroundColor: Colors.green.withOpacity(0.7),
99 | textColor: textColor,
100 | notification: notification,
101 | borderRadius: borderRadius,
102 | );
103 | }
104 |
105 | ///错误
106 | static CancelFunc showError(
107 | String text, {
108 | AlignmentGeometry? align,
109 | Duration? duration,
110 | Color? textColor,
111 |
112 | ///是否通知形式
113 | bool notification = true,
114 | BorderRadiusGeometry borderRadius = const BorderRadius.all(
115 | Radius.circular(6),
116 | ),
117 | }) {
118 | return show(
119 | text,
120 | align: align,
121 | duration: duration,
122 | backgroundColor: Colors.red.withOpacity(0.7),
123 | textColor: textColor,
124 | notification: notification,
125 | borderRadius: borderRadius,
126 | );
127 | }
128 |
129 | ///提醒
130 | static CancelFunc showWarning(
131 | String text, {
132 | AlignmentGeometry? align,
133 | Duration? duration,
134 | Color? textColor,
135 |
136 | ///是否通知形式
137 | bool notification = true,
138 | BorderRadiusGeometry borderRadius = const BorderRadius.all(
139 | Radius.circular(6),
140 | ),
141 | }) {
142 | return show(
143 | text,
144 | align: align,
145 | duration: duration,
146 | backgroundColor: Colors.amber.withOpacity(0.7),
147 | textColor: textColor,
148 | notification: true,
149 | borderRadius: borderRadius,
150 | );
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/lib/view_model/article_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_readhub/basis/basis_refresh_list_view_model.dart';
4 | import 'package:flutter_readhub/data/article_http.dart';
5 | import 'package:flutter_readhub/data/article_repository.dart';
6 | import 'package:flutter_readhub/model/article_model.dart';
7 | import 'package:flutter_readhub/util/toast_util.dart';
8 |
9 | ///获取资讯列表Model
10 | class ArticleViewModel extends BasisRefreshListViewModel {
11 | String? lastCursor;
12 | String url;
13 |
14 | ArticleViewModel(this.url);
15 |
16 | ///预刷新--该方式非100%准确,只适用于一段时间(这段时间最多更新20条新资讯)
17 | preRefresh() async {
18 | ArticleModel model = await ArticleRepository.getArticleList(
19 | url,
20 | pageSize: pageSize,
21 | );
22 | if (model.data != null && model.data!.isNotEmpty) {
23 | List listData = model.data!.toList();
24 |
25 | ///移除已经存在的
26 | model.data!.removeWhere(
27 | (element) => list.any((itemList) => itemList.id == element.id));
28 |
29 | ///有新的资讯
30 | if (model.data!.isNotEmpty) {
31 | ///移除当前list与返回重复资讯
32 | list.removeWhere(
33 | (element) => listData.any((itemData) => itemData.id == element.id));
34 |
35 | ///将新获取资讯添加到list顶部
36 | listData.addAll(list);
37 | list = listData;
38 |
39 | ToastUtil.show(
40 | '发现${model.data!.length}条新${getLabel()}',
41 | backgroundColor: Colors.green.withOpacity(0.9),
42 | textColor: Colors.white,
43 | notification: true,
44 | borderRadius: const BorderRadius.all(Radius.circular(100)),
45 | );
46 | }
47 | ///至少刷新新闻发布时间间隔
48 | setSuccess();
49 | LogUtil.v('length:${model.data!.length};listLength:${list.length}'
50 | ';listData_length:${listData.length}');
51 | }
52 | }
53 |
54 | String getLabel() {
55 | String result = '讯息';
56 | switch (url) {
57 |
58 | ///热门话题
59 | case ArticleHttp.API_TOPIC:
60 | result = '话题';
61 | break;
62 |
63 | ///科技动态
64 | case ArticleHttp.API_NEWS:
65 | result = '动态';
66 | break;
67 |
68 | ///技术资讯
69 | case ArticleHttp.API_TECH_NEWS:
70 | result = '资讯';
71 | break;
72 | }
73 | return result;
74 | }
75 |
76 | @override
77 | Future?> loadData({int? pageNum}) async {
78 | ///第一页将游标重置
79 | lastCursor = pageNum == 0 ? null : lastCursor;
80 | ArticleModel model = await ArticleRepository.getArticleList(
81 | url,
82 | lastCursor: lastCursor,
83 | pageSize: pageSize,
84 | );
85 | lastCursor = model.getLastCursor();
86 |
87 | LogUtil.v('lastCursor:$lastCursor');
88 | return model.data;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/lib/view_model/locale_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter/material.dart';
3 |
4 | ///国际化语言切换-刚开始做了语言切换后面废弃
5 | class LocaleViewModel extends ChangeNotifier {
6 | static const localeValueList = ['', 'zh-CN', 'en'];
7 |
8 | static const SP_KEY_LOCALE_INDEX = 'SP_KEY_LOCALE_INDEX';
9 |
10 | int? _localeIndex;
11 |
12 | int? get localeIndex => _localeIndex;
13 |
14 | Locale? get locale {
15 | if (_localeIndex! > 0) {
16 | var value = localeValueList[_localeIndex!].split("-");
17 | return Locale(value[0], value.length == 2 ? value[1] : '');
18 | }
19 | // 跟随系统
20 | return null;
21 | }
22 |
23 | LocaleViewModel() {
24 | _localeIndex = SpUtil.getInt(SP_KEY_LOCALE_INDEX);
25 | switchLocale(_localeIndex);
26 | }
27 |
28 | switchLocale(int? index) {
29 | _localeIndex = index;
30 | SpUtil.putInt(SP_KEY_LOCALE_INDEX, _localeIndex!);
31 | notifyListeners();
32 | }
33 |
34 | String localeName(index, context) {
35 | switch (index) {
36 | case 0:
37 | // return StringHelper.getS().autoBySystem;
38 | case 1:
39 | // return StringHelper.getS().chinese;
40 | case 2:
41 | // return StringHelper.getS().english;
42 | default:
43 | return '';
44 | }
45 | }
46 |
47 | String localeCurrentName(context) {
48 | return localeName(localeIndex, context);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/view_model/poem_sentence_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter_readhub/basis/basis_view_model.dart';
3 | import 'package:flutter_readhub/data/poem_repository.dart';
4 | import 'package:flutter_readhub/helper/sp_helper.dart';
5 | import 'package:flutter_readhub/model/poem_sentence_model.dart';
6 | import 'package:flutter_readhub/page/home_page.dart';
7 |
8 | ///推荐诗歌ViewModel
9 | class PoemSentenceViewModel extends BasisViewModel {
10 | PoemSentenceModel? poemSentenceModel = SpHelper.getPoemSentenceModel();
11 |
12 | initData() async {
13 | await refresh(init: true);
14 | }
15 |
16 | refresh({bool init = false}) async {
17 | setLoading();
18 | try {
19 | poemSentenceModel = await loadData();
20 | setSuccess();
21 |
22 | ///刷新顶部
23 | topViewModel?.poemSentenceModel = poemSentenceModel;
24 | } catch (e, s) {
25 | setError(e, s);
26 |
27 | ///初始化失败延迟再获取
28 | if (init) {
29 | Future.delayed(Duration(seconds: 5), () => refresh(init: true));
30 | }
31 | LogUtil.e('e:$e;s:$s', tag: 'PoemSentenceViewModel');
32 | }
33 | }
34 |
35 | ///加载数据
36 | Future loadData() async {
37 | PoemSentenceModel model = await PoemRepository.getPoemSentence();
38 | SpHelper.setPoemSentenceModel(model);
39 | return model;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/view_model/update_view_model.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_readhub/basis/basis_view_model.dart';
3 | import 'package:flutter_readhub/data/update_repository.dart';
4 | import 'package:flutter_readhub/main.dart';
5 | import 'package:flutter_readhub/model/app_update_model.dart';
6 | import 'package:flutter_readhub/util/dialog_util.dart';
7 | import 'package:flutter_readhub/util/platform_util.dart';
8 | import 'package:flutter_readhub/util/toast_util.dart';
9 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
10 | import 'package:url_launcher/url_launcher_string.dart';
11 |
12 | ///检查更新
13 | class UpdateViewModel extends BasisViewModel {
14 | static String? _appVersion;
15 |
16 | static String? get appVersion => _appVersion != null ? _appVersion : "";
17 |
18 | static String? _appVersionCode;
19 |
20 | static String? get appVersionCode =>
21 | _appVersionCode != null ? _appVersionCode : '-1';
22 |
23 | ///检查新版本
24 | Future checkUpdate(BuildContext context,
25 | {bool showError = false}) async {
26 | AppUpdateModel? appModel;
27 | setLoading();
28 | try {
29 | appModel = await UpdateRepository.checkUpdate();
30 | showUpdateDialog(context, appModel, background: !showError);
31 | setSuccess();
32 | } catch (e, s) {
33 | setError(e, s);
34 | if (showError) {
35 | ToastUtil.show('检查失败,请稍后重试!$e',
36 | duration: Duration(
37 | seconds: 6,
38 | ));
39 | }
40 | }
41 | return appModel;
42 | }
43 |
44 | UpdateViewModel() {
45 | PlatformUtil.getAppVersion().then((str) {
46 | _appVersion = str;
47 | setSuccess();
48 | });
49 | PlatformUtil.getBuildNumber().then((num) {
50 | _appVersionCode = num;
51 | setSuccess();
52 | });
53 | }
54 |
55 | ///弹出升级新版本Dialog
56 | Future showUpdateDialog(BuildContext context, AppUpdateModel? info,
57 | {bool background = true}) async {
58 | if (info == null || !info.buildHaveNewVersion!) {
59 | if (!background) {
60 | ToastUtil.show(appString.currentIsNew);
61 | }
62 | return;
63 | }
64 | DialogUtil.showAlertDialog(
65 | context,
66 | titleWidget: RichText(
67 | textScaleFactor: ThemeViewModel.textScaleFactor,
68 | text: TextSpan(
69 | style: Theme.of(context).textTheme.titleMedium,
70 | text: '发现新版本:${info.buildVersion}',
71 | children: [
72 | TextSpan(
73 | text: '\n系统自带浏览器打开',
74 | style: Theme.of(context).textTheme.titleMedium?.copyWith(
75 | color: Theme.of(context).primaryColor,
76 | fontSize: 13,
77 | ))
78 | ]),
79 | ),
80 | content: info.buildUpdateDescription,
81 | cancel: appString.updateNextTime,
82 | ensure: appString.updateNow,
83 | ).then((index) {
84 | if (index == 1) {
85 | launchUrlString(info.downloadURL!);
86 | }
87 | });
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/lib/widget/animated_switcher_icon_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flustars/flustars.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_readhub/util/platform_util.dart';
4 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
5 |
6 | ///添加切换动画IconButton
7 | class AnimatedSwitcherIconWidget extends StatefulWidget {
8 | final IconData? defaultIcon;
9 | final IconData? switchIcon;
10 | final String? tooltip;
11 | final VoidCallback? onPressed;
12 | final Duration duration;
13 | final bool checkTheme;
14 |
15 | const AnimatedSwitcherIconWidget({
16 | Key? key,
17 | this.defaultIcon,
18 | this.switchIcon,
19 | this.tooltip,
20 | this.onPressed,
21 | this.duration = const Duration(milliseconds: 500),
22 | this.checkTheme = false,
23 | }) : super(key: key);
24 |
25 | @override
26 | _AnimatedSwitcherIconWidgetState createState() =>
27 | _AnimatedSwitcherIconWidgetState();
28 | }
29 |
30 | class _AnimatedSwitcherIconWidgetState
31 | extends State {
32 | IconData? _actionIcon;
33 |
34 | _AnimatedSwitcherIconWidgetState();
35 |
36 | @override
37 | void initState() {
38 | super.initState();
39 | _actionIcon = widget.defaultIcon;
40 | }
41 |
42 | DateTime? _lastSetSystemUiAt;
43 |
44 | @override
45 | void didUpdateWidget(AnimatedSwitcherIconWidget oldWidget) {
46 | super.didUpdateWidget(oldWidget);
47 | if (!widget.checkTheme || !PlatformUtil.isAndroid) {
48 | return;
49 | }
50 |
51 | ///更新UI--Android系统
52 | ///在深色暗色模式切换时候也会触发因ThemeData无NavigationBar相关主题配置故采用该方法迂回处理
53 | if (_lastSetSystemUiAt == null ||
54 | DateTime.now().difference(_lastSetSystemUiAt!) >
55 | Duration(milliseconds: 1000)) {
56 | ///两次点击间隔超过阈值则重新计时
57 | _lastSetSystemUiAt = DateTime.now();
58 | LogUtil.v('设置系统栏颜色');
59 | ThemeViewModel.setSystemBarTheme();
60 | }
61 | }
62 |
63 | @override
64 | Widget build(BuildContext context) {
65 | return AnimatedSwitcher(
66 | transitionBuilder: (child, anim) {
67 | return ScaleTransition(child: child, scale: anim);
68 | },
69 | duration: widget.duration,
70 | child: IconButton(
71 | autofocus: true,
72 | tooltip: widget.tooltip,
73 | key: ValueKey(_actionIcon =
74 | ThemeViewModel.darkMode ? widget.switchIcon : widget.defaultIcon),
75 | icon: Icon(_actionIcon),
76 | hoverColor: Colors.transparent,
77 | splashColor: Colors.transparent,
78 | onPressed: widget.onPressed,
79 | ),
80 | );
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/lib/widget/highlight_card_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_readhub/basis/basis_highlight_view_model.dart';
3 | import 'package:flutter_readhub/basis/basis_provider_widget.dart';
4 | import 'package:flutter_readhub/util/platform_util.dart';
5 | import 'package:flutter_readhub/util/resource_util.dart';
6 |
7 | ///长按/悬浮效果Card-包括景深度、margin变化
8 | class HighlightCardWidget extends StatelessWidget {
9 | final GestureTapCallback? onTap;
10 | final GestureLongPressCallback? onLongPress;
11 |
12 | final double? margin;
13 | final double? marginHighlight;
14 | final double? elevation;
15 | final double? elevationHighlight;
16 | final Color? color;
17 | final Color? shadowColor;
18 | final Color? shadowHighlightColor;
19 | final BorderRadiusGeometry? borderRadius;
20 | final bool showBorder;
21 | final Widget Function(BuildContext context, BasisHighlightViewModel value)
22 | builder;
23 |
24 | const HighlightCardWidget({
25 | Key? key,
26 | this.onTap,
27 | this.onLongPress,
28 | this.margin,
29 | this.marginHighlight,
30 | this.elevation,
31 | this.elevationHighlight,
32 | this.color,
33 | this.shadowColor,
34 | this.shadowHighlightColor,
35 | this.borderRadius,
36 | this.showBorder = false,
37 | required this.builder,
38 | }) : super(key: key);
39 |
40 | @override
41 | Widget build(BuildContext context) {
42 | return BasisProviderWidget(
43 | model: BasisHighlightViewModel(),
44 | builder: (context, highlightMode, widget) => Card(
45 | margin: PlatformUtil.isMobile && !showBorder
46 | ? null
47 | : EdgeInsets.all(
48 | highlightMode.highlight ? marginHighlight ?? 10 : margin ?? 10,
49 | ),
50 | elevation: highlightMode.highlight ? 0 : 0,
51 | color: Colors.transparent,
52 | borderOnForeground: false,
53 | shadowColor: highlightMode.highlight
54 | ? shadowHighlightColor ?? Colors.deepPurpleAccent
55 | : shadowColor ?? Theme.of(context).primaryColor,
56 | clipBehavior: Clip.antiAliasWithSaveLayer,
57 | shape: PlatformUtil.isMobile && !showBorder
58 | ? null
59 | : Decorations.lineShapeBorder(
60 | context,
61 | lineWidth: highlightMode.highlight ? 1.6 : 0.8,
62 | borderRadius: BorderRadius.circular(12),
63 | color: highlightMode.highlight
64 | ? Theme.of(context).primaryColor
65 | : Theme.of(context).hintColor.withOpacity(0.1),
66 | ),
67 | child: InkWell(
68 | canRequestFocus: true,
69 | autofocus: true,
70 | onHighlightChanged: highlightMode.onHighlightChanged,
71 | onHover: highlightMode.onHighlightChanged,
72 | // highlightColor: PlatformUtil.isMobile ? null : Colors.transparent,
73 | // splashColor: PlatformUtil.isMobile ? null : Colors.transparent,
74 | // hoverColor: PlatformUtil.isMobile ? null : Colors.transparent,
75 | onTap: () {
76 | onTap?.call();
77 | highlightMode.onHighlightChanged.call(!PlatformUtil.isMobile);
78 | },
79 | onLongPress: () {
80 | onLongPress?.call();
81 | highlightMode.onHighlightChanged.call(!PlatformUtil.isMobile);
82 | },
83 | child: builder(context, highlightMode),
84 | ),
85 | ),
86 | );
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/lib/widget/keep_alive_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | ///KeepAliveWidget-可保存不被回收Widget
4 | class KeepAliveWidget extends StatefulWidget {
5 | final Widget child;
6 |
7 | const KeepAliveWidget({
8 | Key? key,
9 | required this.child,
10 | }) : super(key: key);
11 |
12 | @override
13 | _KeepAliveWidgetState createState() => _KeepAliveWidgetState();
14 | }
15 |
16 | class _KeepAliveWidgetState extends State
17 | with AutomaticKeepAliveClientMixin {
18 | @override
19 | Widget build(BuildContext context) {
20 | super.build(context);
21 | return widget.child;
22 | }
23 |
24 | @override
25 | bool get wantKeepAlive => true;
26 | }
27 |
--------------------------------------------------------------------------------
/lib/widget/qr_code.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:qr_flutter/qr_flutter.dart';
3 |
4 | ///二维码生成
5 | class QrCode extends StatelessWidget {
6 | final String data;
7 | final double? size;
8 | final ImageProvider? embeddedImage;
9 | final Size? embeddedImageSize;
10 |
11 | const QrCode({
12 | Key? key,
13 | required this.data,
14 | this.size,
15 | this.embeddedImage,
16 | this.embeddedImageSize,
17 | }) : super(key: key);
18 |
19 | @override
20 | Widget build(BuildContext context) {
21 | return QrImage(
22 | data: data,
23 | padding: EdgeInsets.all(1),
24 | version: QrVersions.auto,
25 | size: size,
26 | embeddedImage: embeddedImage,
27 | embeddedImageStyle: QrEmbeddedImageStyle(
28 | size: embeddedImageSize,
29 | ),
30 | foregroundColor: Theme.of(context).textTheme.titleLarge?.color,
31 | backgroundColor: Theme.of(context).cardColor,
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/widget/skeleton.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
3 | import 'package:shimmer/shimmer.dart';
4 |
5 | ///占位方块控件
6 | class SkeletonBox extends StatelessWidget {
7 | final double width;
8 | final double height;
9 | final bool isCircle;
10 | final BorderRadiusGeometry? borderRadius;
11 |
12 | final EdgeInsetsGeometry margin;
13 | final EdgeInsetsGeometry padding;
14 |
15 | SkeletonBox({
16 | required this.width,
17 | required this.height,
18 | this.isCircle = false,
19 | this.borderRadius,
20 | this.margin = const EdgeInsets.all(0),
21 | this.padding = const EdgeInsets.all(0),
22 | });
23 |
24 | @override
25 | Widget build(BuildContext context) {
26 | Divider.createBorderSide(context, width: 0.7);
27 | return Container(
28 | margin: margin,
29 | padding: padding,
30 | width: width,
31 | height: height,
32 | decoration: SkeletonDecoration(
33 | isCircle: isCircle,
34 | isDark: ThemeViewModel.darkMode,
35 | borderRadius: borderRadius,
36 | ),
37 | );
38 | }
39 | }
40 |
41 | /// 骨架屏元素 ->形状及颜色及圆角
42 | class SkeletonDecoration extends BoxDecoration {
43 | SkeletonDecoration({
44 | isCircle = false,
45 | isDark = false,
46 |
47 | ///圆角
48 | BorderRadiusGeometry? borderRadius,
49 | }) : super(
50 | color: !isDark ? Colors.grey[350] : Colors.grey[700],
51 | borderRadius: borderRadius ?? BorderRadius.circular(0),
52 | shape: isCircle ? BoxShape.circle : BoxShape.rectangle,
53 | );
54 | }
55 |
56 | /// 骨架屏ListView
57 | class SkeletonList extends StatelessWidget {
58 | final EdgeInsetsGeometry padding;
59 | final bool horizontal;
60 |
61 | ///模拟数量
62 | final int length;
63 |
64 | ///Item适配器
65 | final IndexedWidgetBuilder? builder;
66 |
67 | ///基础颜色
68 | final Color? baseColor;
69 |
70 | ///高亮颜色
71 | final Color? highlightColor;
72 | final Widget? child;
73 |
74 | SkeletonList({
75 | this.builder,
76 | this.length = 10,
77 | this.horizontal = false,
78 | this.baseColor,
79 | this.highlightColor,
80 | this.padding = const EdgeInsets.all(0),
81 | this.child,
82 | });
83 |
84 | @override
85 | Widget build(BuildContext context) {
86 | MaterialColor color = Colors.grey;
87 | return Shimmer.fromColors(
88 | period: Duration(milliseconds: 1000),
89 | baseColor:
90 | baseColor ?? (ThemeViewModel.darkMode ? color[700]! : color[350]!),
91 | highlightColor: highlightColor ??
92 | (ThemeViewModel.darkMode ? color[500]! : color[200]!),
93 | child: child ??
94 | ListView.builder(
95 | padding: padding,
96 | itemBuilder: builder!,
97 | itemCount: length,
98 | scrollDirection: horizontal ? Axis.horizontal : Axis.vertical,
99 | ),
100 | );
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lib/widget/tab_bar_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_readhub/view_model/theme_view_model.dart';
3 |
4 | ///TabBar效果
5 | class TabBarWidget extends StatelessWidget {
6 | const TabBarWidget({
7 | Key? key,
8 | required this.labels,
9 | this.controller,
10 | this.onTap,
11 | this.physics,
12 | }) : super(key: key);
13 | final List? labels;
14 | final ScrollPhysics? physics;
15 | final TabController? controller;
16 | final ValueChanged? onTap;
17 |
18 | @override
19 | Widget build(BuildContext context) {
20 | return TabBar(
21 | controller: controller,
22 | physics: physics,
23 | onTap: onTap,
24 | tabs: List.generate(
25 | labels!.length,
26 | (i) => Tab(
27 | child: Text(
28 | labels![i],
29 | softWrap: false,
30 | overflow: TextOverflow.fade,
31 | textScaleFactor: ThemeViewModel.textScaleFactor,
32 | ))),
33 |
34 | ///不自动滚动则均分屏幕宽度
35 | isScrollable: false,
36 |
37 | ///指示器高度
38 | indicatorWeight: 1.5,
39 |
40 | ///指示器颜色
41 | indicatorColor: Theme.of(context).primaryColor,
42 |
43 | ///指示器样式-根据label宽度
44 | indicatorSize: TabBarIndicatorSize.label,
45 |
46 | ///选中label颜色
47 | labelColor: Theme.of(context).textTheme.titleLarge?.color,
48 |
49 | enableFeedback: false,
50 |
51 | ///未选择label颜色
52 | unselectedLabelColor:
53 | Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6),
54 | );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/xcuserdata/
7 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = Freadhub-聚合资讯
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = cn.aries.freadhub
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2021 AriesHoo All rights reserved.
15 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 | com.apple.security.network.client
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | ///设置屏幕固定宽高
12 | // self.setContentSize(NSSize(width: 414,height: 736))
13 | // self.setContentSize(NSSize(width: 1024,height: 768))
14 | // self.setContentSize(NSSize(width: 800,height: 600))
15 | // let window: NSWindow! = self.contentView?.window
16 | ///去掉屏幕调整相关功能
17 | // window.styleMask.remove(.resizable)
18 |
19 | RegisterGeneratedPlugins(registry: flutterViewController)
20 |
21 | super.awakeFromNib()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 | com.apple.security.network.client
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/plugins/flutter_macos_webview/README.md:
--------------------------------------------------------------------------------
1 | # flutter_macos_webview
2 |
3 | Flutter plugin that lets you display native WebView on macOS
4 |
5 | For docs see [flutter_macos_webview.dart](https://github.com/vanelizarov/flutter_macos_webview/blob/master/lib/flutter_macos_webview.dart)
6 |
--------------------------------------------------------------------------------
/plugins/flutter_macos_webview/macos/flutter_macos_webview.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint flutter_macos_webview.podspec' to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'flutter_macos_webview'
7 | s.version = '0.0.4'
8 | s.summary = 'Flutter plugin that lets you display native WebView on macOS'
9 | s.description = <<-DESC
10 | Flutter plugin that lets you display native WebView on macOS
11 | DESC
12 | s.homepage = 'http://github.com/vanelizarov/flutter_macos_webview'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'vanelizarov' => 'elizarov.vanya@gmail.com' }
15 | s.source = { :path => '.' }
16 | s.source_files = 'Classes/**/*'
17 | s.dependency 'FlutterMacOS'
18 |
19 | s.platform = :osx, '10.6'
20 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
21 | s.swift_version = '5.0'
22 | end
23 |
--------------------------------------------------------------------------------
/plugins/flutter_macos_webview/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | characters:
5 | dependency: transitive
6 | description:
7 | name: characters
8 | url: "https://pub.flutter-io.cn"
9 | source: hosted
10 | version: "1.2.0"
11 | collection:
12 | dependency: transitive
13 | description:
14 | name: collection
15 | url: "https://pub.flutter-io.cn"
16 | source: hosted
17 | version: "1.15.0"
18 | flutter:
19 | dependency: "direct main"
20 | description: flutter
21 | source: sdk
22 | version: "0.0.0"
23 | meta:
24 | dependency: transitive
25 | description:
26 | name: meta
27 | url: "https://pub.flutter-io.cn"
28 | source: hosted
29 | version: "1.7.0"
30 | sky_engine:
31 | dependency: transitive
32 | description: flutter
33 | source: sdk
34 | version: "0.0.99"
35 | typed_data:
36 | dependency: transitive
37 | description:
38 | name: typed_data
39 | url: "https://pub.flutter-io.cn"
40 | source: hosted
41 | version: "1.3.0"
42 | vector_math:
43 | dependency: transitive
44 | description:
45 | name: vector_math
46 | url: "https://pub.flutter-io.cn"
47 | source: hosted
48 | version: "2.1.1"
49 | sdks:
50 | dart: ">=2.14.0 <3.0.0"
51 | flutter: ">=1.20.0"
52 |
--------------------------------------------------------------------------------
/plugins/flutter_macos_webview/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_macos_webview
2 | description: Flutter plugin that lets you display native WebView on macOS
3 | version: 0.0.4
4 | homepage: https://github.com/vanelizarov/flutter_macos_webview
5 |
6 | environment:
7 | sdk: ">=2.12.0 <3.0.0"
8 | flutter: ">=1.20.0"
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | flutter:
15 | plugin:
16 | platforms:
17 | macos:
18 | pluginClass: FlutterMacOSWebViewPlugin
19 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_readhub
2 | description: A new Flutter Readhub application.
3 |
4 | # The following defines the version and build number for your application.
5 | # A version number is three numbers separated by dots, like 1.2.43
6 | # followed by an optional build number separated by a +.
7 | # Both the version and the builder number may be overridden in flutter
8 | # build by specifying --build-name and --build-number, respectively.
9 | # In Android, build-name is used as versionName while build-number used as versionCode.
10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
12 | # Read more about iOS versioning at
13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14 | version: 1.4.0+1400
15 | publish_to: none
16 |
17 | environment:
18 | sdk: '>=2.15.0 <3.0.0'
19 |
20 | dependencies:
21 | flutter:
22 | sdk: flutter
23 | cupertino_icons: ^1.0.3
24 | # 国际化支持
25 | flutter_localizations:
26 | sdk: flutter
27 | # 状态管理State
28 | provider: ^6.0.1
29 | # 吐司toast
30 | bot_toast: ^4.0.1
31 | # 设备信息
32 | device_info_plus: ^8.2.0
33 | # 应用包信息
34 | package_info_plus: ^3.1.0
35 |
36 | # WebView-增加Web端插件
37 | webview_flutter: ^3.0.0
38 | webview_flutter_web: ^0.1.0
39 | # 网络请求相关dio
40 | dio: ^5.1.1
41 | # 加载网络图片
42 | cached_network_image: ^3.2.3
43 | synchronized: ^3.0.0
44 | # 下拉刷新
45 | pull_to_refresh: ^2.0.0
46 | # 本地缓存sp
47 | shared_preferences: ^2.0.6
48 | #用于做骨架屏-闪光效果
49 | shimmer: ^2.0.0
50 | #跳转系统浏览器/打电话等
51 | url_launcher: ^6.1.10
52 | #二维码-生成
53 | qr_flutter: ^4.0.0
54 | #工具类
55 | flustars: ^2.0.1
56 | #与flustars配合-版本要固定否则内部容易出现异常
57 | decimal: 1.5.0
58 | #动态权限申请-8.0.0版本需在Profile申请需要启用的权限
59 | #https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler/example/ios/Podfile
60 | permission_handler: ^10.2.0
61 | #文件路径
62 | path_provider: ^2.0.14
63 | #分享文字及文件-注意保存文件位置
64 | #注意0.1.2以后的版本分享图片微信提示获取资源失败,分享到其它平台正常
65 | # flutter_share_plugin: 0.1.2
66 | # share: ^2.0.1
67 | # 使用官网分支增加分享特定App/App某个方法 增加判断App是否安装方法-Android
68 | # 参考官网 https://flutter.dev/docs/development/packages-and-plugins/using-packages
69 | share:
70 | git:
71 | url: 'https://gitee.com/AriesHoo/plugins.git'
72 | path: packages/share
73 | ref: master
74 | # mac分享才有意义web及windows无意义shareFile方法都没有实现shareText也是调用的url_launcher
75 | share_plus: ^6.3.2
76 | # 自适应断点?---响应式
77 | adaptive_breakpoints: ^0.1.1
78 | # desktop窗口控制
79 | desktop_window: ^0.4.0
80 | # macos webView
81 | flutter_macos_webview:
82 | path: './plugins/flutter_macos_webview'
83 |
84 | # windows webView
85 | webview_windows: ^0.2.2
86 | # 生命周期
87 | lifecycle: ^0.6.0
88 | # 尺寸自适应Text
89 | auto_size_text: ^3.0.0
90 | dev_dependencies:
91 | flutter_lints: ^2.0.1
92 | flutter_test:
93 | sdk: flutter
94 |
95 |
96 | # For information on the generic Dart part of this file, see the
97 | # following page: https://dart.dev/tools/pub/pubspec
98 |
99 | # The following section is specific to Flutter.
100 | flutter:
101 |
102 | # The following line ensures that the Material Icons font is
103 | # included with your application, so that you can use the icons in
104 | # the material Icons class.
105 | uses-material-design: true
106 |
107 | fonts:
108 | - family: iconfont
109 | fonts:
110 | - asset: assets/fonts/iconfont.ttf
111 | assets:
112 | - assets/images/
113 | - assets/images/share/
114 | # To add assets to your application, add an assets section, like this:
115 | # assets:
116 | # - images/a_dot_burr.jpeg
117 | # - images/a_dot_ham.jpeg
118 |
119 | # An image asset can refer to one or more resolution-specific "variants", see
120 | # https://flutter.dev/assets-and-images/#resolution-aware.
121 |
122 | # For details regarding adding assets from package dependencies, see
123 | # https://flutter.dev/assets-and-images/#from-packages
124 |
125 | # To add custom fonts to your application, add a fonts section here,
126 | # in this "flutter" section. Each entry in this list should have a
127 | # "family" key with the font family name, and a "fonts" key with a
128 | # list giving the asset and other descriptors for the font. For
129 | # example:
130 | # fonts:
131 | # - family: Schyler
132 | # fonts:
133 | # - asset: fonts/Schyler-Regular.ttf
134 | # - asset: fonts/Schyler-Italic.ttf
135 | # style: italic
136 | # - family: Trajan Pro
137 | # fonts:
138 | # - asset: fonts/TrajanPro.ttf
139 | # - asset: fonts/TrajanPro_Bold.ttf
140 | # weight: 700
141 | #
142 | # For details regarding fonts from package dependencies,
143 | # see https://flutter.dev/custom-fonts/#from-packages
144 | flutter_intl:
145 | enabled: true
146 |
--------------------------------------------------------------------------------
/sample/Freadhub-聚合资讯.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/sample/Freadhub-聚合资讯.zip
--------------------------------------------------------------------------------
/sample/sample.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/sample/sample.apk
--------------------------------------------------------------------------------
/sample/sample.ipa:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/sample/sample.ipa
--------------------------------------------------------------------------------
/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_readhub/main.dart';
10 | import 'package:flutter_test/flutter_test.dart';
11 |
12 | void main() {
13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
14 | // Build our app and trigger a frame.
15 | await tester.pumpWidget(MaterialAppPage());
16 |
17 | // Verify that our counter starts at 0.
18 | expect(find.text('0'), findsOneWidget);
19 | expect(find.text('1'), findsNothing);
20 |
21 | // Tap the '+' icon and trigger a frame.
22 | await tester.tap(find.byIcon(Icons.add));
23 | await tester.pump();
24 |
25 | // Verify that our counter has incremented.
26 | expect(find.text('0'), findsNothing);
27 | expect(find.text('1'), findsOneWidget);
28 | });
29 | }
30 |
--------------------------------------------------------------------------------
/update/macos:
--------------------------------------------------------------------------------
1 | {
2 | "buildVersionNo":"1",
3 | "buildVersion":"1.3.0",
4 | "buildUpdateDescription":"初始版本",
5 | "downloadURL":"https://note.youdao.com/s/SnOimKqO",
6 | "needForceUpdate":true
7 | }
--------------------------------------------------------------------------------
/web/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/web/favicon.ico
--------------------------------------------------------------------------------
/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/web/favicon.png
--------------------------------------------------------------------------------
/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AriesHoo/flutter_readhub/064a4df94672fd562cdd3a4d3aad29d353641566/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Freadhub-聚合资讯
18 |
19 |
20 |
21 |
24 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Freadhub-聚合资讯",
3 | "short_name": "Freadhub-聚合资讯",
4 | "start_url": ".",
5 | "display": "minimal-ui",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter application.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(flutter_readhub LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "flutter_readhub")
5 |
6 | cmake_policy(SET CMP0063 NEW)
7 |
8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
9 |
10 | # Configure build options.
11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
12 | if(IS_MULTICONFIG)
13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
14 | CACHE STRING "" FORCE)
15 | else()
16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17 | set(CMAKE_BUILD_TYPE "Debug" CACHE
18 | STRING "Flutter build mode" FORCE)
19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
20 | "Debug" "Profile" "Release")
21 | endif()
22 | endif()
23 |
24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
28 |
29 | # Use Unicode for all projects.
30 | add_definitions(-DUNICODE -D_UNICODE)
31 |
32 | # Compilation settings that should be applied to most targets.
33 | function(APPLY_STANDARD_SETTINGS TARGET)
34 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
36 | target_compile_options(${TARGET} PRIVATE /EHsc)
37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
39 | endfunction()
40 |
41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
42 |
43 | # Flutter library and tool build rules.
44 | add_subdirectory(${FLUTTER_MANAGED_DIR})
45 |
46 | # Application build
47 | add_subdirectory("runner")
48 |
49 | # Generated plugin build rules, which manage building the plugins and adding
50 | # them to the application.
51 | include(flutter/generated_plugins.cmake)
52 |
53 |
54 | # === Installation ===
55 | # Support files are copied into place next to the executable, so that it can
56 | # run in place. This is done instead of making a separate bundle (as on Linux)
57 | # so that building and running from within Visual Studio will work.
58 | set(BUILD_BUNDLE_DIR "$")
59 | # Make the "install" step default, as it's required to run.
60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
63 | endif()
64 |
65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
67 |
68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
69 | COMPONENT Runtime)
70 |
71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
72 | COMPONENT Runtime)
73 |
74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
75 | COMPONENT Runtime)
76 |
77 | if(PLUGIN_BUNDLED_LIBRARIES)
78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
80 | COMPONENT Runtime)
81 | endif()
82 |
83 | # Fully re-copy the assets directory on each build to avoid having stale files
84 | # from a previous install.
85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
86 | install(CODE "
87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
88 | " COMPONENT Runtime)
89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
91 |
92 | # Install the AOT library on non-Debug builds only.
93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
94 | CONFIGURATIONS Profile;Release
95 | COMPONENT Runtime)
96 |
--------------------------------------------------------------------------------
/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
11 |
12 | # === Flutter Library ===
13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
14 |
15 | # Published to parent scope for install step.
16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
20 |
21 | list(APPEND FLUTTER_LIBRARY_HEADERS
22 | "flutter_export.h"
23 | "flutter_windows.h"
24 | "flutter_messenger.h"
25 | "flutter_plugin_registrar.h"
26 | "flutter_texture_registrar.h"
27 | )
28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
29 | add_library(flutter INTERFACE)
30 | target_include_directories(flutter INTERFACE
31 | "${EPHEMERAL_DIR}"
32 | )
33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
34 | add_dependencies(flutter flutter_assemble)
35 |
36 | # === Wrapper ===
37 | list(APPEND CPP_WRAPPER_SOURCES_CORE
38 | "core_implementations.cc"
39 | "standard_codec.cc"
40 | )
41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
43 | "plugin_registrar.cc"
44 | )
45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
46 | list(APPEND CPP_WRAPPER_SOURCES_APP
47 | "flutter_engine.cc"
48 | "flutter_view_controller.cc"
49 | )
50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
51 |
52 | # Wrapper sources needed for a plugin.
53 | add_library(flutter_wrapper_plugin STATIC
54 | ${CPP_WRAPPER_SOURCES_CORE}
55 | ${CPP_WRAPPER_SOURCES_PLUGIN}
56 | )
57 | apply_standard_settings(flutter_wrapper_plugin)
58 | set_target_properties(flutter_wrapper_plugin PROPERTIES
59 | POSITION_INDEPENDENT_CODE ON)
60 | set_target_properties(flutter_wrapper_plugin PROPERTIES
61 | CXX_VISIBILITY_PRESET hidden)
62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
63 | target_include_directories(flutter_wrapper_plugin PUBLIC
64 | "${WRAPPER_ROOT}/include"
65 | )
66 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
67 |
68 | # Wrapper sources needed for the runner.
69 | add_library(flutter_wrapper_app STATIC
70 | ${CPP_WRAPPER_SOURCES_CORE}
71 | ${CPP_WRAPPER_SOURCES_APP}
72 | )
73 | apply_standard_settings(flutter_wrapper_app)
74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
75 | target_include_directories(flutter_wrapper_app PUBLIC
76 | "${WRAPPER_ROOT}/include"
77 | )
78 | add_dependencies(flutter_wrapper_app flutter_assemble)
79 |
80 | # === Flutter tool backend ===
81 | # _phony_ is a non-existent file to force this command to run every time,
82 | # since currently there's no way to get a full input/output list from the
83 | # flutter tool.
84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
86 | add_custom_command(
87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
89 | ${CPP_WRAPPER_SOURCES_APP}
90 | ${PHONY_OUTPUT}
91 | COMMAND ${CMAKE_COMMAND} -E env
92 | ${FLUTTER_TOOL_ENVIRONMENT}
93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
94 | windows-x64 $
95 | VERBATIM
96 | )
97 | add_custom_target(flutter_assemble DEPENDS
98 | "${FLUTTER_LIBRARY}"
99 | ${FLUTTER_LIBRARY_HEADERS}
100 | ${CPP_WRAPPER_SOURCES_CORE}
101 | ${CPP_WRAPPER_SOURCES_PLUGIN}
102 | ${CPP_WRAPPER_SOURCES_APP}
103 | )
104 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | void RegisterPlugins(flutter::PluginRegistry* registry) {
16 | DesktopWindowPluginRegisterWithRegistrar(
17 | registry->GetRegistrarForPlugin("DesktopWindowPlugin"));
18 | PermissionHandlerWindowsPluginRegisterWithRegistrar(
19 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
20 | SharePlusWindowsPluginCApiRegisterWithRegistrar(
21 | registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
22 | UrlLauncherWindowsRegisterWithRegistrar(
23 | registry->GetRegistrarForPlugin("UrlLauncherWindows"));
24 | WebviewWindowsPluginRegisterWithRegistrar(
25 | registry->GetRegistrarForPlugin("WebviewWindowsPlugin"));
26 | }
27 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | desktop_window
7 | permission_handler_windows
8 | share_plus
9 | url_launcher_windows
10 | webview_windows
11 | )
12 |
13 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
14 | )
15 |
16 | set(PLUGIN_BUNDLED_LIBRARIES)
17 |
18 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
19 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
20 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
21 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
23 | endforeach(plugin)
24 |
25 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
26 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
28 | endforeach(ffi_plugin)
29 |
--------------------------------------------------------------------------------
/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(runner LANGUAGES CXX)
3 |
4 | add_executable(${BINARY_NAME} WIN32
5 | "flutter_window.cpp"
6 | "main.cpp"
7 | "run_loop.cpp"
8 | "utils.cpp"
9 | "win32_window.cpp"
10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
11 | "Runner.rc"
12 | "runner.exe.manifest"
13 | )
14 | apply_standard_settings(${BINARY_NAME})
15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
18 | add_dependencies(${BINARY_NAME} flutter_assemble)
19 |
--------------------------------------------------------------------------------
/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #ifdef FLUTTER_BUILD_NUMBER
64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0
67 | #endif
68 |
69 | #ifdef FLUTTER_BUILD_NAME
70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "AriesHoo" "\0"
93 | VALUE "FileDescription", "Freadhub-做轻便的聚合资讯" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "Freadhub" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2021 AriesHoo. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "Freadhub.exe" "\0"
98 | VALUE "ProductName", "Freadhub-聚合资讯" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(RunLoop* run_loop,
8 | const flutter::DartProject& project)
9 | : run_loop_(run_loop), project_(project) {}
10 |
11 | FlutterWindow::~FlutterWindow() {}
12 |
13 | bool FlutterWindow::OnCreate() {
14 | if (!Win32Window::OnCreate()) {
15 | return false;
16 | }
17 |
18 | RECT frame = GetClientArea();
19 |
20 | // The size here must match the window dimensions to avoid unnecessary surface
21 | // creation / destruction in the startup path.
22 | flutter_controller_ = std::make_unique(
23 | frame.right - frame.left, frame.bottom - frame.top, project_);
24 | // Ensure that basic setup of the controller was successful.
25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
26 | return false;
27 | }
28 | RegisterPlugins(flutter_controller_->engine());
29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
30 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
31 | return true;
32 | }
33 |
34 | void FlutterWindow::OnDestroy() {
35 | if (flutter_controller_) {
36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
37 | flutter_controller_ = nullptr;
38 | }
39 |
40 | Win32Window::OnDestroy();
41 | }
42 |
43 | LRESULT
44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
45 | WPARAM const wparam,
46 | LPARAM const lparam) noexcept {
47 | // Give Flutter, including plugins, an opportunity to handle window messages.
48 | if (flutter_controller_) {
49 | std::optional result =
50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
51 | lparam);
52 | if (result) {
53 | return *result;
54 | }
55 | }
56 |
57 | switch (message) {
58 | case WM_FONTCHANGE:
59 | flutter_controller_->engine()->ReloadSystemFonts();
60 | break;
61 | }
62 |
63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
64 | }
65 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "run_loop.h"
10 | #include "win32_window.h"
11 |
12 | // A window that does nothing but host a Flutter view.
13 | class FlutterWindow : public Win32Window {
14 | public:
15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a
16 | // Flutter view running |project|.
17 | explicit FlutterWindow(RunLoop* run_loop,
18 | const flutter::DartProject& project);
19 | virtual ~FlutterWindow();
20 |
21 | protected:
22 | // Win32Window:
23 | bool OnCreate() override;
24 | void OnDestroy() override;
25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
26 | LPARAM const lparam) noexcept override;
27 |
28 | private:
29 | // The run loop driving events for this window.
30 | RunLoop* run_loop_;
31 |
32 | // The project to run.
33 | flutter::DartProject project_;
34 |
35 | // The Flutter instance hosted by this window.
36 | std::unique_ptr flutter_controller_;
37 | };
38 |
39 | #endif // RUNNER_FLUTTER_WINDOW_H_
40 |
--------------------------------------------------------------------------------
/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "run_loop.h"
7 | #include "utils.h"
8 |
9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
10 | _In_ wchar_t *command_line, _In_ int show_command) {
11 | // Attach to console when present (e.g., 'flutter run') or create a
12 | // new console when running with a debugger.
13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
14 | CreateAndAttachConsole();
15 | }
16 |
17 | // Initialize COM, so that it is available for use in the library and/or
18 | // plugins.
19 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
20 |
21 | RunLoop run_loop;
22 |
23 | flutter::DartProject project(L"data");
24 |
25 | std::vector command_line_arguments =
26 | GetCommandLineArguments();
27 |
28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
29 |
30 | FlutterWindow window(&run_loop, project);
31 | Win32Window::Point origin(10, 10);
32 | Win32Window::Size size(800, 600);
33 | if (!window.CreateAndShow(L"Freadhub", origin, size)) {
34 | return EXIT_FAILURE;
35 | }
36 | window.SetQuitOnClose(true);
37 |
38 | run_loop.Run();
39 |
40 | ::CoUninitialize();
41 | return EXIT_SUCCESS;
42 | }
43 |
--------------------------------------------------------------------------------
/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/windows/runner/run_loop.cpp:
--------------------------------------------------------------------------------
1 | #include "run_loop.h"
2 |
3 | #include
4 |
5 | #include
6 |
7 | RunLoop::RunLoop() {}
8 |
9 | RunLoop::~RunLoop() {}
10 |
11 | void RunLoop::Run() {
12 | bool keep_running = true;
13 | TimePoint next_flutter_event_time = TimePoint::clock::now();
14 | while (keep_running) {
15 | std::chrono::nanoseconds wait_duration =
16 | std::max(std::chrono::nanoseconds(0),
17 | next_flutter_event_time - TimePoint::clock::now());
18 | ::MsgWaitForMultipleObjects(
19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000),
20 | QS_ALLINPUT);
21 | bool processed_events = false;
22 | MSG message;
23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects
24 | // won't return again for items left in the queue after PeekMessage.
25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) {
26 | processed_events = true;
27 | if (message.message == WM_QUIT) {
28 | keep_running = false;
29 | break;
30 | }
31 | ::TranslateMessage(&message);
32 | ::DispatchMessage(&message);
33 | // Allow Flutter to process messages each time a Windows message is
34 | // processed, to prevent starvation.
35 | next_flutter_event_time =
36 | std::min(next_flutter_event_time, ProcessFlutterMessages());
37 | }
38 | // If the PeekMessage loop didn't run, process Flutter messages.
39 | if (!processed_events) {
40 | next_flutter_event_time =
41 | std::min(next_flutter_event_time, ProcessFlutterMessages());
42 | }
43 | }
44 | }
45 |
46 | void RunLoop::RegisterFlutterInstance(
47 | flutter::FlutterEngine* flutter_instance) {
48 | flutter_instances_.insert(flutter_instance);
49 | }
50 |
51 | void RunLoop::UnregisterFlutterInstance(
52 | flutter::FlutterEngine* flutter_instance) {
53 | flutter_instances_.erase(flutter_instance);
54 | }
55 |
56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() {
57 | TimePoint next_event_time = TimePoint::max();
58 | for (auto instance : flutter_instances_) {
59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages();
60 | if (wait_duration != std::chrono::nanoseconds::max()) {
61 | next_event_time =
62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration);
63 | }
64 | }
65 | return next_event_time;
66 | }
67 |
--------------------------------------------------------------------------------
/windows/runner/run_loop.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_RUN_LOOP_H_
2 | #define RUNNER_RUN_LOOP_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | // A runloop that will service events for Flutter instances as well
10 | // as native messages.
11 | class RunLoop {
12 | public:
13 | RunLoop();
14 | ~RunLoop();
15 |
16 | // Prevent copying
17 | RunLoop(RunLoop const&) = delete;
18 | RunLoop& operator=(RunLoop const&) = delete;
19 |
20 | // Runs the run loop until the application quits.
21 | void Run();
22 |
23 | // Registers the given Flutter instance for event servicing.
24 | void RegisterFlutterInstance(
25 | flutter::FlutterEngine* flutter_instance);
26 |
27 | // Unregisters the given Flutter instance from event servicing.
28 | void UnregisterFlutterInstance(
29 | flutter::FlutterEngine* flutter_instance);
30 |
31 | private:
32 | using TimePoint = std::chrono::steady_clock::time_point;
33 |
34 | // Processes all currently pending messages for registered Flutter instances.
35 | TimePoint ProcessFlutterMessages();
36 |
37 | std::set flutter_instances_;
38 | };
39 |
40 | #endif // RUNNER_RUN_LOOP_H_
41 |
--------------------------------------------------------------------------------
/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | if (target_length == 0) {
52 | return std::string();
53 | }
54 | std::string utf8_string;
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------