├── .cirrus.yml ├── .flutter-plugins-dependencies ├── .fvm ├── flutter_sdk └── fvm_config.json ├── .gitignore ├── .metadata ├── LICENSE ├── README.md ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── hn_app │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── fonts ├── EBGaramond-Bold.ttf ├── EBGaramond-BoldItalic.ttf ├── EBGaramond-Italic.ttf ├── EBGaramond-Regular.ttf └── OFL.txt ├── ios ├── .gitignore ├── Flutter │ ├── .last_build_id │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── 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-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── generated_plugin_registrant.dart ├── main.dart └── src │ ├── article.dart │ ├── article.g.dart │ ├── favorites.dart │ ├── favorites.g.dart │ ├── notifiers │ ├── hn_api.dart │ ├── prefs.dart │ └── worker.dart │ ├── pages │ ├── favorites.dart │ └── settings.dart │ ├── serializers.dart │ ├── serializers.g.dart │ └── widgets │ ├── headline.dart │ ├── hn_page.dart │ ├── loading_info.dart │ └── search.dart ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── 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 ├── pubspec.lock ├── pubspec.yaml ├── test ├── json_test.dart ├── tweens_test.dart ├── widget_test.dart └── worker_test.dart └── web ├── favicon.png ├── icons ├── Icon-192.png └── Icon-512.png ├── index.html └── manifest.json /.cirrus.yml: -------------------------------------------------------------------------------- 1 | container: 2 | image: cirrusci/flutter:stable 3 | 4 | test_task: 5 | env: 6 | CIRRUS_CLONE_DEPTH: 3 7 | pub_cache: 8 | folder: ~/.pub-cache 9 | flutter_analyze_script: flutter analyze 10 | flutter_test_script: flutter test 11 | flutter_format_script: flutter format --dry-run --set-exit-if-changed . 12 | -------------------------------------------------------------------------------- /.flutter-plugins-dependencies: -------------------------------------------------------------------------------- 1 | {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.2/","dependencies":[]},{"name":"shared_preferences","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.6/","dependencies":[]},{"name":"sqflite","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]},{"name":"url_launcher","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.9/","dependencies":[]},{"name":"webview_flutter","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/webview_flutter-2.0.9/","dependencies":[]}],"android":[{"name":"path_provider","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.2/","dependencies":[]},{"name":"shared_preferences","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.6/","dependencies":[]},{"name":"sqflite","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]},{"name":"url_launcher","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.9/","dependencies":[]},{"name":"webview_flutter","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/webview_flutter-2.0.9/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.0/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.0/","dependencies":[]},{"name":"sqflite","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-2.0.0/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.0.0/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.0.0/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-2.0.0/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.1/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.0.0/","dependencies":["path_provider_windows"]},{"name":"url_launcher_windows","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-2.0.0/","dependencies":[]}],"web":[{"name":"shared_preferences_web","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.0/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/afitzgibbon/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.1/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2021-07-07 12:02:00.702221","version":"2.2.2"} -------------------------------------------------------------------------------- /.fvm/flutter_sdk: -------------------------------------------------------------------------------- 1 | /Users/filiph/fvm/versions/stable -------------------------------------------------------------------------------- /.fvm/fvm_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flutterSdkVersion": "stable", 3 | "flavors": {} 4 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.lock 4 | *.log 5 | *.pyc 6 | *.swp 7 | .DS_Store 8 | .atom/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # Visual Studio Code related 20 | .vscode/ 21 | 22 | # Flutter/Dart/Pub related 23 | **/doc/api/ 24 | .dart_tool/ 25 | .flutter-plugins 26 | .packages 27 | .pub-cache/ 28 | .pub/ 29 | build/ 30 | 31 | # Android related 32 | **/android/**/gradle-wrapper.jar 33 | **/android/.gradle 34 | **/android/captures/ 35 | **/android/gradlew 36 | **/android/gradlew.bat 37 | **/android/local.properties 38 | **/android/**/GeneratedPluginRegistrant.java 39 | 40 | # iOS/XCode related 41 | **/ios/**/*.mode1v3 42 | **/ios/**/*.mode2v3 43 | **/ios/**/*.moved-aside 44 | **/ios/**/*.pbxuser 45 | **/ios/**/*.perspectivev3 46 | **/ios/**/*sync/ 47 | **/ios/**/.sconsign.dblite 48 | **/ios/**/.tags* 49 | **/ios/**/.vagrant/ 50 | **/ios/**/DerivedData/ 51 | **/ios/**/Icon? 52 | **/ios/**/Pods/ 53 | **/ios/**/.symlinks/ 54 | **/ios/**/profile 55 | **/ios/**/xcuserdata 56 | **/ios/.generated/ 57 | **/ios/Flutter/App.framework 58 | **/ios/Flutter/Flutter.framework 59 | **/ios/Flutter/Generated.xcconfig 60 | **/ios/Flutter/app.flx 61 | **/ios/Flutter/app.zip 62 | **/ios/Flutter/flutter_assets/ 63 | **/ios/ServiceDefinitions.json 64 | **/ios/Runner/GeneratedPluginRegistrant.* 65 | 66 | # Exceptions to above rules. 67 | !**/ios/**/default.mode1v3 68 | !**/ios/**/default.mode2v3 69 | !**/ios/**/default.pbxuser 70 | !**/ios/**/default.perspectivev3 71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 72 | -------------------------------------------------------------------------------- /.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: 985ccb6d14c6ce5ce74823a4d366df2438eac44f 8 | channel: beta 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Filip Hracek 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hn_app [![Build Status](https://api.cirrus-ci.com/github/filiph/hn_app.svg)](https://cirrus-ci.com/github/filiph/hn_app) 2 | 3 | A HackerNews reader app in Flutter. 4 | 5 | ## Development 6 | 7 | If the `Article` API gets changed, you should run: 8 | 9 | `$ flutter packages pub run build_runner build --delete-conflicting-outputs` 10 | 11 | ## FVM 12 | 13 | For faster switching between versions of Flutter, this app uses 14 | the community tool called [fvm](https://github.com/leoafarias/fvm). 15 | 16 | You don't need to use it, but if you want to, then install the tool 17 | and then run everything with `fvm` (e.g. `fvm flutter build`). Read the tool's 18 | [README](https://github.com/leoafarias/fvm) for more information. 19 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 30 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | defaultConfig { 36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 37 | applicationId "com.example.hn_app" 38 | minSdkVersion 19 39 | targetSdkVersion 30 40 | versionCode flutterVersionCode.toInteger() 41 | versionName flutterVersionName 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 59 | } 60 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/hn_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.hn_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /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-6.7-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /fonts/EBGaramond-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/fonts/EBGaramond-Bold.ttf -------------------------------------------------------------------------------- /fonts/EBGaramond-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/fonts/EBGaramond-BoldItalic.ttf -------------------------------------------------------------------------------- /fonts/EBGaramond-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/fonts/EBGaramond-Italic.ttf -------------------------------------------------------------------------------- /fonts/EBGaramond-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/fonts/EBGaramond-Regular.ttf -------------------------------------------------------------------------------- /fonts/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2012 The Press Start 2P Project Authors (cody@zone38.net), with Reserved Font Name "Press Start 2P". 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /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/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/ephemeral/ 22 | Flutter/app.flx 23 | Flutter/app.zip 24 | Flutter/flutter_assets/ 25 | Flutter/flutter_export_environment.sh 26 | ServiceDefinitions.json 27 | Runner/GeneratedPluginRegistrant.* 28 | 29 | # Exceptions to above rules. 30 | !default.mode1v3 31 | !default.mode2v3 32 | !default.pbxuser 33 | !default.perspectivev3 34 | -------------------------------------------------------------------------------- /ios/Flutter/.last_build_id: -------------------------------------------------------------------------------- 1 | 48dc7c651b6f161d08dda96ae83b905f -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /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, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def 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 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 55E7ACD8A679DCC845C6CC01 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD31CD4E6402E0BCFC030DDA /* Pods_Runner.framework */; }; 13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 34 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 35 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 36 | 67CDC2BC15458EA8F6BF44EE /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 37 | 6D1F53A324AAF8870C53DE5F /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 38 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 39 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 41 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 42 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 43 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 47 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | EEBE40110E6896B425A5B61D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 49 | FD31CD4E6402E0BCFC030DDA /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 55E7ACD8A679DCC845C6CC01 /* Pods_Runner.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 5BCD3937B41EC21CDE115480 /* Pods */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 67CDC2BC15458EA8F6BF44EE /* Pods-Runner.debug.xcconfig */, 68 | EEBE40110E6896B425A5B61D /* Pods-Runner.release.xcconfig */, 69 | 6D1F53A324AAF8870C53DE5F /* Pods-Runner.profile.xcconfig */, 70 | ); 71 | name = Pods; 72 | path = Pods; 73 | sourceTree = ""; 74 | }; 75 | 9740EEB11CF90186004384FC /* Flutter */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 79 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 80 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 81 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 82 | ); 83 | name = Flutter; 84 | sourceTree = ""; 85 | }; 86 | 97C146E51CF9000F007C117D = { 87 | isa = PBXGroup; 88 | children = ( 89 | 9740EEB11CF90186004384FC /* Flutter */, 90 | 97C146F01CF9000F007C117D /* Runner */, 91 | 97C146EF1CF9000F007C117D /* Products */, 92 | 5BCD3937B41EC21CDE115480 /* Pods */, 93 | E1D3D50D3C02C29B0E5ED2DB /* Frameworks */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 97C146EF1CF9000F007C117D /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 97C146EE1CF9000F007C117D /* Runner.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 97C146F01CF9000F007C117D /* Runner */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 109 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 110 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 111 | 97C147021CF9000F007C117D /* Info.plist */, 112 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 113 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 114 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 115 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 116 | ); 117 | path = Runner; 118 | sourceTree = ""; 119 | }; 120 | E1D3D50D3C02C29B0E5ED2DB /* Frameworks */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | FD31CD4E6402E0BCFC030DDA /* Pods_Runner.framework */, 124 | ); 125 | name = Frameworks; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | 97C146ED1CF9000F007C117D /* Runner */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 134 | buildPhases = ( 135 | A827F9914A0E15DB2F24E38A /* [CP] Check Pods Manifest.lock */, 136 | 9740EEB61CF901F6004384FC /* Run Script */, 137 | 97C146EA1CF9000F007C117D /* Sources */, 138 | 97C146EB1CF9000F007C117D /* Frameworks */, 139 | 97C146EC1CF9000F007C117D /* Resources */, 140 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 141 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 142 | 9EECF4D5CF8F1599F0012D66 /* [CP] Embed Pods Frameworks */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | ); 148 | name = Runner; 149 | productName = Runner; 150 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 151 | productType = "com.apple.product-type.application"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | 97C146E61CF9000F007C117D /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastUpgradeCheck = 1020; 160 | ORGANIZATIONNAME = ""; 161 | TargetAttributes = { 162 | 97C146ED1CF9000F007C117D = { 163 | CreatedOnToolsVersion = 7.3.1; 164 | LastSwiftMigration = 1100; 165 | }; 166 | }; 167 | }; 168 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 169 | compatibilityVersion = "Xcode 9.3"; 170 | developmentRegion = en; 171 | hasScannedForEncodings = 0; 172 | knownRegions = ( 173 | en, 174 | Base, 175 | ); 176 | mainGroup = 97C146E51CF9000F007C117D; 177 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 178 | projectDirPath = ""; 179 | projectRoot = ""; 180 | targets = ( 181 | 97C146ED1CF9000F007C117D /* Runner */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXResourcesBuildPhase section */ 187 | 97C146EC1CF9000F007C117D /* Resources */ = { 188 | isa = PBXResourcesBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 192 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 193 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 194 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXResourcesBuildPhase section */ 199 | 200 | /* Begin PBXShellScriptBuildPhase section */ 201 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 202 | isa = PBXShellScriptBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | inputPaths = ( 207 | ); 208 | name = "Thin Binary"; 209 | outputPaths = ( 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | shellPath = /bin/sh; 213 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 214 | }; 215 | 9740EEB61CF901F6004384FC /* Run Script */ = { 216 | isa = PBXShellScriptBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | ); 220 | inputPaths = ( 221 | ); 222 | name = "Run Script"; 223 | outputPaths = ( 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | shellPath = /bin/sh; 227 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 228 | }; 229 | 9EECF4D5CF8F1599F0012D66 /* [CP] Embed Pods Frameworks */ = { 230 | isa = PBXShellScriptBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | ); 234 | inputFileListPaths = ( 235 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 236 | ); 237 | name = "[CP] Embed Pods Frameworks"; 238 | outputFileListPaths = ( 239 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | shellPath = /bin/sh; 243 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 244 | showEnvVarsInLog = 0; 245 | }; 246 | A827F9914A0E15DB2F24E38A /* [CP] Check Pods Manifest.lock */ = { 247 | isa = PBXShellScriptBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | ); 251 | inputFileListPaths = ( 252 | ); 253 | inputPaths = ( 254 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 255 | "${PODS_ROOT}/Manifest.lock", 256 | ); 257 | name = "[CP] Check Pods Manifest.lock"; 258 | outputFileListPaths = ( 259 | ); 260 | outputPaths = ( 261 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | shellPath = /bin/sh; 265 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 266 | showEnvVarsInLog = 0; 267 | }; 268 | /* End PBXShellScriptBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | 97C146EA1CF9000F007C117D /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 276 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXSourcesBuildPhase section */ 281 | 282 | /* Begin PBXVariantGroup section */ 283 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 284 | isa = PBXVariantGroup; 285 | children = ( 286 | 97C146FB1CF9000F007C117D /* Base */, 287 | ); 288 | name = Main.storyboard; 289 | sourceTree = ""; 290 | }; 291 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 292 | isa = PBXVariantGroup; 293 | children = ( 294 | 97C147001CF9000F007C117D /* Base */, 295 | ); 296 | name = LaunchScreen.storyboard; 297 | sourceTree = ""; 298 | }; 299 | /* End PBXVariantGroup section */ 300 | 301 | /* Begin XCBuildConfiguration section */ 302 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ALWAYS_SEARCH_USER_PATHS = NO; 306 | CLANG_ANALYZER_NONNULL = YES; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_COMMA = YES; 314 | CLANG_WARN_CONSTANT_CONVERSION = YES; 315 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INFINITE_RECURSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 322 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 323 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 326 | CLANG_WARN_STRICT_PROTOTYPES = YES; 327 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = NO; 332 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 333 | ENABLE_NS_ASSERTIONS = NO; 334 | ENABLE_STRICT_OBJC_MSGSEND = YES; 335 | GCC_C_LANGUAGE_STANDARD = gnu99; 336 | GCC_NO_COMMON_BLOCKS = YES; 337 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 338 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 339 | GCC_WARN_UNDECLARED_SELECTOR = YES; 340 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 341 | GCC_WARN_UNUSED_FUNCTION = YES; 342 | GCC_WARN_UNUSED_VARIABLE = YES; 343 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 344 | MTL_ENABLE_DEBUG_INFO = NO; 345 | SDKROOT = iphoneos; 346 | SUPPORTED_PLATFORMS = iphoneos; 347 | TARGETED_DEVICE_FAMILY = "1,2"; 348 | VALIDATE_PRODUCT = YES; 349 | }; 350 | name = Profile; 351 | }; 352 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 353 | isa = XCBuildConfiguration; 354 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 355 | buildSettings = { 356 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 357 | CLANG_ENABLE_MODULES = YES; 358 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 359 | ENABLE_BITCODE = NO; 360 | INFOPLIST_FILE = Runner/Info.plist; 361 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 362 | PRODUCT_BUNDLE_IDENTIFIER = com.example.hnApp; 363 | PRODUCT_NAME = "$(TARGET_NAME)"; 364 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 365 | SWIFT_VERSION = 5.0; 366 | VERSIONING_SYSTEM = "apple-generic"; 367 | }; 368 | name = Profile; 369 | }; 370 | 97C147031CF9000F007C117D /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | CLANG_ANALYZER_NONNULL = YES; 375 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 376 | CLANG_CXX_LIBRARY = "libc++"; 377 | CLANG_ENABLE_MODULES = YES; 378 | CLANG_ENABLE_OBJC_ARC = YES; 379 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 380 | CLANG_WARN_BOOL_CONVERSION = YES; 381 | CLANG_WARN_COMMA = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 385 | CLANG_WARN_EMPTY_BODY = YES; 386 | CLANG_WARN_ENUM_CONVERSION = YES; 387 | CLANG_WARN_INFINITE_RECURSION = YES; 388 | CLANG_WARN_INT_CONVERSION = YES; 389 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 390 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 391 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 393 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 394 | CLANG_WARN_STRICT_PROTOTYPES = YES; 395 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 396 | CLANG_WARN_UNREACHABLE_CODE = YES; 397 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 398 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 399 | COPY_PHASE_STRIP = NO; 400 | DEBUG_INFORMATION_FORMAT = dwarf; 401 | ENABLE_STRICT_OBJC_MSGSEND = YES; 402 | ENABLE_TESTABILITY = YES; 403 | GCC_C_LANGUAGE_STANDARD = gnu99; 404 | GCC_DYNAMIC_NO_PIC = NO; 405 | GCC_NO_COMMON_BLOCKS = YES; 406 | GCC_OPTIMIZATION_LEVEL = 0; 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 418 | MTL_ENABLE_DEBUG_INFO = YES; 419 | ONLY_ACTIVE_ARCH = YES; 420 | SDKROOT = iphoneos; 421 | TARGETED_DEVICE_FAMILY = "1,2"; 422 | }; 423 | name = Debug; 424 | }; 425 | 97C147041CF9000F007C117D /* Release */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ALWAYS_SEARCH_USER_PATHS = NO; 429 | CLANG_ANALYZER_NONNULL = YES; 430 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 431 | CLANG_CXX_LIBRARY = "libc++"; 432 | CLANG_ENABLE_MODULES = YES; 433 | CLANG_ENABLE_OBJC_ARC = YES; 434 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 435 | CLANG_WARN_BOOL_CONVERSION = YES; 436 | CLANG_WARN_COMMA = YES; 437 | CLANG_WARN_CONSTANT_CONVERSION = YES; 438 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 439 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 440 | CLANG_WARN_EMPTY_BODY = YES; 441 | CLANG_WARN_ENUM_CONVERSION = YES; 442 | CLANG_WARN_INFINITE_RECURSION = YES; 443 | CLANG_WARN_INT_CONVERSION = YES; 444 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 445 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 446 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 447 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 448 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 449 | CLANG_WARN_STRICT_PROTOTYPES = YES; 450 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 451 | CLANG_WARN_UNREACHABLE_CODE = YES; 452 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 453 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 454 | COPY_PHASE_STRIP = NO; 455 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 456 | ENABLE_NS_ASSERTIONS = NO; 457 | ENABLE_STRICT_OBJC_MSGSEND = YES; 458 | GCC_C_LANGUAGE_STANDARD = gnu99; 459 | GCC_NO_COMMON_BLOCKS = YES; 460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 461 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 462 | GCC_WARN_UNDECLARED_SELECTOR = YES; 463 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 464 | GCC_WARN_UNUSED_FUNCTION = YES; 465 | GCC_WARN_UNUSED_VARIABLE = YES; 466 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 467 | MTL_ENABLE_DEBUG_INFO = NO; 468 | SDKROOT = iphoneos; 469 | SUPPORTED_PLATFORMS = iphoneos; 470 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 471 | TARGETED_DEVICE_FAMILY = "1,2"; 472 | VALIDATE_PRODUCT = YES; 473 | }; 474 | name = Release; 475 | }; 476 | 97C147061CF9000F007C117D /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 479 | buildSettings = { 480 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 481 | CLANG_ENABLE_MODULES = YES; 482 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 483 | ENABLE_BITCODE = NO; 484 | INFOPLIST_FILE = Runner/Info.plist; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = com.example.hnApp; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 489 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 490 | SWIFT_VERSION = 5.0; 491 | VERSIONING_SYSTEM = "apple-generic"; 492 | }; 493 | name = Debug; 494 | }; 495 | 97C147071CF9000F007C117D /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 498 | buildSettings = { 499 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 500 | CLANG_ENABLE_MODULES = YES; 501 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 502 | ENABLE_BITCODE = NO; 503 | INFOPLIST_FILE = Runner/Info.plist; 504 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 505 | PRODUCT_BUNDLE_IDENTIFIER = com.example.hnApp; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 508 | SWIFT_VERSION = 5.0; 509 | VERSIONING_SYSTEM = "apple-generic"; 510 | }; 511 | name = Release; 512 | }; 513 | /* End XCBuildConfiguration section */ 514 | 515 | /* Begin XCConfigurationList section */ 516 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 517 | isa = XCConfigurationList; 518 | buildConfigurations = ( 519 | 97C147031CF9000F007C117D /* Debug */, 520 | 97C147041CF9000F007C117D /* Release */, 521 | 249021D3217E4FDB00AE95B9 /* Profile */, 522 | ); 523 | defaultConfigurationIsVisible = 0; 524 | defaultConfigurationName = Release; 525 | }; 526 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 527 | isa = XCConfigurationList; 528 | buildConfigurations = ( 529 | 97C147061CF9000F007C117D /* Debug */, 530 | 97C147071CF9000F007C117D /* Release */, 531 | 249021D4217E4FDB00AE95B9 /* Profile */, 532 | ); 533 | defaultConfigurationIsVisible = 0; 534 | defaultConfigurationName = Release; 535 | }; 536 | /* End XCConfigurationList section */ 537 | }; 538 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 539 | } 540 | -------------------------------------------------------------------------------- /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 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | hn_app 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/generated_plugin_registrant.dart: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // ignore_for_file: lines_longer_than_80_chars 6 | 7 | import 'package:shared_preferences_web/shared_preferences_web.dart'; 8 | import 'package:url_launcher_web/url_launcher_web.dart'; 9 | 10 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 11 | 12 | // ignore: public_member_api_docs 13 | void registerPlugins(Registrar registrar) { 14 | SharedPreferencesPlugin.registerWith(registrar); 15 | UrlLauncherPlugin.registerWith(registrar); 16 | registrar.registerMessageHandler(); 17 | } 18 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/gestures.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:google_fonts/google_fonts.dart'; 6 | import 'package:hn_app/src/article.dart'; 7 | import 'package:hn_app/src/favorites.dart'; 8 | import 'package:hn_app/src/notifiers/hn_api.dart'; 9 | import 'package:hn_app/src/notifiers/prefs.dart'; 10 | import 'package:hn_app/src/pages/favorites.dart'; 11 | import 'package:hn_app/src/pages/settings.dart'; 12 | import 'package:hn_app/src/widgets/headline.dart'; 13 | import 'package:hn_app/src/widgets/hn_page.dart'; 14 | import 'package:hn_app/src/widgets/loading_info.dart'; 15 | import 'package:hn_app/src/widgets/search.dart'; 16 | import 'package:logging/logging.dart'; 17 | import 'package:provider/provider.dart'; 18 | import 'package:webview_flutter/webview_flutter.dart'; 19 | 20 | void main() { 21 | // Set up logging to console. (In production, this might go to 22 | // a rotating log, so that it can be sent to an analytics service 23 | // when problems arise.) 24 | Logger.root.level = Level.FINE; // Default is Level.INFO. 25 | Logger.root.onRecord.listen((record) { 26 | print('[${record.level.name}] ${record.loggerName} ' 27 | '-- ${record.time} -- ${record.message}'); 28 | }); 29 | 30 | runApp( 31 | MultiProvider( 32 | providers: [ 33 | ListenableProvider( 34 | create: (_) => LoadingTabsCount(), 35 | dispose: (_, value) => value.dispose(), 36 | ), 37 | Provider(create: (_) => MyDatabase()), 38 | ChangeNotifierProvider( 39 | create: (context) => HackerNewsNotifier( 40 | // TODO(filiph): revisit when ProxyProvider lands 41 | // https://github.com/rrousselGit/provider/issues/46 42 | Provider.of(context, listen: false), 43 | ), 44 | ), 45 | ChangeNotifierProvider(create: (_) => PrefsNotifier()), 46 | ], 47 | child: MyApp(), 48 | ), 49 | ); 50 | } 51 | 52 | class MyApp extends StatelessWidget { 53 | static const primaryColor = Colors.white; 54 | 55 | @override 56 | Widget build(BuildContext context) { 57 | return MaterialApp( 58 | title: 'Flutter Demo', 59 | darkTheme: ThemeData.dark(), 60 | theme: ThemeData( 61 | brightness: Provider.of(context).userDarkMode 62 | ? Brightness.dark 63 | : Brightness.light, 64 | canvasColor: Theme.of(context).brightness == Brightness.dark || 65 | Provider.of(context).userDarkMode 66 | ? Colors.black 67 | : Colors.white, 68 | primaryColor: primaryColor, 69 | scaffoldBackgroundColor: primaryColor, 70 | textTheme: TextTheme( 71 | caption: TextStyle(color: Colors.white54), 72 | button: GoogleFonts.boogaloo(fontSize: 18), 73 | subtitle1: GoogleFonts.boogaloo(fontSize: 24), 74 | ), 75 | ), 76 | onGenerateRoute: (settings) { 77 | switch (settings.name) { 78 | case '/': 79 | return MaterialPageRoute( 80 | builder: (context) => MyHomePage(), 81 | ); 82 | case '/favorites': 83 | return PageRouteBuilder( 84 | pageBuilder: (context, animation, secondaryAnimation) { 85 | return FavoritesPage(); 86 | }); 87 | case '/settings': 88 | return PageRouteBuilder( 89 | pageBuilder: (context, animation, secondaryAnimation) { 90 | return SettingsPage(animation); 91 | }, 92 | transitionsBuilder: 93 | (context, animation, secondaryAnimation, child) { 94 | return FadeTransition( 95 | opacity: animation, 96 | child: ScaleTransition( 97 | scale: animation.drive( 98 | Tween(begin: 1.3, end: 1.0).chain( 99 | CurveTween(curve: Curves.easeOutCubic), 100 | ), 101 | ), 102 | child: child, 103 | ), 104 | ); 105 | }, 106 | ); 107 | default: 108 | throw UnimplementedError('no route for $settings'); 109 | } 110 | }, 111 | ); 112 | } 113 | } 114 | 115 | class MyHomePage extends StatefulWidget { 116 | @override 117 | _MyHomePageState createState() => _MyHomePageState(); 118 | } 119 | 120 | /// The Key of the nested Navigator in the body of [_MyHomePageState]. 121 | /// 122 | /// It's a GlobalKey because we need to access it from the drawer (which is 123 | /// outside the body). 124 | GlobalKey _pageNavigatorKey = GlobalKey(); 125 | 126 | class _MyHomePageState extends State { 127 | int _currentIndex = 0; 128 | final PageController _pageController = PageController(); 129 | 130 | @override 131 | void initState() { 132 | _pageController.addListener(_handlePageChange); 133 | super.initState(); 134 | } 135 | 136 | @override 137 | void dispose() { 138 | _pageController.removeListener(_handlePageChange); 139 | super.dispose(); 140 | } 141 | 142 | void _handlePageChange() { 143 | final newIndex = _pageController.page!.round(); 144 | 145 | if (_currentIndex != newIndex) { 146 | setState(() { 147 | _currentIndex = newIndex; 148 | }); 149 | 150 | final hn = context.read(); 151 | final tabs = hn.tabs; 152 | final current = tabs[_currentIndex]; 153 | 154 | if (current.articles.isEmpty && !current.isLoading) { 155 | // New tab with no data. Let's fetch some. 156 | current.refresh(); 157 | } 158 | } 159 | } 160 | 161 | @override 162 | Widget build(BuildContext context) { 163 | final hn = context.watch(); 164 | final tabs = hn.tabs; 165 | 166 | return Scaffold( 167 | appBar: AppBar( 168 | title: Headline( 169 | text: tabs[_currentIndex].name, 170 | index: _currentIndex, 171 | ), 172 | elevation: 0.0, 173 | actions: [ 174 | IconButton( 175 | icon: Icon(Icons.search), 176 | onPressed: () async { 177 | var result = await showSearch( 178 | context: context, 179 | delegate: ArticleSearch(hn.allArticles), 180 | ); 181 | if (result != null) { 182 | Navigator.push( 183 | context, 184 | MaterialPageRoute( 185 | builder: (context) => HackerNewsWebPage(result.url))); 186 | } 187 | }, 188 | ), 189 | ], 190 | leading: Consumer(builder: (context, loading, child) { 191 | bool isLoading = loading.value > 0; 192 | return AnimatedSwitcher( 193 | duration: Duration(milliseconds: 500), 194 | child: isLoading 195 | // TODO: make sure that LoadingInfo is rotating when shown 196 | // or, better, collapse the two alternate widgets into one 197 | ? LoadingInfo(loading) 198 | : IconButton( 199 | icon: Icon(Icons.menu), 200 | onPressed: () => Scaffold.of(context).openDrawer(), 201 | ), 202 | ); 203 | }), 204 | ), 205 | // A nested navigator so we can push routes in the body from the drawer. 206 | body: Navigator( 207 | key: _pageNavigatorKey, 208 | onGenerateRoute: (settings) { 209 | // TODO: use PageRouteBuilders below instead of MaterialPageRoute 210 | // and merely cross-fade the routes 211 | 212 | if (settings.name == '/favorites') { 213 | return MaterialPageRoute( 214 | builder: (context) => FavoritesPage(), 215 | ); 216 | } 217 | 218 | return MaterialPageRoute( 219 | builder: (context) => PageView.builder( 220 | controller: _pageController, 221 | itemCount: tabs.length, 222 | itemBuilder: (context, index) => ChangeNotifierProvider.value( 223 | value: tabs[index], 224 | child: _TabPage(index), 225 | ), 226 | ), 227 | ); 228 | }, 229 | ), 230 | bottomNavigationBar: BottomNavigationBar( 231 | backgroundColor: Colors.black, 232 | currentIndex: _currentIndex, 233 | items: [ 234 | for (final tab in tabs) 235 | BottomNavigationBarItem( 236 | label: tab.name, 237 | icon: Icon(tab.icon), 238 | ) 239 | ], 240 | onTap: (index) { 241 | _pageController.animateToPage(index, 242 | duration: const Duration(milliseconds: 300), 243 | curve: Curves.easeOutCubic); 244 | setState(() { 245 | _currentIndex = index; 246 | }); 247 | }, 248 | ), 249 | 250 | drawer: Drawer( 251 | child: Container( 252 | child: ListView( 253 | children: [ 254 | DrawerHeader( 255 | child: Text('HN APP'), 256 | ), 257 | ListTile( 258 | title: Text('Favorites'), 259 | onTap: () { 260 | // TODO Figure out why past devs wanted to do a replacement. 261 | Navigator.pop(context); 262 | Navigator.pushNamed(context, '/favorites'); 263 | }, 264 | ), 265 | ListTile( 266 | title: Text('Settings'), 267 | onTap: () => Navigator.pushNamed(context, '/settings'), 268 | ), 269 | ], 270 | ), 271 | ), 272 | ), 273 | ); 274 | } 275 | } 276 | 277 | class _Item extends StatelessWidget { 278 | final Article article; 279 | final PrefsNotifier prefs; 280 | 281 | const _Item({ 282 | Key? key, 283 | required this.article, 284 | required this.prefs, 285 | }) : super(key: key); 286 | 287 | @override 288 | Widget build(BuildContext context) { 289 | final prefs = Provider.of(context); 290 | var myDatabase = Provider.of(context); 291 | assert(article.title != null); 292 | return Padding( 293 | key: PageStorageKey(article.title), 294 | padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 12.0), 295 | child: Column( 296 | children: [ 297 | ExpansionTile( 298 | leading: StreamBuilder( 299 | stream: myDatabase.isFavorite(article.id), 300 | builder: (context, snapshot) { 301 | if (snapshot.hasData && snapshot.data!) { 302 | return IconButton( 303 | icon: Icon(Icons.star), 304 | onPressed: () => myDatabase.removeFavorite(article.id)); 305 | } 306 | return IconButton( 307 | icon: Icon(Icons.star_border), 308 | onPressed: () => myDatabase.addFavorite(article)); 309 | }), 310 | title: Text(article.title!), 311 | children: [ 312 | Padding( 313 | padding: const EdgeInsets.symmetric(horizontal: 16.0), 314 | child: Column( 315 | children: [ 316 | Row( 317 | mainAxisAlignment: MainAxisAlignment.start, 318 | children: [ 319 | Padding( 320 | padding: const EdgeInsets.only(left: 46), 321 | child: TextButton( 322 | onPressed: () => Navigator.push( 323 | context, 324 | MaterialPageRoute( 325 | builder: (BuildContext context) => 326 | HackerNewsCommentPage(article.id), 327 | ), 328 | ), 329 | child: Text('${article.descendants} comments'), 330 | ), 331 | ), 332 | SizedBox(width: 16.0), 333 | IconButton( 334 | icon: Icon(Icons.launch), 335 | onPressed: () => Navigator.push( 336 | context, 337 | MaterialPageRoute( 338 | builder: (context) => 339 | HackerNewsWebPage(article.url))), 340 | ) 341 | ], 342 | ), 343 | prefs.showWebView 344 | ? Container( 345 | height: 200, 346 | child: WebView( 347 | javascriptMode: JavascriptMode.unrestricted, 348 | initialUrl: article.url, 349 | gestureRecognizers: Set() 350 | ..add(Factory( 351 | () => VerticalDragGestureRecognizer())), 352 | ), 353 | ) 354 | : Container(), 355 | ], 356 | ), 357 | ), 358 | ], 359 | ), 360 | ], 361 | ), 362 | ); 363 | } 364 | } 365 | 366 | class _TabPage extends StatelessWidget { 367 | final int index; 368 | 369 | _TabPage(this.index, {Key? key}) : super(key: key); 370 | 371 | @override 372 | Widget build(BuildContext context) { 373 | final tab = Provider.of(context); 374 | final articles = tab.articles; 375 | final prefs = Provider.of(context); 376 | 377 | if (tab.isLoading && articles.isEmpty) { 378 | return Center( 379 | child: CircularProgressIndicator(), 380 | ); 381 | } 382 | 383 | return RefreshIndicator( 384 | color: Colors.white, 385 | backgroundColor: Colors.black, 386 | onRefresh: () => tab.refresh(), 387 | child: ListView( 388 | key: PageStorageKey(index), 389 | children: [ 390 | for (final article in articles) 391 | _Item( 392 | article: article, 393 | prefs: prefs, 394 | ) 395 | ], 396 | ), 397 | ); 398 | } 399 | } 400 | 401 | class HackerNewsCommentPage extends StatelessWidget { 402 | final int id; 403 | 404 | HackerNewsCommentPage(this.id); 405 | 406 | @override 407 | Widget build(BuildContext context) { 408 | return Scaffold( 409 | appBar: AppBar( 410 | title: Text('Comments'), 411 | ), 412 | body: WebView( 413 | initialUrl: 'https://news.ycombinator.com/item?id=$id', 414 | javascriptMode: JavascriptMode.unrestricted, 415 | ), 416 | ); 417 | } 418 | } 419 | -------------------------------------------------------------------------------- /lib/src/article.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert' as json; 2 | 3 | import 'package:built_collection/built_collection.dart'; 4 | import 'package:built_value/built_value.dart'; 5 | import 'package:built_value/serializer.dart'; 6 | 7 | import 'serializers.dart'; 8 | 9 | part 'article.g.dart'; 10 | 11 | /// Note: If changing this file, see readme for how to regenerate 12 | /// serialization code. 13 | abstract class Article implements Built { 14 | static Serializer
get serializer => _$articleSerializer; 15 | 16 | int get id; 17 | 18 | bool? get deleted; 19 | 20 | /// This is the type of the article. 21 | /// 22 | /// It can be any of these: "job", "story", "comment", "poll", or "pollopt". 23 | String get type; 24 | 25 | String get by; 26 | 27 | int get time; 28 | 29 | String? get text; 30 | 31 | bool? get dead; 32 | 33 | int? get parent; 34 | 35 | int? get poll; 36 | 37 | BuiltList? get kids; 38 | 39 | String? get url; 40 | 41 | int? get score; 42 | 43 | String? get title; 44 | 45 | BuiltList? get parts; 46 | 47 | int? get descendants; 48 | 49 | Article._(); 50 | 51 | factory Article([updates(ArticleBuilder b)?]) = _$Article; 52 | } 53 | 54 | List parseStoryIds(String jsonStr) { 55 | var parsed = json.jsonDecode(jsonStr); 56 | var listOfIds = List.from(parsed); 57 | return listOfIds; 58 | } 59 | 60 | Article parseArticle(String jsonStr) { 61 | var parsed = json.jsonDecode(jsonStr); 62 | var article = standardSerializers.deserializeWith(Article.serializer, parsed); 63 | 64 | if (article == null) { 65 | // TODO(fitza) choose a better exception and message 66 | throw StateError("null article"); 67 | } 68 | return article; 69 | } 70 | -------------------------------------------------------------------------------- /lib/src/article.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'article.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | Serializer
_$articleSerializer = new _$ArticleSerializer(); 10 | 11 | class _$ArticleSerializer implements StructuredSerializer
{ 12 | @override 13 | final Iterable types = const [Article, _$Article]; 14 | @override 15 | final String wireName = 'Article'; 16 | 17 | @override 18 | Iterable serialize(Serializers serializers, Article object, 19 | {FullType specifiedType = FullType.unspecified}) { 20 | final result = [ 21 | 'id', 22 | serializers.serialize(object.id, specifiedType: const FullType(int)), 23 | 'type', 24 | serializers.serialize(object.type, specifiedType: const FullType(String)), 25 | 'by', 26 | serializers.serialize(object.by, specifiedType: const FullType(String)), 27 | 'time', 28 | serializers.serialize(object.time, specifiedType: const FullType(int)), 29 | ]; 30 | Object? value; 31 | value = object.deleted; 32 | if (value != null) { 33 | result 34 | ..add('deleted') 35 | ..add( 36 | serializers.serialize(value, specifiedType: const FullType(bool))); 37 | } 38 | value = object.text; 39 | if (value != null) { 40 | result 41 | ..add('text') 42 | ..add(serializers.serialize(value, 43 | specifiedType: const FullType(String))); 44 | } 45 | value = object.dead; 46 | if (value != null) { 47 | result 48 | ..add('dead') 49 | ..add( 50 | serializers.serialize(value, specifiedType: const FullType(bool))); 51 | } 52 | value = object.parent; 53 | if (value != null) { 54 | result 55 | ..add('parent') 56 | ..add(serializers.serialize(value, specifiedType: const FullType(int))); 57 | } 58 | value = object.poll; 59 | if (value != null) { 60 | result 61 | ..add('poll') 62 | ..add(serializers.serialize(value, specifiedType: const FullType(int))); 63 | } 64 | value = object.kids; 65 | if (value != null) { 66 | result 67 | ..add('kids') 68 | ..add(serializers.serialize(value, 69 | specifiedType: 70 | const FullType(BuiltList, const [const FullType(int)]))); 71 | } 72 | value = object.url; 73 | if (value != null) { 74 | result 75 | ..add('url') 76 | ..add(serializers.serialize(value, 77 | specifiedType: const FullType(String))); 78 | } 79 | value = object.score; 80 | if (value != null) { 81 | result 82 | ..add('score') 83 | ..add(serializers.serialize(value, specifiedType: const FullType(int))); 84 | } 85 | value = object.title; 86 | if (value != null) { 87 | result 88 | ..add('title') 89 | ..add(serializers.serialize(value, 90 | specifiedType: const FullType(String))); 91 | } 92 | value = object.parts; 93 | if (value != null) { 94 | result 95 | ..add('parts') 96 | ..add(serializers.serialize(value, 97 | specifiedType: 98 | const FullType(BuiltList, const [const FullType(int)]))); 99 | } 100 | value = object.descendants; 101 | if (value != null) { 102 | result 103 | ..add('descendants') 104 | ..add(serializers.serialize(value, specifiedType: const FullType(int))); 105 | } 106 | return result; 107 | } 108 | 109 | @override 110 | Article deserialize(Serializers serializers, Iterable serialized, 111 | {FullType specifiedType = FullType.unspecified}) { 112 | final result = new ArticleBuilder(); 113 | 114 | final iterator = serialized.iterator; 115 | while (iterator.moveNext()) { 116 | final key = iterator.current as String; 117 | iterator.moveNext(); 118 | final Object? value = iterator.current; 119 | switch (key) { 120 | case 'id': 121 | result.id = serializers.deserialize(value, 122 | specifiedType: const FullType(int)) as int; 123 | break; 124 | case 'deleted': 125 | result.deleted = serializers.deserialize(value, 126 | specifiedType: const FullType(bool)) as bool?; 127 | break; 128 | case 'type': 129 | result.type = serializers.deserialize(value, 130 | specifiedType: const FullType(String)) as String; 131 | break; 132 | case 'by': 133 | result.by = serializers.deserialize(value, 134 | specifiedType: const FullType(String)) as String; 135 | break; 136 | case 'time': 137 | result.time = serializers.deserialize(value, 138 | specifiedType: const FullType(int)) as int; 139 | break; 140 | case 'text': 141 | result.text = serializers.deserialize(value, 142 | specifiedType: const FullType(String)) as String?; 143 | break; 144 | case 'dead': 145 | result.dead = serializers.deserialize(value, 146 | specifiedType: const FullType(bool)) as bool?; 147 | break; 148 | case 'parent': 149 | result.parent = serializers.deserialize(value, 150 | specifiedType: const FullType(int)) as int?; 151 | break; 152 | case 'poll': 153 | result.poll = serializers.deserialize(value, 154 | specifiedType: const FullType(int)) as int?; 155 | break; 156 | case 'kids': 157 | result.kids.replace(serializers.deserialize(value, 158 | specifiedType: 159 | const FullType(BuiltList, const [const FullType(int)]))! 160 | as BuiltList); 161 | break; 162 | case 'url': 163 | result.url = serializers.deserialize(value, 164 | specifiedType: const FullType(String)) as String?; 165 | break; 166 | case 'score': 167 | result.score = serializers.deserialize(value, 168 | specifiedType: const FullType(int)) as int?; 169 | break; 170 | case 'title': 171 | result.title = serializers.deserialize(value, 172 | specifiedType: const FullType(String)) as String?; 173 | break; 174 | case 'parts': 175 | result.parts.replace(serializers.deserialize(value, 176 | specifiedType: 177 | const FullType(BuiltList, const [const FullType(int)]))! 178 | as BuiltList); 179 | break; 180 | case 'descendants': 181 | result.descendants = serializers.deserialize(value, 182 | specifiedType: const FullType(int)) as int?; 183 | break; 184 | } 185 | } 186 | 187 | return result.build(); 188 | } 189 | } 190 | 191 | class _$Article extends Article { 192 | @override 193 | final int id; 194 | @override 195 | final bool? deleted; 196 | @override 197 | final String type; 198 | @override 199 | final String by; 200 | @override 201 | final int time; 202 | @override 203 | final String? text; 204 | @override 205 | final bool? dead; 206 | @override 207 | final int? parent; 208 | @override 209 | final int? poll; 210 | @override 211 | final BuiltList? kids; 212 | @override 213 | final String? url; 214 | @override 215 | final int? score; 216 | @override 217 | final String? title; 218 | @override 219 | final BuiltList? parts; 220 | @override 221 | final int? descendants; 222 | 223 | factory _$Article([void Function(ArticleBuilder)? updates]) => 224 | (new ArticleBuilder()..update(updates)).build(); 225 | 226 | _$Article._( 227 | {required this.id, 228 | this.deleted, 229 | required this.type, 230 | required this.by, 231 | required this.time, 232 | this.text, 233 | this.dead, 234 | this.parent, 235 | this.poll, 236 | this.kids, 237 | this.url, 238 | this.score, 239 | this.title, 240 | this.parts, 241 | this.descendants}) 242 | : super._() { 243 | BuiltValueNullFieldError.checkNotNull(id, 'Article', 'id'); 244 | BuiltValueNullFieldError.checkNotNull(type, 'Article', 'type'); 245 | BuiltValueNullFieldError.checkNotNull(by, 'Article', 'by'); 246 | BuiltValueNullFieldError.checkNotNull(time, 'Article', 'time'); 247 | } 248 | 249 | @override 250 | Article rebuild(void Function(ArticleBuilder) updates) => 251 | (toBuilder()..update(updates)).build(); 252 | 253 | @override 254 | ArticleBuilder toBuilder() => new ArticleBuilder()..replace(this); 255 | 256 | @override 257 | bool operator ==(Object other) { 258 | if (identical(other, this)) return true; 259 | return other is Article && 260 | id == other.id && 261 | deleted == other.deleted && 262 | type == other.type && 263 | by == other.by && 264 | time == other.time && 265 | text == other.text && 266 | dead == other.dead && 267 | parent == other.parent && 268 | poll == other.poll && 269 | kids == other.kids && 270 | url == other.url && 271 | score == other.score && 272 | title == other.title && 273 | parts == other.parts && 274 | descendants == other.descendants; 275 | } 276 | 277 | @override 278 | int get hashCode { 279 | return $jf($jc( 280 | $jc( 281 | $jc( 282 | $jc( 283 | $jc( 284 | $jc( 285 | $jc( 286 | $jc( 287 | $jc( 288 | $jc( 289 | $jc( 290 | $jc( 291 | $jc( 292 | $jc($jc(0, id.hashCode), 293 | deleted.hashCode), 294 | type.hashCode), 295 | by.hashCode), 296 | time.hashCode), 297 | text.hashCode), 298 | dead.hashCode), 299 | parent.hashCode), 300 | poll.hashCode), 301 | kids.hashCode), 302 | url.hashCode), 303 | score.hashCode), 304 | title.hashCode), 305 | parts.hashCode), 306 | descendants.hashCode)); 307 | } 308 | 309 | @override 310 | String toString() { 311 | return (newBuiltValueToStringHelper('Article') 312 | ..add('id', id) 313 | ..add('deleted', deleted) 314 | ..add('type', type) 315 | ..add('by', by) 316 | ..add('time', time) 317 | ..add('text', text) 318 | ..add('dead', dead) 319 | ..add('parent', parent) 320 | ..add('poll', poll) 321 | ..add('kids', kids) 322 | ..add('url', url) 323 | ..add('score', score) 324 | ..add('title', title) 325 | ..add('parts', parts) 326 | ..add('descendants', descendants)) 327 | .toString(); 328 | } 329 | } 330 | 331 | class ArticleBuilder implements Builder { 332 | _$Article? _$v; 333 | 334 | int? _id; 335 | int? get id => _$this._id; 336 | set id(int? id) => _$this._id = id; 337 | 338 | bool? _deleted; 339 | bool? get deleted => _$this._deleted; 340 | set deleted(bool? deleted) => _$this._deleted = deleted; 341 | 342 | String? _type; 343 | String? get type => _$this._type; 344 | set type(String? type) => _$this._type = type; 345 | 346 | String? _by; 347 | String? get by => _$this._by; 348 | set by(String? by) => _$this._by = by; 349 | 350 | int? _time; 351 | int? get time => _$this._time; 352 | set time(int? time) => _$this._time = time; 353 | 354 | String? _text; 355 | String? get text => _$this._text; 356 | set text(String? text) => _$this._text = text; 357 | 358 | bool? _dead; 359 | bool? get dead => _$this._dead; 360 | set dead(bool? dead) => _$this._dead = dead; 361 | 362 | int? _parent; 363 | int? get parent => _$this._parent; 364 | set parent(int? parent) => _$this._parent = parent; 365 | 366 | int? _poll; 367 | int? get poll => _$this._poll; 368 | set poll(int? poll) => _$this._poll = poll; 369 | 370 | ListBuilder? _kids; 371 | ListBuilder get kids => _$this._kids ??= new ListBuilder(); 372 | set kids(ListBuilder? kids) => _$this._kids = kids; 373 | 374 | String? _url; 375 | String? get url => _$this._url; 376 | set url(String? url) => _$this._url = url; 377 | 378 | int? _score; 379 | int? get score => _$this._score; 380 | set score(int? score) => _$this._score = score; 381 | 382 | String? _title; 383 | String? get title => _$this._title; 384 | set title(String? title) => _$this._title = title; 385 | 386 | ListBuilder? _parts; 387 | ListBuilder get parts => _$this._parts ??= new ListBuilder(); 388 | set parts(ListBuilder? parts) => _$this._parts = parts; 389 | 390 | int? _descendants; 391 | int? get descendants => _$this._descendants; 392 | set descendants(int? descendants) => _$this._descendants = descendants; 393 | 394 | ArticleBuilder(); 395 | 396 | ArticleBuilder get _$this { 397 | final $v = _$v; 398 | if ($v != null) { 399 | _id = $v.id; 400 | _deleted = $v.deleted; 401 | _type = $v.type; 402 | _by = $v.by; 403 | _time = $v.time; 404 | _text = $v.text; 405 | _dead = $v.dead; 406 | _parent = $v.parent; 407 | _poll = $v.poll; 408 | _kids = $v.kids?.toBuilder(); 409 | _url = $v.url; 410 | _score = $v.score; 411 | _title = $v.title; 412 | _parts = $v.parts?.toBuilder(); 413 | _descendants = $v.descendants; 414 | _$v = null; 415 | } 416 | return this; 417 | } 418 | 419 | @override 420 | void replace(Article other) { 421 | ArgumentError.checkNotNull(other, 'other'); 422 | _$v = other as _$Article; 423 | } 424 | 425 | @override 426 | void update(void Function(ArticleBuilder)? updates) { 427 | if (updates != null) updates(this); 428 | } 429 | 430 | @override 431 | _$Article build() { 432 | _$Article _$result; 433 | try { 434 | _$result = _$v ?? 435 | new _$Article._( 436 | id: BuiltValueNullFieldError.checkNotNull(id, 'Article', 'id'), 437 | deleted: deleted, 438 | type: BuiltValueNullFieldError.checkNotNull( 439 | type, 'Article', 'type'), 440 | by: BuiltValueNullFieldError.checkNotNull(by, 'Article', 'by'), 441 | time: BuiltValueNullFieldError.checkNotNull( 442 | time, 'Article', 'time'), 443 | text: text, 444 | dead: dead, 445 | parent: parent, 446 | poll: poll, 447 | kids: _kids?.build(), 448 | url: url, 449 | score: score, 450 | title: title, 451 | parts: _parts?.build(), 452 | descendants: descendants); 453 | } catch (_) { 454 | late String _$failedField; 455 | try { 456 | _$failedField = 'kids'; 457 | _kids?.build(); 458 | 459 | _$failedField = 'parts'; 460 | _parts?.build(); 461 | } catch (e) { 462 | throw new BuiltValueNestedFieldError( 463 | 'Article', _$failedField, e.toString()); 464 | } 465 | rethrow; 466 | } 467 | replace(_$result); 468 | return _$result; 469 | } 470 | } 471 | 472 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 473 | -------------------------------------------------------------------------------- /lib/src/favorites.dart: -------------------------------------------------------------------------------- 1 | import 'package:hn_app/src/article.dart'; 2 | import 'package:moor_flutter/moor_flutter.dart'; 3 | 4 | part 'favorites.g.dart'; 5 | 6 | // this will generate a table called "todos" for us. The rows of that table will 7 | // be represented by a class called "Todo". 8 | class Favorites extends Table { 9 | // article id 10 | IntColumn? get id => integer().customConstraint('UNIQUE')(); 11 | TextColumn? get title => text()(); 12 | TextColumn? get url => text()(); 13 | TextColumn? get category => text().nullable()(); 14 | } 15 | 16 | // this annotation tells moor to prepare a database class that uses both of the 17 | // tables we just defined. We'll see how to use that database class in a moment. 18 | @UseMoor(tables: [Favorites]) 19 | class MyDatabase extends _$MyDatabase { 20 | // we tell the database where to store the data with this constructor 21 | MyDatabase() 22 | : super(FlutterQueryExecutor.inDatabaseFolder(path: 'db1.sqlite')); 23 | 24 | // you should bump this number whenever you change or add a table definition. Migrations 25 | // are covered later in this readme. 26 | @override 27 | int get schemaVersion => 1; 28 | 29 | Future> get allFavorites => select(favorites).get(); 30 | 31 | void addFavorite(Article article) { 32 | var favorite = Favorite( 33 | id: article.id, 34 | url: article.url ?? '', 35 | title: article.title ?? '', 36 | category: article.type); 37 | into(favorites).insert(favorite); 38 | } 39 | 40 | void removeFavorite(int? i) => 41 | (delete(favorites)..where((t) => t.id.equals(i))).go(); 42 | 43 | // watches all todo entries in a given category. The stream will automatically 44 | // emit new items whenever the underlying data changes. 45 | Stream isFavorite(int id) { 46 | // TODO: is there a count for Moor ? MOAR APIS?! 47 | // https://github.com/simolus3/moor/issues/55#issuecomment-507808555 48 | return select(favorites).watch().map( 49 | (favoritesList) => favoritesList.any((favorite) => favorite.id == id)); 50 | // return (select(favorites)..where((favorite) => favorite.id.equals(id))) 51 | // .watch() 52 | // .map((favoritesList) => favoritesList.length >= 1); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/src/favorites.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'favorites.dart'; 4 | 5 | // ************************************************************************** 6 | // MoorGenerator 7 | // ************************************************************************** 8 | 9 | // ignore_for_file: unnecessary_brace_in_string_interps, unnecessary_this 10 | class Favorite extends DataClass implements Insertable { 11 | final int id; 12 | final String title; 13 | final String url; 14 | final String? category; 15 | Favorite( 16 | {required this.id, 17 | required this.title, 18 | required this.url, 19 | this.category}); 20 | factory Favorite.fromData(Map data, GeneratedDatabase db, 21 | {String? prefix}) { 22 | final effectivePrefix = prefix ?? ''; 23 | return Favorite( 24 | id: const IntType() 25 | .mapFromDatabaseResponse(data['${effectivePrefix}id'])!, 26 | title: const StringType() 27 | .mapFromDatabaseResponse(data['${effectivePrefix}title'])!, 28 | url: const StringType() 29 | .mapFromDatabaseResponse(data['${effectivePrefix}url'])!, 30 | category: const StringType() 31 | .mapFromDatabaseResponse(data['${effectivePrefix}category']), 32 | ); 33 | } 34 | @override 35 | Map toColumns(bool nullToAbsent) { 36 | final map = {}; 37 | map['id'] = Variable(id); 38 | map['title'] = Variable(title); 39 | map['url'] = Variable(url); 40 | if (!nullToAbsent || category != null) { 41 | map['category'] = Variable(category); 42 | } 43 | return map; 44 | } 45 | 46 | FavoritesCompanion toCompanion(bool nullToAbsent) { 47 | return FavoritesCompanion( 48 | id: Value(id), 49 | title: Value(title), 50 | url: Value(url), 51 | category: category == null && nullToAbsent 52 | ? const Value.absent() 53 | : Value(category), 54 | ); 55 | } 56 | 57 | factory Favorite.fromJson(Map json, 58 | {ValueSerializer? serializer}) { 59 | serializer ??= moorRuntimeOptions.defaultSerializer; 60 | return Favorite( 61 | id: serializer.fromJson(json['id']), 62 | title: serializer.fromJson(json['title']), 63 | url: serializer.fromJson(json['url']), 64 | category: serializer.fromJson(json['category']), 65 | ); 66 | } 67 | @override 68 | Map toJson({ValueSerializer? serializer}) { 69 | serializer ??= moorRuntimeOptions.defaultSerializer; 70 | return { 71 | 'id': serializer.toJson(id), 72 | 'title': serializer.toJson(title), 73 | 'url': serializer.toJson(url), 74 | 'category': serializer.toJson(category), 75 | }; 76 | } 77 | 78 | Favorite copyWith({int? id, String? title, String? url, String? category}) => 79 | Favorite( 80 | id: id ?? this.id, 81 | title: title ?? this.title, 82 | url: url ?? this.url, 83 | category: category ?? this.category, 84 | ); 85 | @override 86 | String toString() { 87 | return (StringBuffer('Favorite(') 88 | ..write('id: $id, ') 89 | ..write('title: $title, ') 90 | ..write('url: $url, ') 91 | ..write('category: $category') 92 | ..write(')')) 93 | .toString(); 94 | } 95 | 96 | @override 97 | int get hashCode => $mrjf($mrjc(id.hashCode, 98 | $mrjc(title.hashCode, $mrjc(url.hashCode, category.hashCode)))); 99 | @override 100 | bool operator ==(Object other) => 101 | identical(this, other) || 102 | (other is Favorite && 103 | other.id == this.id && 104 | other.title == this.title && 105 | other.url == this.url && 106 | other.category == this.category); 107 | } 108 | 109 | class FavoritesCompanion extends UpdateCompanion { 110 | final Value id; 111 | final Value title; 112 | final Value url; 113 | final Value category; 114 | const FavoritesCompanion({ 115 | this.id = const Value.absent(), 116 | this.title = const Value.absent(), 117 | this.url = const Value.absent(), 118 | this.category = const Value.absent(), 119 | }); 120 | FavoritesCompanion.insert({ 121 | required int id, 122 | required String title, 123 | required String url, 124 | this.category = const Value.absent(), 125 | }) : id = Value(id), 126 | title = Value(title), 127 | url = Value(url); 128 | static Insertable custom({ 129 | Expression? id, 130 | Expression? title, 131 | Expression? url, 132 | Expression? category, 133 | }) { 134 | return RawValuesInsertable({ 135 | if (id != null) 'id': id, 136 | if (title != null) 'title': title, 137 | if (url != null) 'url': url, 138 | if (category != null) 'category': category, 139 | }); 140 | } 141 | 142 | FavoritesCompanion copyWith( 143 | {Value? id, 144 | Value? title, 145 | Value? url, 146 | Value? category}) { 147 | return FavoritesCompanion( 148 | id: id ?? this.id, 149 | title: title ?? this.title, 150 | url: url ?? this.url, 151 | category: category ?? this.category, 152 | ); 153 | } 154 | 155 | @override 156 | Map toColumns(bool nullToAbsent) { 157 | final map = {}; 158 | if (id.present) { 159 | map['id'] = Variable(id.value); 160 | } 161 | if (title.present) { 162 | map['title'] = Variable(title.value); 163 | } 164 | if (url.present) { 165 | map['url'] = Variable(url.value); 166 | } 167 | if (category.present) { 168 | map['category'] = Variable(category.value); 169 | } 170 | return map; 171 | } 172 | 173 | @override 174 | String toString() { 175 | return (StringBuffer('FavoritesCompanion(') 176 | ..write('id: $id, ') 177 | ..write('title: $title, ') 178 | ..write('url: $url, ') 179 | ..write('category: $category') 180 | ..write(')')) 181 | .toString(); 182 | } 183 | } 184 | 185 | class $FavoritesTable extends Favorites 186 | with TableInfo<$FavoritesTable, Favorite> { 187 | final GeneratedDatabase _db; 188 | final String? _alias; 189 | $FavoritesTable(this._db, [this._alias]); 190 | final VerificationMeta _idMeta = const VerificationMeta('id'); 191 | late final GeneratedColumn id = GeneratedColumn( 192 | 'id', aliasedName, false, 193 | typeName: 'INTEGER', 194 | requiredDuringInsert: true, 195 | $customConstraints: 'UNIQUE'); 196 | final VerificationMeta _titleMeta = const VerificationMeta('title'); 197 | late final GeneratedColumn title = GeneratedColumn( 198 | 'title', aliasedName, false, 199 | typeName: 'TEXT', requiredDuringInsert: true); 200 | final VerificationMeta _urlMeta = const VerificationMeta('url'); 201 | late final GeneratedColumn url = GeneratedColumn( 202 | 'url', aliasedName, false, 203 | typeName: 'TEXT', requiredDuringInsert: true); 204 | final VerificationMeta _categoryMeta = const VerificationMeta('category'); 205 | late final GeneratedColumn category = GeneratedColumn( 206 | 'category', aliasedName, true, 207 | typeName: 'TEXT', requiredDuringInsert: false); 208 | @override 209 | List get $columns => [id, title, url, category]; 210 | @override 211 | String get aliasedName => _alias ?? 'favorites'; 212 | @override 213 | String get actualTableName => 'favorites'; 214 | @override 215 | VerificationContext validateIntegrity(Insertable instance, 216 | {bool isInserting = false}) { 217 | final context = VerificationContext(); 218 | final data = instance.toColumns(true); 219 | if (data.containsKey('id')) { 220 | context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); 221 | } else if (isInserting) { 222 | context.missing(_idMeta); 223 | } 224 | if (data.containsKey('title')) { 225 | context.handle( 226 | _titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta)); 227 | } else if (isInserting) { 228 | context.missing(_titleMeta); 229 | } 230 | if (data.containsKey('url')) { 231 | context.handle( 232 | _urlMeta, url.isAcceptableOrUnknown(data['url']!, _urlMeta)); 233 | } else if (isInserting) { 234 | context.missing(_urlMeta); 235 | } 236 | if (data.containsKey('category')) { 237 | context.handle(_categoryMeta, 238 | category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); 239 | } 240 | return context; 241 | } 242 | 243 | @override 244 | Set get $primaryKey => {}; 245 | @override 246 | Favorite map(Map data, {String? tablePrefix}) { 247 | return Favorite.fromData(data, _db, 248 | prefix: tablePrefix != null ? '$tablePrefix.' : null); 249 | } 250 | 251 | @override 252 | $FavoritesTable createAlias(String alias) { 253 | return $FavoritesTable(_db, alias); 254 | } 255 | } 256 | 257 | abstract class _$MyDatabase extends GeneratedDatabase { 258 | _$MyDatabase(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e); 259 | late final $FavoritesTable favorites = $FavoritesTable(this); 260 | @override 261 | Iterable get allTables => allSchemaEntities.whereType(); 262 | @override 263 | List get allSchemaEntities => [favorites]; 264 | } 265 | -------------------------------------------------------------------------------- /lib/src/notifiers/hn_api.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:collection'; 3 | 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:hn_app/src/article.dart'; 7 | import 'package:hn_app/src/notifiers/worker.dart'; 8 | import 'package:logging/logging.dart'; 9 | 10 | class HackerNewsApiError extends Error { 11 | final String message; 12 | 13 | HackerNewsApiError(this.message); 14 | } 15 | 16 | /// The number of tabs that are currently loading. 17 | class LoadingTabsCount extends ValueNotifier { 18 | LoadingTabsCount() : super(0); 19 | } 20 | 21 | /// This class encapsulates the app's communication with the Hacker News API 22 | /// and which articles are fetched in which [tabs]. 23 | class HackerNewsNotifier with ChangeNotifier { 24 | static final _log = Logger('HackerNewsNotifier'); 25 | 26 | late List _tabs; 27 | 28 | HackerNewsNotifier(LoadingTabsCount loading) { 29 | _log.fine('constructor called'); 30 | 31 | _tabs = [ 32 | HackerNewsTab( 33 | StoriesType.topStories, 34 | 'Top Stories', 35 | Icons.arrow_drop_up, 36 | loading, 37 | ), 38 | HackerNewsTab( 39 | StoriesType.newStories, 40 | 'New Stories', 41 | Icons.new_releases, 42 | loading, 43 | ), 44 | ]; 45 | 46 | scheduleMicrotask(() { 47 | _log.fine('First refresh of first tab called'); 48 | _tabs.first.refresh(); 49 | }); 50 | } 51 | 52 | /// Articles from all tabs. De-duplicated. 53 | UnmodifiableListView
get allArticles => UnmodifiableListView( 54 | _tabs.expand((tab) => tab.articles).toSet().toList(growable: false)); 55 | 56 | UnmodifiableListView get tabs => UnmodifiableListView(_tabs); 57 | } 58 | 59 | class HackerNewsTab with ChangeNotifier { 60 | final Logger _log; 61 | 62 | final StoriesType storiesType; 63 | 64 | final String name; 65 | 66 | List
_articles = []; 67 | 68 | bool _isLoading = false; 69 | bool get isLoading => _isLoading; 70 | 71 | final IconData icon; 72 | 73 | final LoadingTabsCount loadingTabsCount; 74 | 75 | HackerNewsTab(this.storiesType, this.name, this.icon, this.loadingTabsCount) 76 | // In this case, we want the logger name to have the type of the stories 77 | // in it. So we make it an instance field, and initialize it here. 78 | : _log = Logger('HackerNewsTab.$storiesType'); 79 | 80 | UnmodifiableListView
get articles => UnmodifiableListView(_articles); 81 | 82 | Future refresh() async { 83 | _log.info('refresh() called'); 84 | _isLoading = true; 85 | notifyListeners(); 86 | loadingTabsCount.value += 1; 87 | 88 | final worker = Worker(); 89 | await worker.isReady; 90 | _log.fine('worker created and ready, fetching'); 91 | 92 | _articles = await worker.fetch(storiesType); 93 | _isLoading = false; 94 | _log.fine('articles fetched'); 95 | 96 | worker.dispose(); 97 | 98 | // TODO: remove the artificial delay, or don't wait if the actual fetch 99 | // has taken enough time 100 | await Future.delayed(const Duration(seconds: 1)); 101 | notifyListeners(); 102 | loadingTabsCount.value -= 1; 103 | _log.fine('articles refreshed, listeners notified'); 104 | } 105 | } 106 | 107 | enum StoriesType { 108 | topStories, 109 | newStories, 110 | } 111 | 112 | class HackerNewsApiException implements Exception { 113 | final int? statusCode; 114 | final String? message; 115 | 116 | const HackerNewsApiException({this.statusCode, this.message}); 117 | } 118 | -------------------------------------------------------------------------------- /lib/src/notifiers/prefs.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:shared_preferences/shared_preferences.dart'; 5 | 6 | class PrefsBlocError extends Error { 7 | final String message; 8 | 9 | PrefsBlocError(this.message); 10 | } 11 | 12 | class PrefsState { 13 | final bool showWebView; 14 | final bool userSetDarkMode; 15 | 16 | const PrefsState({this.showWebView = false, this.userSetDarkMode = false}); 17 | } 18 | 19 | class PrefsNotifier with ChangeNotifier { 20 | PrefsState _currentPrefs = 21 | PrefsState(showWebView: false, userSetDarkMode: false); 22 | 23 | PrefsNotifier() { 24 | _loadSharedPrefs(); 25 | } 26 | 27 | bool get showWebView => _currentPrefs.showWebView; 28 | bool get userDarkMode => _currentPrefs.userSetDarkMode; 29 | 30 | set showWebView(bool newValue) { 31 | if (newValue == _currentPrefs.showWebView) return; 32 | _currentPrefs = PrefsState(showWebView: newValue); 33 | notifyListeners(); 34 | _saveNewPrefs(); 35 | } 36 | 37 | set userDarkMode(bool newValue) { 38 | if (newValue == _currentPrefs.userSetDarkMode) return; 39 | _currentPrefs = PrefsState(userSetDarkMode: newValue); 40 | notifyListeners(); 41 | _saveNewPrefs(); 42 | } 43 | 44 | Future _loadSharedPrefs() async { 45 | var sharedPrefs = await SharedPreferences.getInstance(); 46 | var showWebView = sharedPrefs.getBool('showWebView') ?? false; 47 | var userDarkMode = sharedPrefs.getBool('userDarkMode') ?? false; 48 | _currentPrefs = 49 | PrefsState(showWebView: showWebView, userSetDarkMode: userDarkMode); 50 | notifyListeners(); 51 | } 52 | 53 | Future _saveNewPrefs() async { 54 | var sharedPrefs = await SharedPreferences.getInstance(); 55 | // TODO(efortuna): Why is this a shared preferences variable? 56 | await sharedPrefs.setBool('showWebView', _currentPrefs.showWebView); 57 | await sharedPrefs.setBool('userDarkMode', _currentPrefs.userSetDarkMode); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/src/notifiers/worker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | import 'dart:isolate'; 4 | 5 | import 'package:built_value/serializer.dart'; 6 | import 'package:hn_app/src/article.dart'; 7 | import 'package:hn_app/src/notifiers/hn_api.dart'; 8 | import 'package:http/http.dart' as http; 9 | 10 | class Worker { 11 | static const _baseUrl = 'https://hacker-news.firebaseio.com/v0/'; 12 | 13 | late SendPort _sendPort; 14 | 15 | late Isolate _isolate; 16 | 17 | Completer>? _ids; 18 | 19 | final _isolateReady = Completer(); 20 | 21 | Worker() { 22 | init(); 23 | } 24 | 25 | Future get isReady => _isolateReady.future; 26 | 27 | void dispose() { 28 | _isolate.kill(); 29 | } 30 | 31 | Future> fetch(StoriesType type) async { 32 | var partUrl = type == StoriesType.topStories ? 'top' : 'new'; 33 | var url = '$_baseUrl${partUrl}stories.json'; 34 | 35 | _sendPort.send(url); 36 | 37 | // TODO: deal with multiple simultaneous requests 38 | _ids = Completer>(); 39 | return _ids!.future; 40 | } 41 | 42 | Future init() async { 43 | final receivePort = ReceivePort(); 44 | final errorPort = ReceivePort(); 45 | errorPort.listen(print); 46 | 47 | receivePort.listen(_handleMessage); 48 | _isolate = await Isolate.spawn( 49 | _isolateEntry, 50 | receivePort.sendPort, 51 | onError: errorPort.sendPort, 52 | ); 53 | } 54 | 55 | void _handleMessage(dynamic message) { 56 | if (message is SendPort) { 57 | _sendPort = message; 58 | _isolateReady.complete(); 59 | return; 60 | } 61 | 62 | if (message is List
) { 63 | _ids?.complete(message); 64 | _ids = null; 65 | return; 66 | } 67 | 68 | throw UnimplementedError("Undefined behavior for message: $message"); 69 | } 70 | 71 | static Future
_getArticle(http.Client client, int id) async { 72 | var storyUrl = '${_baseUrl}item/$id.json'; 73 | try { 74 | var storyRes = await client.get(Uri.parse(storyUrl)); 75 | if (storyRes.statusCode == 200) { 76 | return parseArticle(storyRes.body); 77 | } else { 78 | throw HackerNewsApiException(statusCode: storyRes.statusCode); 79 | } 80 | } on DeserializationError { 81 | throw HackerNewsApiException( 82 | statusCode: 200, message: "Article was not parseable."); 83 | } on http.ClientException { 84 | throw HackerNewsApiException(message: "Connection failed."); 85 | } 86 | } 87 | 88 | static Future> _getArticles( 89 | http.Client client, List articleIds) async { 90 | final results =
[]; 91 | 92 | // We are running the fetch of each article in parallel with Future.wait. 93 | // Here, we catch HackerNewsApiExceptions so that one API exception 94 | // doesn't stop the whole fetch. 95 | var futureArticles = articleIds.map>((id) async { 96 | try { 97 | var article = await _getArticle(client, id); 98 | results.add(article); 99 | } on HackerNewsApiException catch (e) { 100 | print(e); 101 | } 102 | }); 103 | await Future.wait(futureArticles); 104 | var filtered = results.where((a) => a.title != null).toList(); 105 | // Re-sort the articles according to the original order in [articleIds]. 106 | // We need to do this because fetching the articles in parallel will 107 | // result in scrambled order. 108 | filtered.sort( 109 | (a, b) => articleIds.indexOf(a.id).compareTo(articleIds.indexOf(b.id))); 110 | return filtered; 111 | } 112 | 113 | static Future> _getIds(http.Client client, String url) async { 114 | http.Response response; 115 | try { 116 | response = await client.get(Uri.parse(url)); 117 | } on SocketException catch (e) { 118 | throw HackerNewsApiException(message: "$url couldn't be fetched: $e"); 119 | } 120 | if (response.statusCode != 200) { 121 | throw HackerNewsApiException(message: "$url returned non-HTTP200"); 122 | } 123 | 124 | var result = parseStoryIds(response.body); 125 | 126 | return result.take(10).toList(); 127 | } 128 | 129 | static void _isolateEntry(dynamic message) { 130 | late SendPort sendPort; 131 | final receivePort = ReceivePort(); 132 | 133 | receivePort.listen((dynamic message) async { 134 | assert(message is String); 135 | final client = http.Client(); 136 | try { 137 | final ids = await _getIds(client, message); 138 | final articles = await _getArticles(client, ids); 139 | sendPort.send(articles); 140 | } finally { 141 | client.close(); 142 | } 143 | }); 144 | 145 | if (message is SendPort) { 146 | sendPort = message; 147 | sendPort.send(receivePort.sendPort); 148 | return; 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /lib/src/pages/favorites.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hn_app/src/favorites.dart'; 3 | import 'package:provider/provider.dart'; 4 | import 'package:hn_app/src/widgets/hn_page.dart'; 5 | 6 | class FavoritesPage extends StatefulWidget { 7 | @override 8 | _FavoritesPageState createState() => _FavoritesPageState(); 9 | } 10 | 11 | class _FavoritesPageState extends State { 12 | late List _favorites; 13 | 14 | @override 15 | void initState() { 16 | super.initState(); 17 | _favorites = []; 18 | } 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | var myDatabase = Provider.of(context); 23 | 24 | // TODO: add comments to the favorites page. 25 | return Scaffold( 26 | appBar: AppBar( 27 | title: Text("FAVORITES"), 28 | ), 29 | body: StreamBuilder( 30 | stream: myDatabase.allFavorites.asStream(), 31 | builder: (context, AsyncSnapshot> snapshot) { 32 | return Column( 33 | children: [ 34 | Expanded( 35 | child: ListView.builder( 36 | itemCount: snapshot.data?.length, 37 | itemBuilder: (_, index) { 38 | if (snapshot.data == null) { 39 | return Container(); 40 | } 41 | Favorite article = snapshot.data![index]; 42 | 43 | return ListTile( 44 | leading: IconButton( 45 | icon: Icon(Icons.star), 46 | onPressed: () { 47 | myDatabase.removeFavorite(article.id); 48 | // TODO(fitza): verify that this is or isn't best practice 49 | setState(() => {}); 50 | }), 51 | title: Text(snapshot.data![index].title), 52 | onTap: () { 53 | Navigator.push( 54 | context, 55 | MaterialPageRoute( 56 | builder: (context) => 57 | HackerNewsWebPage(article.url))); 58 | }, 59 | ); 60 | }, 61 | ), 62 | ), 63 | ], 64 | ); 65 | }, 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/src/pages/settings.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hn_app/src/notifiers/prefs.dart'; 3 | import 'package:provider/provider.dart'; 4 | 5 | class SettingsPage extends StatelessWidget { 6 | final Animation initialAnimation; 7 | 8 | const SettingsPage(this.initialAnimation, {Key? key}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return ValueListenableBuilder( 13 | valueListenable: initialAnimation, 14 | builder: (context, dynamic value, child) { 15 | return Theme( 16 | data: ThemeData( 17 | canvasColor: 18 | ColorTween(begin: Color(0x00FFFFFF), end: Colors.white) 19 | .transform(value)), 20 | child: child!, 21 | ); 22 | }, 23 | child: Scaffold( 24 | appBar: AppBar(), 25 | body: Column( 26 | children: [ 27 | Text('Use Dark Mode'), 28 | Switch( 29 | value: Provider.of(context).userDarkMode, 30 | onChanged: (bool newValue) { 31 | Provider.of(context).userDarkMode = newValue; 32 | }, 33 | ), 34 | ], 35 | ), 36 | ), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/src/serializers.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Google Inc. Please see the AUTHORS file for details. 2 | // All rights reserved. Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | library serializers; 6 | 7 | import 'package:built_collection/built_collection.dart'; 8 | import 'package:built_value/serializer.dart'; 9 | import 'package:built_value/standard_json_plugin.dart'; 10 | 11 | import 'article.dart'; 12 | 13 | part 'serializers.g.dart'; 14 | 15 | /// Example of how to use built_value serialization. 16 | /// 17 | /// Declare a top level [Serializers] field called serializers. Annotate it 18 | /// with [SerializersFor] and provide a `const` `List` of types you want to 19 | /// be serializable. 20 | /// 21 | /// The built_value code generator will provide the implementation. It will 22 | /// contain serializers for all the types asked for explicitly plus all the 23 | /// types needed transitively via fields. 24 | /// 25 | /// You usually only need to do this once per project. 26 | @SerializersFor(const [ 27 | Article, 28 | ]) 29 | Serializers serializers = _$serializers; 30 | 31 | Serializers standardSerializers = 32 | (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); 33 | -------------------------------------------------------------------------------- /lib/src/serializers.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of serializers; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | Serializers _$serializers = (new Serializers().toBuilder() 10 | ..add(Article.serializer) 11 | ..addBuilderFactory( 12 | const FullType(BuiltList, const [const FullType(int)]), 13 | () => new ListBuilder()) 14 | ..addBuilderFactory( 15 | const FullType(BuiltList, const [const FullType(int)]), 16 | () => new ListBuilder())) 17 | .build(); 18 | 19 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 20 | -------------------------------------------------------------------------------- /lib/src/widgets/headline.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const Duration headlineAnimationDuration = const Duration(milliseconds: 400); 4 | const List headlineTextColors = [Colors.blue, Colors.deepOrange]; 5 | 6 | class Headline extends ImplicitlyAnimatedWidget { 7 | final String text; 8 | final int index; 9 | 10 | Color get targetColor => headlineTextColors[index]; 11 | 12 | Headline({required this.text, required this.index, Key? key}) 13 | : super(key: key, duration: headlineAnimationDuration); 14 | 15 | @override 16 | HeadlineState createState() { 17 | return HeadlineState(); 18 | } 19 | } 20 | 21 | class HeadlineState extends AnimatedWidgetBaseState { 22 | GhostFadeTween? _colorTween; 23 | 24 | SwitchStringTween? _switchStringTween; 25 | 26 | @override 27 | Widget build(BuildContext context) { 28 | return Text( 29 | '${_switchStringTween!.evaluate(animation)}', 30 | style: TextStyle(color: _colorTween!.evaluate(animation)), 31 | ); 32 | } 33 | 34 | @override 35 | void forEachTween(visitor) { 36 | _colorTween = visitor( 37 | _colorTween, 38 | widget.targetColor, 39 | (color) => GhostFadeTween(begin: color), 40 | ) as GhostFadeTween?; 41 | 42 | _switchStringTween = visitor( 43 | _switchStringTween, 44 | widget.text, 45 | (value) => SwitchStringTween(begin: value), 46 | ) as SwitchStringTween?; 47 | } 48 | } 49 | 50 | @visibleForTesting 51 | class GhostFadeTween extends Tween { 52 | final Color middle = Colors.white; 53 | 54 | GhostFadeTween({Color? begin, Color? end}) : super(begin: begin, end: end); 55 | 56 | Color? lerp(double t) { 57 | if (t < 0.5) { 58 | return Color.lerp(begin, middle, t * 2); 59 | } else { 60 | return Color.lerp(middle, end, (t - 0.5) * 2); 61 | } 62 | } 63 | } 64 | 65 | @visibleForTesting 66 | class SwitchStringTween extends Tween { 67 | SwitchStringTween({String? begin, String? end}) : super(begin: begin, end: end); 68 | 69 | String? lerp(double t) { 70 | if (t < 0.5) return begin; 71 | return end; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/src/widgets/hn_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:webview_flutter/webview_flutter.dart'; 3 | 4 | class HackerNewsWebPage extends StatelessWidget { 5 | HackerNewsWebPage(this.url); 6 | 7 | final String? url; 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Scaffold( 12 | appBar: AppBar( 13 | title: Text('Web Page'), 14 | ), 15 | body: WebView( 16 | initialUrl: url, 17 | javascriptMode: JavascriptMode.unrestricted, 18 | ), 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/src/widgets/loading_info.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 3 | import 'package:hn_app/src/notifiers/hn_api.dart'; 4 | 5 | class LoadingInfo extends StatefulWidget { 6 | final LoadingTabsCount isLoading; 7 | 8 | LoadingInfo(this.isLoading); 9 | 10 | createState() => LoadingInfoState(); 11 | } 12 | 13 | class LoadingInfoState extends State 14 | with TickerProviderStateMixin { 15 | late AnimationController _controller; 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | _controller = 21 | AnimationController(vsync: this, duration: Duration(seconds: 1)); 22 | widget.isLoading.addListener(_handleLoadingChange); 23 | } 24 | 25 | @override 26 | void dispose() { 27 | widget.isLoading.removeListener(_handleLoadingChange); 28 | _controller.dispose(); 29 | super.dispose(); 30 | } 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | return RotationTransition( 35 | turns: Tween(begin: 0.0, end: 1.0).animate( 36 | CurvedAnimation(parent: _controller, curve: Curves.elasticOut)), 37 | child: Icon(FontAwesomeIcons.hackerNewsSquare), 38 | ); 39 | } 40 | 41 | void _handleLoadingChange() { 42 | if (widget.isLoading.value > 0) { 43 | _controller.forward(from: 0); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/src/widgets/search.dart: -------------------------------------------------------------------------------- 1 | import 'package:collection/collection.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:hn_app/src/article.dart'; 4 | import 'package:url_launcher/url_launcher.dart'; 5 | 6 | class ArticleSearch extends SearchDelegate { 7 | final UnmodifiableListView
articles; 8 | 9 | ArticleSearch(this.articles); 10 | 11 | @override 12 | List buildActions(BuildContext context) { 13 | return [ 14 | IconButton( 15 | icon: Icon(Icons.clear), 16 | onPressed: () { 17 | query = ''; 18 | }, 19 | ), 20 | ]; 21 | } 22 | 23 | @override 24 | Widget buildLeading(BuildContext context) { 25 | return IconButton( 26 | icon: Icon(Icons.arrow_back), 27 | onPressed: () { 28 | close(context, null); 29 | }, 30 | ); 31 | } 32 | 33 | @override 34 | Widget buildResults(BuildContext context) { 35 | var results = articles 36 | .where((a) => a.title!.toLowerCase().contains(query.toLowerCase())); 37 | 38 | return ListView( 39 | children: results 40 | .map((a) => ListTile( 41 | title: Text(a.title!, 42 | style: Theme.of(context) 43 | .textTheme 44 | .subtitle1! 45 | .copyWith(fontSize: 16.0)), 46 | leading: Icon(Icons.book), 47 | onTap: () async { 48 | if (await canLaunch(a.url!)) { 49 | await launch(a.url!); 50 | } 51 | close(context, a); 52 | }, 53 | )) 54 | .toList(), 55 | ); 56 | } 57 | 58 | @override 59 | Widget buildSuggestions(BuildContext context) { 60 | final results = articles 61 | .where((a) => a.title!.toLowerCase().contains(query.toLowerCase())); 62 | 63 | return ListView( 64 | children: results 65 | .map((a) => ListTile( 66 | title: Text(a.title!, 67 | style: Theme.of(context).textTheme.subtitle1!.copyWith( 68 | fontSize: 16.0, 69 | color: Colors.blue, 70 | )), 71 | onTap: () { 72 | close(context, a); 73 | }, 74 | )) 75 | .toList(), 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/xcuserdata/ 7 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import path_provider_macos 9 | import shared_preferences_macos 10 | import sqflite 11 | import url_launcher_macos 12 | 13 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 14 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 15 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 16 | SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) 17 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 18 | } 19 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /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 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/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 = hn_app 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.hnApp 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.example. 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 | 12 | 13 | -------------------------------------------------------------------------------- /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 | $(FLUTTER_BUILD_NUMBER) 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 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "22.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "1.7.1" 18 | analyzer_plugin: 19 | dependency: transitive 20 | description: 21 | name: analyzer_plugin 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "0.6.0" 25 | args: 26 | dependency: transitive 27 | description: 28 | name: args 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.1.1" 32 | async: 33 | dependency: transitive 34 | description: 35 | name: async 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "2.6.1" 39 | boolean_selector: 40 | dependency: transitive 41 | description: 42 | name: boolean_selector 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "2.1.0" 46 | build: 47 | dependency: transitive 48 | description: 49 | name: build 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "2.0.2" 53 | build_config: 54 | dependency: transitive 55 | description: 56 | name: build_config 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.0.0" 60 | build_daemon: 61 | dependency: transitive 62 | description: 63 | name: build_daemon 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "3.0.0" 67 | build_resolvers: 68 | dependency: "direct dev" 69 | description: 70 | name: build_resolvers 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "2.0.3" 74 | build_runner: 75 | dependency: "direct dev" 76 | description: 77 | name: build_runner 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "2.0.5" 81 | build_runner_core: 82 | dependency: transitive 83 | description: 84 | name: build_runner_core 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "7.0.0" 88 | built_collection: 89 | dependency: "direct main" 90 | description: 91 | name: built_collection 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "5.1.0" 95 | built_value: 96 | dependency: "direct main" 97 | description: 98 | name: built_value 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "8.1.0" 102 | built_value_generator: 103 | dependency: "direct dev" 104 | description: 105 | name: built_value_generator 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "8.1.0" 109 | characters: 110 | dependency: transitive 111 | description: 112 | name: characters 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "1.1.0" 116 | charcode: 117 | dependency: transitive 118 | description: 119 | name: charcode 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "1.2.0" 123 | checked_yaml: 124 | dependency: transitive 125 | description: 126 | name: checked_yaml 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "2.0.1" 130 | cli_util: 131 | dependency: transitive 132 | description: 133 | name: cli_util 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "0.3.2" 137 | clock: 138 | dependency: transitive 139 | description: 140 | name: clock 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "1.1.0" 144 | code_builder: 145 | dependency: transitive 146 | description: 147 | name: code_builder 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "4.0.0" 151 | collection: 152 | dependency: transitive 153 | description: 154 | name: collection 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "1.15.0" 158 | convert: 159 | dependency: transitive 160 | description: 161 | name: convert 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "3.0.1" 165 | coverage: 166 | dependency: transitive 167 | description: 168 | name: coverage 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "1.0.3" 172 | crypto: 173 | dependency: transitive 174 | description: 175 | name: crypto 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "3.0.1" 179 | cupertino_icons: 180 | dependency: "direct main" 181 | description: 182 | name: cupertino_icons 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "1.0.3" 186 | dart_style: 187 | dependency: transitive 188 | description: 189 | name: dart_style 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "2.0.1" 193 | fake_async: 194 | dependency: transitive 195 | description: 196 | name: fake_async 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "1.2.0" 200 | ffi: 201 | dependency: transitive 202 | description: 203 | name: ffi 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "1.1.2" 207 | file: 208 | dependency: transitive 209 | description: 210 | name: file 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "6.1.2" 214 | fixnum: 215 | dependency: transitive 216 | description: 217 | name: fixnum 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "1.0.0" 221 | flutter: 222 | dependency: "direct main" 223 | description: flutter 224 | source: sdk 225 | version: "0.0.0" 226 | flutter_test: 227 | dependency: "direct dev" 228 | description: flutter 229 | source: sdk 230 | version: "0.0.0" 231 | flutter_web_plugins: 232 | dependency: transitive 233 | description: flutter 234 | source: sdk 235 | version: "0.0.0" 236 | font_awesome_flutter: 237 | dependency: "direct main" 238 | description: 239 | name: font_awesome_flutter 240 | url: "https://pub.dartlang.org" 241 | source: hosted 242 | version: "9.1.0" 243 | frontend_server_client: 244 | dependency: transitive 245 | description: 246 | name: frontend_server_client 247 | url: "https://pub.dartlang.org" 248 | source: hosted 249 | version: "2.1.0" 250 | glob: 251 | dependency: transitive 252 | description: 253 | name: glob 254 | url: "https://pub.dartlang.org" 255 | source: hosted 256 | version: "2.0.1" 257 | google_fonts: 258 | dependency: "direct main" 259 | description: 260 | name: google_fonts 261 | url: "https://pub.dartlang.org" 262 | source: hosted 263 | version: "2.1.0" 264 | graphs: 265 | dependency: transitive 266 | description: 267 | name: graphs 268 | url: "https://pub.dartlang.org" 269 | source: hosted 270 | version: "2.0.0" 271 | http: 272 | dependency: "direct main" 273 | description: 274 | name: http 275 | url: "https://pub.dartlang.org" 276 | source: hosted 277 | version: "0.13.3" 278 | http_multi_server: 279 | dependency: transitive 280 | description: 281 | name: http_multi_server 282 | url: "https://pub.dartlang.org" 283 | source: hosted 284 | version: "3.0.1" 285 | http_parser: 286 | dependency: transitive 287 | description: 288 | name: http_parser 289 | url: "https://pub.dartlang.org" 290 | source: hosted 291 | version: "4.0.0" 292 | io: 293 | dependency: transitive 294 | description: 295 | name: io 296 | url: "https://pub.dartlang.org" 297 | source: hosted 298 | version: "1.0.2" 299 | js: 300 | dependency: transitive 301 | description: 302 | name: js 303 | url: "https://pub.dartlang.org" 304 | source: hosted 305 | version: "0.6.3" 306 | json_annotation: 307 | dependency: transitive 308 | description: 309 | name: json_annotation 310 | url: "https://pub.dartlang.org" 311 | source: hosted 312 | version: "4.0.1" 313 | logging: 314 | dependency: "direct main" 315 | description: 316 | name: logging 317 | url: "https://pub.dartlang.org" 318 | source: hosted 319 | version: "1.0.1" 320 | matcher: 321 | dependency: transitive 322 | description: 323 | name: matcher 324 | url: "https://pub.dartlang.org" 325 | source: hosted 326 | version: "0.12.10" 327 | meta: 328 | dependency: transitive 329 | description: 330 | name: meta 331 | url: "https://pub.dartlang.org" 332 | source: hosted 333 | version: "1.3.0" 334 | mime: 335 | dependency: transitive 336 | description: 337 | name: mime 338 | url: "https://pub.dartlang.org" 339 | source: hosted 340 | version: "1.0.0" 341 | moor: 342 | dependency: transitive 343 | description: 344 | name: moor 345 | url: "https://pub.dartlang.org" 346 | source: hosted 347 | version: "4.4.0" 348 | moor_flutter: 349 | dependency: "direct main" 350 | description: 351 | name: moor_flutter 352 | url: "https://pub.dartlang.org" 353 | source: hosted 354 | version: "4.0.0" 355 | moor_generator: 356 | dependency: "direct dev" 357 | description: 358 | name: moor_generator 359 | url: "https://pub.dartlang.org" 360 | source: hosted 361 | version: "4.4.0" 362 | nested: 363 | dependency: transitive 364 | description: 365 | name: nested 366 | url: "https://pub.dartlang.org" 367 | source: hosted 368 | version: "1.0.0" 369 | node_preamble: 370 | dependency: transitive 371 | description: 372 | name: node_preamble 373 | url: "https://pub.dartlang.org" 374 | source: hosted 375 | version: "2.0.1" 376 | package_config: 377 | dependency: transitive 378 | description: 379 | name: package_config 380 | url: "https://pub.dartlang.org" 381 | source: hosted 382 | version: "2.0.0" 383 | path: 384 | dependency: transitive 385 | description: 386 | name: path 387 | url: "https://pub.dartlang.org" 388 | source: hosted 389 | version: "1.8.0" 390 | path_provider: 391 | dependency: transitive 392 | description: 393 | name: path_provider 394 | url: "https://pub.dartlang.org" 395 | source: hosted 396 | version: "2.0.2" 397 | path_provider_linux: 398 | dependency: transitive 399 | description: 400 | name: path_provider_linux 401 | url: "https://pub.dartlang.org" 402 | source: hosted 403 | version: "2.0.0" 404 | path_provider_macos: 405 | dependency: transitive 406 | description: 407 | name: path_provider_macos 408 | url: "https://pub.dartlang.org" 409 | source: hosted 410 | version: "2.0.0" 411 | path_provider_platform_interface: 412 | dependency: transitive 413 | description: 414 | name: path_provider_platform_interface 415 | url: "https://pub.dartlang.org" 416 | source: hosted 417 | version: "2.0.1" 418 | path_provider_windows: 419 | dependency: transitive 420 | description: 421 | name: path_provider_windows 422 | url: "https://pub.dartlang.org" 423 | source: hosted 424 | version: "2.0.1" 425 | pedantic: 426 | dependency: transitive 427 | description: 428 | name: pedantic 429 | url: "https://pub.dartlang.org" 430 | source: hosted 431 | version: "1.11.1" 432 | platform: 433 | dependency: transitive 434 | description: 435 | name: platform 436 | url: "https://pub.dartlang.org" 437 | source: hosted 438 | version: "3.0.0" 439 | plugin_platform_interface: 440 | dependency: transitive 441 | description: 442 | name: plugin_platform_interface 443 | url: "https://pub.dartlang.org" 444 | source: hosted 445 | version: "2.0.0" 446 | pool: 447 | dependency: transitive 448 | description: 449 | name: pool 450 | url: "https://pub.dartlang.org" 451 | source: hosted 452 | version: "1.5.0" 453 | process: 454 | dependency: transitive 455 | description: 456 | name: process 457 | url: "https://pub.dartlang.org" 458 | source: hosted 459 | version: "4.2.1" 460 | provider: 461 | dependency: "direct main" 462 | description: 463 | name: provider 464 | url: "https://pub.dartlang.org" 465 | source: hosted 466 | version: "5.0.0" 467 | pub_semver: 468 | dependency: transitive 469 | description: 470 | name: pub_semver 471 | url: "https://pub.dartlang.org" 472 | source: hosted 473 | version: "2.0.0" 474 | pubspec_parse: 475 | dependency: transitive 476 | description: 477 | name: pubspec_parse 478 | url: "https://pub.dartlang.org" 479 | source: hosted 480 | version: "1.0.0" 481 | quiver: 482 | dependency: transitive 483 | description: 484 | name: quiver 485 | url: "https://pub.dartlang.org" 486 | source: hosted 487 | version: "3.0.1" 488 | recase: 489 | dependency: transitive 490 | description: 491 | name: recase 492 | url: "https://pub.dartlang.org" 493 | source: hosted 494 | version: "4.0.0" 495 | shared_preferences: 496 | dependency: "direct main" 497 | description: 498 | name: shared_preferences 499 | url: "https://pub.dartlang.org" 500 | source: hosted 501 | version: "2.0.6" 502 | shared_preferences_linux: 503 | dependency: transitive 504 | description: 505 | name: shared_preferences_linux 506 | url: "https://pub.dartlang.org" 507 | source: hosted 508 | version: "2.0.0" 509 | shared_preferences_macos: 510 | dependency: transitive 511 | description: 512 | name: shared_preferences_macos 513 | url: "https://pub.dartlang.org" 514 | source: hosted 515 | version: "2.0.0" 516 | shared_preferences_platform_interface: 517 | dependency: transitive 518 | description: 519 | name: shared_preferences_platform_interface 520 | url: "https://pub.dartlang.org" 521 | source: hosted 522 | version: "2.0.0" 523 | shared_preferences_web: 524 | dependency: transitive 525 | description: 526 | name: shared_preferences_web 527 | url: "https://pub.dartlang.org" 528 | source: hosted 529 | version: "2.0.0" 530 | shared_preferences_windows: 531 | dependency: transitive 532 | description: 533 | name: shared_preferences_windows 534 | url: "https://pub.dartlang.org" 535 | source: hosted 536 | version: "2.0.0" 537 | shelf: 538 | dependency: transitive 539 | description: 540 | name: shelf 541 | url: "https://pub.dartlang.org" 542 | source: hosted 543 | version: "1.1.4" 544 | shelf_packages_handler: 545 | dependency: transitive 546 | description: 547 | name: shelf_packages_handler 548 | url: "https://pub.dartlang.org" 549 | source: hosted 550 | version: "3.0.0" 551 | shelf_static: 552 | dependency: transitive 553 | description: 554 | name: shelf_static 555 | url: "https://pub.dartlang.org" 556 | source: hosted 557 | version: "1.0.0" 558 | shelf_web_socket: 559 | dependency: transitive 560 | description: 561 | name: shelf_web_socket 562 | url: "https://pub.dartlang.org" 563 | source: hosted 564 | version: "1.0.1" 565 | sky_engine: 566 | dependency: transitive 567 | description: flutter 568 | source: sdk 569 | version: "0.0.99" 570 | source_gen: 571 | dependency: transitive 572 | description: 573 | name: source_gen 574 | url: "https://pub.dartlang.org" 575 | source: hosted 576 | version: "1.0.2" 577 | source_map_stack_trace: 578 | dependency: transitive 579 | description: 580 | name: source_map_stack_trace 581 | url: "https://pub.dartlang.org" 582 | source: hosted 583 | version: "2.1.0" 584 | source_maps: 585 | dependency: transitive 586 | description: 587 | name: source_maps 588 | url: "https://pub.dartlang.org" 589 | source: hosted 590 | version: "0.10.10" 591 | source_span: 592 | dependency: transitive 593 | description: 594 | name: source_span 595 | url: "https://pub.dartlang.org" 596 | source: hosted 597 | version: "1.8.1" 598 | sqflite: 599 | dependency: transitive 600 | description: 601 | name: sqflite 602 | url: "https://pub.dartlang.org" 603 | source: hosted 604 | version: "2.0.0+3" 605 | sqflite_common: 606 | dependency: transitive 607 | description: 608 | name: sqflite_common 609 | url: "https://pub.dartlang.org" 610 | source: hosted 611 | version: "2.0.0+2" 612 | sqlite3: 613 | dependency: transitive 614 | description: 615 | name: sqlite3 616 | url: "https://pub.dartlang.org" 617 | source: hosted 618 | version: "1.1.2" 619 | sqlparser: 620 | dependency: transitive 621 | description: 622 | name: sqlparser 623 | url: "https://pub.dartlang.org" 624 | source: hosted 625 | version: "0.17.0" 626 | stack_trace: 627 | dependency: transitive 628 | description: 629 | name: stack_trace 630 | url: "https://pub.dartlang.org" 631 | source: hosted 632 | version: "1.10.0" 633 | stream_channel: 634 | dependency: transitive 635 | description: 636 | name: stream_channel 637 | url: "https://pub.dartlang.org" 638 | source: hosted 639 | version: "2.1.0" 640 | stream_transform: 641 | dependency: transitive 642 | description: 643 | name: stream_transform 644 | url: "https://pub.dartlang.org" 645 | source: hosted 646 | version: "2.0.0" 647 | string_scanner: 648 | dependency: transitive 649 | description: 650 | name: string_scanner 651 | url: "https://pub.dartlang.org" 652 | source: hosted 653 | version: "1.1.0" 654 | synchronized: 655 | dependency: transitive 656 | description: 657 | name: synchronized 658 | url: "https://pub.dartlang.org" 659 | source: hosted 660 | version: "3.0.0" 661 | term_glyph: 662 | dependency: transitive 663 | description: 664 | name: term_glyph 665 | url: "https://pub.dartlang.org" 666 | source: hosted 667 | version: "1.2.0" 668 | test: 669 | dependency: "direct dev" 670 | description: 671 | name: test 672 | url: "https://pub.dartlang.org" 673 | source: hosted 674 | version: "1.16.8" 675 | test_api: 676 | dependency: transitive 677 | description: 678 | name: test_api 679 | url: "https://pub.dartlang.org" 680 | source: hosted 681 | version: "0.3.0" 682 | test_core: 683 | dependency: transitive 684 | description: 685 | name: test_core 686 | url: "https://pub.dartlang.org" 687 | source: hosted 688 | version: "0.3.19" 689 | timing: 690 | dependency: transitive 691 | description: 692 | name: timing 693 | url: "https://pub.dartlang.org" 694 | source: hosted 695 | version: "1.0.0" 696 | typed_data: 697 | dependency: transitive 698 | description: 699 | name: typed_data 700 | url: "https://pub.dartlang.org" 701 | source: hosted 702 | version: "1.3.0" 703 | url_launcher: 704 | dependency: "direct main" 705 | description: 706 | name: url_launcher 707 | url: "https://pub.dartlang.org" 708 | source: hosted 709 | version: "6.0.9" 710 | url_launcher_linux: 711 | dependency: transitive 712 | description: 713 | name: url_launcher_linux 714 | url: "https://pub.dartlang.org" 715 | source: hosted 716 | version: "2.0.0" 717 | url_launcher_macos: 718 | dependency: transitive 719 | description: 720 | name: url_launcher_macos 721 | url: "https://pub.dartlang.org" 722 | source: hosted 723 | version: "2.0.0" 724 | url_launcher_platform_interface: 725 | dependency: transitive 726 | description: 727 | name: url_launcher_platform_interface 728 | url: "https://pub.dartlang.org" 729 | source: hosted 730 | version: "2.0.4" 731 | url_launcher_web: 732 | dependency: transitive 733 | description: 734 | name: url_launcher_web 735 | url: "https://pub.dartlang.org" 736 | source: hosted 737 | version: "2.0.1" 738 | url_launcher_windows: 739 | dependency: transitive 740 | description: 741 | name: url_launcher_windows 742 | url: "https://pub.dartlang.org" 743 | source: hosted 744 | version: "2.0.0" 745 | vector_math: 746 | dependency: transitive 747 | description: 748 | name: vector_math 749 | url: "https://pub.dartlang.org" 750 | source: hosted 751 | version: "2.1.0" 752 | vm_service: 753 | dependency: transitive 754 | description: 755 | name: vm_service 756 | url: "https://pub.dartlang.org" 757 | source: hosted 758 | version: "6.2.0" 759 | watcher: 760 | dependency: transitive 761 | description: 762 | name: watcher 763 | url: "https://pub.dartlang.org" 764 | source: hosted 765 | version: "1.0.0" 766 | web_socket_channel: 767 | dependency: transitive 768 | description: 769 | name: web_socket_channel 770 | url: "https://pub.dartlang.org" 771 | source: hosted 772 | version: "2.1.0" 773 | webkit_inspection_protocol: 774 | dependency: transitive 775 | description: 776 | name: webkit_inspection_protocol 777 | url: "https://pub.dartlang.org" 778 | source: hosted 779 | version: "1.0.0" 780 | webview_flutter: 781 | dependency: "direct main" 782 | description: 783 | name: webview_flutter 784 | url: "https://pub.dartlang.org" 785 | source: hosted 786 | version: "2.0.9" 787 | win32: 788 | dependency: transitive 789 | description: 790 | name: win32 791 | url: "https://pub.dartlang.org" 792 | source: hosted 793 | version: "2.2.5" 794 | xdg_directories: 795 | dependency: transitive 796 | description: 797 | name: xdg_directories 798 | url: "https://pub.dartlang.org" 799 | source: hosted 800 | version: "0.2.0" 801 | yaml: 802 | dependency: transitive 803 | description: 804 | name: yaml 805 | url: "https://pub.dartlang.org" 806 | source: hosted 807 | version: "3.1.0" 808 | sdks: 809 | dart: ">=2.13.0 <3.0.0" 810 | flutter: ">=2.0.0" 811 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: hn_app 2 | description: A new Flutter application. 3 | 4 | version: 0.0.2+2 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | 9 | dependencies: 10 | moor_flutter: ^4.0.0 11 | url_launcher: ^6.0.6 12 | 13 | built_collection: ^5.0.0 14 | built_value: ^8.0.6 15 | 16 | google_fonts: ^2.1.0 17 | 18 | http: ^0.13.3 19 | 20 | logging: ">=0.11.4 <2.0.0" 21 | 22 | font_awesome_flutter: ^9.1.0 23 | 24 | webview_flutter: ^2.0.8 25 | 26 | provider: ^5.0.0 27 | 28 | flutter: 29 | sdk: flutter 30 | 31 | cupertino_icons: ^1.0.3 32 | 33 | shared_preferences: ^2.0.6 34 | 35 | dev_dependencies: 36 | build_resolvers: ^2.0.3 37 | build_runner: ^2.0.4 38 | built_value_generator: ^8.0.6 39 | moor_generator: ^4.3.1 40 | 41 | test: ^1.15.0 42 | flutter_test: 43 | sdk: flutter 44 | 45 | flutter: 46 | 47 | uses-material-design: true 48 | 49 | fonts: 50 | - family: Garamond 51 | fonts: 52 | - asset: fonts/EBGaramond-Regular.ttf 53 | - asset: fonts/EBGaramond-Italic.ttf 54 | style: italic 55 | - asset: fonts/EBGaramond-Bold.ttf 56 | weight: 700 57 | - asset: fonts/EBGaramond-BoldItalic.ttf 58 | weight: 700 59 | style: italic 60 | -------------------------------------------------------------------------------- /test/json_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:hn_app/src/article.dart'; 2 | import 'package:http/http.dart' as http; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | test("parses topstories.json", () { 7 | const jsonString = 8 | "[17238241,17239602,17238135,17236788,17237510,17238089,17230960,17238070,17238911,17238953,17236022,17239753,17237792,17235171,17237567,17236187,17236473,17236242,17237442,17239413,17238766,17235832,17234537,17237468,17234448,17235749,17237183,17237876,17234498,17234416,17237295,17236405,17236294,17235810,17239740,17239036,17237526,17233371,17239259,17230273,17235056,17239061,17237026,17237373,17236039,17235063,17223926,17231593,17233824,17236110,17229397,17230583,17233979,17235160,17234615,17226225,17233208,17238146,17234627,17230262,17235375,17237153,17231847,17233811,17230720,17238639,17230469,17230916,17233448,17221885,17231355,17230863,17227564,17238015,17231349,17233538,17222827,17230510,17231806,17230785,17224772,17232884,17221379,17230090,17237490,17234526,17229264,17230513,17217815,17222861,17216634,17231120,17232169,17219379,17228517,17230631,17235354,17231704,17226900,17234488,17235027,17230143,17232447,17235949,17217827,17232200,17220861,17232357,17224329,17229085,17234350,17236351,17218831,17226243,17234483,17234124,17231178,17220002,17230120,17229491,17223749,17230029,17233835,17234217,17228369,17229940,17217081,17231493,17229971,17228480,17216178,17230578,17235609,17221221,17217526,17236300,17228891,17218080,17235692,17233106,17220356,17234452,17220006,17232083,17220507,17219101,17228384,17223116,17232519,17217203,17233908,17214827,17216937,17220252,17221483,17234090,17234723,17218573,17231773,17221211,17217069,17218190,17220630,17221498,17217210,17214953,17220387,17229435,17219185,17220325,17235614,17231337,17221794,17218833,17220016,17216878,17217673,17217324,17214711,17225725,17220396,17215474,17214986,17217444,17229793,17231091,17220382,17234800,17216078,17218160,17216452,17220660,17215391,17236760,17217155,17216972,17239039,17222252,17214857,17214841,17214750,17216536,17215409,17234933,17218605,17234371,17221239,17216441,17232945,17226485,17226781,17225327,17222177,17215679,17216319,17226169,17224758,17215603,17216039,17229973,17215829,17234230,17217653,17218285,17230539,17219059,17215089,17219092,17218348,17218473,17231576,17217498,17214867,17230934,17217044,17219111,17215332,17216193,17230413,17230239,17218657,17216293,17230047,17232799,17221486,17222460,17232302,17218576,17223855,17214676,17219217,17217637,17215476,17225889,17219249,17230394,17215407,17216035,17220226,17223383,17216564,17223579,17217881,17228234,17220369,17215966,17217733,17222439,17215931,17221696,17233726,17216114,17225665,17233923,17216249,17227307,17215950,17215514,17222576,17224805,17230766,17219556,17228458,17221435,17223935,17217688,17219162,17215836,17215299,17225599,17224474,17217625,17223375,17216271,17220590,17215605,17221670,17224920,17220761,17217584,17224948,17215372,17216239,17219734,17224382,17216260,17217472,17216851,17216188,17217799,17216649,17220544,17216192,17215738,17215074,17219885,17215881,17220163,17220803,17217407,17217359,17219992,17228099,17215381,17215051,17234826,17223628,17227286,17218250,17225756,17227299,17220662,17221527,17228704,17218302,17232456,17231289,17229848,17228097,17230995,17225957,17226063,17229200,17217193,17239580,17233367,17229374]"; 9 | 10 | expect(parseStoryIds(jsonString).first, 17238241); 11 | }); 12 | 13 | test("parses item.json", () { 14 | const jsonString = 15 | """{"by":"dhouston","descendants":71,"id":8863,"kids":[9224,8952,8917,8884,8887,8943,8869,8940,8908,8958,9005,8873,9671,9067,9055,8865,8881,8872,8955,10403,8903,8928,9125,8998,8901,8902,8907,8894,8870,8878,8980,8934,8876],"score":104,"time":1175714200,"title":"My YC app: Dropbox - Throw away your USB drive","type":"story","url":"http://www.getdropbox.com/u/2/screencast.html"}"""; 16 | expect(parseArticle(jsonString)!.by, "dhouston"); 17 | }); 18 | 19 | test("parses item.json over a network", () async { 20 | final url = 'https://hacker-news.firebaseio.com/v0/beststories.json'; 21 | final res = await http.get(Uri.parse(url)); 22 | if (res.statusCode == 200) { 23 | final idList = parseStoryIds(res.body); 24 | if (idList.isNotEmpty) { 25 | final storyUrl = 26 | 'https://hacker-news.firebaseio.com/v0/item/${idList.first}.json'; 27 | final storyRes = await http.get(Uri.parse(storyUrl)); 28 | if (storyRes.statusCode == 200) { 29 | expect(parseArticle(storyRes.body), isNotNull); 30 | } 31 | } 32 | } 33 | }, skip: true); 34 | } 35 | -------------------------------------------------------------------------------- /test/tweens_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:hn_app/src/widgets/headline.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | group('_GhostFadeTween', () { 7 | test('interpolates colors correctly', () { 8 | Color blue = Color.fromARGB(255, 0, 0, 255); 9 | Color red = Color.fromARGB(255, 255, 0, 0); 10 | Color white = Color.fromARGB(255, 255, 255, 255); 11 | GhostFadeTween tween = GhostFadeTween( 12 | begin: blue, 13 | end: red, 14 | ); 15 | 16 | expect(tween.lerp(0.0), blue); 17 | expect(tween.lerp(0.5), white); 18 | expect(tween.lerp(1.0), red); 19 | }); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter 3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to 4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties 5 | // are correct. 6 | // import 'dart:async'; 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter_test/flutter_test.dart'; 9 | import 'package:hn_app/src/widgets/headline.dart'; 10 | 11 | void main() { 12 | testWidgets('headline animates and changes text correctly', 13 | (WidgetTester tester) async { 14 | String text = "Foo"; 15 | int index = 0; 16 | Key buttonKey = GlobalKey(); 17 | Key headlineKey = GlobalKey(); 18 | 19 | Widget widget = StatefulBuilder( 20 | builder: (BuildContext context, void Function(void Function()) setState) { 21 | return Directionality( 22 | textDirection: TextDirection.ltr, 23 | child: Column( 24 | children: [ 25 | Headline( 26 | key: headlineKey, 27 | text: text, 28 | index: index, 29 | ), 30 | TextButton( 31 | onPressed: () { 32 | setState(() { 33 | text = 'Bar'; 34 | index = 1; 35 | }); 36 | }, 37 | child: Text("Tap"), 38 | key: buttonKey, 39 | ) 40 | ], 41 | ), 42 | ); 43 | }, 44 | ); 45 | await tester.pumpWidget( 46 | widget, 47 | ); 48 | 49 | expect(find.text('Foo'), findsOneWidget); 50 | 51 | await tester.pump(); 52 | 53 | await tester.tap(find.byKey(buttonKey)); 54 | 55 | await tester.pumpAndSettle(); 56 | 57 | expect(find.text('Bar'), findsOneWidget); 58 | }); 59 | 60 | testWidgets('headline animates and changes text color correctly', 61 | (WidgetTester tester) async { 62 | String text = "Foo"; 63 | int index = 0; 64 | Key buttonKey = GlobalKey(); 65 | Key headlineKey = GlobalKey(); 66 | Headline? headline; 67 | 68 | Widget widget = StatefulBuilder( 69 | builder: (BuildContext context, void Function(void Function()) setState) { 70 | headline = Headline( 71 | key: headlineKey, 72 | text: text, 73 | index: index, 74 | ); 75 | 76 | return Directionality( 77 | textDirection: TextDirection.ltr, 78 | child: Column( 79 | children: [ 80 | headline!, 81 | TextButton( 82 | onPressed: () { 83 | setState(() { 84 | text = 'Bar'; 85 | index = 1; 86 | }); 87 | }, 88 | child: Text("Tap"), 89 | key: buttonKey, 90 | ) 91 | ], 92 | ), 93 | ); 94 | }, 95 | ); 96 | await tester.pumpWidget( 97 | widget, 98 | ); 99 | 100 | expect(headline!.targetColor, headlineTextColors[index]); 101 | 102 | await tester.pump(); 103 | 104 | await tester.tap(find.byKey(buttonKey)); 105 | 106 | await tester.pumpAndSettle(); 107 | 108 | expect(headline!.targetColor, headlineTextColors[index]); 109 | }); 110 | } 111 | -------------------------------------------------------------------------------- /test/worker_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:hn_app/src/notifiers/worker.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | void main() { 5 | test("worker spins up", () async { 6 | final worker = Worker(); 7 | await worker.isReady; 8 | worker.dispose(); 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filiph/hn_app/ce41539d7d59d1a493937dbe60e8ff796b50cdd3/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | hn_app 27 | 28 | 29 | 30 | 33 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hn_app", 3 | "short_name": "hn_app", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 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 | --------------------------------------------------------------------------------