├── linux
├── .gitignore
├── main.cc
├── flutter
│ ├── generated_plugin_registrant.h
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugins.cmake
│ └── CMakeLists.txt
├── my_application.h
├── my_application.cc
└── CMakeLists.txt
├── .env.dev
├── .env.prod
├── ios
├── Runner
│ ├── Runner-Bridging-Header.h
│ ├── Assets.xcassets
│ │ ├── LaunchImage.imageset
│ │ │ ├── logo-dark-40.png
│ │ │ ├── logo-dark-1024 1.png
│ │ │ ├── logo-dark-60@2x.png
│ │ │ ├── README.md
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ ├── App Icons - App Store@2x-1024.png
│ │ │ ├── App Icons - App Store@2x-20.png
│ │ │ ├── App Icons - App Store@2x-29 1.png
│ │ │ ├── App Icons - App Store@2x-29.png
│ │ │ ├── App Icons - App Store@2x-40.png
│ │ │ ├── App Icons - App Store@2x-76.png
│ │ │ ├── App Icons - App Store@2x-20@2x.png
│ │ │ ├── App Icons - App Store@2x-20@3x.png
│ │ │ ├── App Icons - App Store@2x-29@2x.png
│ │ │ ├── App Icons - App Store@2x-29@3x.png
│ │ │ ├── App Icons - App Store@2x-40@2x.png
│ │ │ ├── App Icons - App Store@2x-40@3x.png
│ │ │ ├── App Icons - App Store@2x-60@2x.png
│ │ │ ├── App Icons - App Store@2x-60@3x.png
│ │ │ ├── App Icons - App Store@2x-76@2x.png
│ │ │ ├── App Icons - App Store@2x-20@2x 1.png
│ │ │ ├── App Icons - App Store@2x-29@2x 1.png
│ │ │ ├── App Icons - App Store@2x-40@2x 1.png
│ │ │ ├── App Icons - App Store@2x-83.5@2x.png
│ │ │ └── Contents.json
│ ├── AppDelegate.swift
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ └── Info.plist
├── Flutter
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── AppFrameworkInfo.plist
├── Runner.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── WorkspaceSettings.xcsettings
│ │ └── IDEWorkspaceChecks.plist
├── .gitignore
├── Podfile.lock
└── Podfile
├── web
├── favicon.png
├── icons
│ ├── Icon-192.png
│ ├── Icon-512.png
│ ├── Icon-maskable-192.png
│ └── Icon-maskable-512.png
├── manifest.json
└── index.html
├── .github
├── blocks
│ └── all.json
└── workflows
│ └── android.yml
├── android
├── gradle.properties
├── app
│ ├── src
│ │ ├── main
│ │ │ ├── ic_launcher-playstore.png
│ │ │ ├── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher_round.png
│ │ │ │ │ └── ic_launcher_foreground.png
│ │ │ │ ├── values
│ │ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ ├── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable-v21
│ │ │ │ │ └── launch_background.xml
│ │ │ │ └── values-night
│ │ │ │ │ └── styles.xml
│ │ │ ├── kotlin
│ │ │ │ └── dev
│ │ │ │ │ └── progmar
│ │ │ │ │ └── tabnews
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ └── profile
│ │ │ └── AndroidManifest.xml
│ └── build.gradle
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle
└── build.gradle
├── macos
├── Runner
│ ├── Configs
│ │ ├── Debug.xcconfig
│ │ ├── Release.xcconfig
│ │ ├── Warnings.xcconfig
│ │ └── AppInfo.xcconfig
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ ├── app_icon_128.png
│ │ │ ├── app_icon_16.png
│ │ │ ├── app_icon_256.png
│ │ │ ├── app_icon_32.png
│ │ │ ├── app_icon_512.png
│ │ │ ├── app_icon_64.png
│ │ │ ├── app_icon_1024.png
│ │ │ └── Contents.json
│ ├── AppDelegate.swift
│ ├── Release.entitlements
│ ├── DebugProfile.entitlements
│ ├── MainFlutterWindow.swift
│ └── Info.plist
├── .gitignore
├── Flutter
│ ├── Flutter-Debug.xcconfig
│ ├── Flutter-Release.xcconfig
│ └── GeneratedPluginRegistrant.swift
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── Runner.xcodeproj
│ ├── project.xcworkspace
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
└── Podfile
├── windows
├── runner
│ ├── resources
│ │ └── app_icon.ico
│ ├── resource.h
│ ├── utils.h
│ ├── runner.exe.manifest
│ ├── flutter_window.h
│ ├── main.cpp
│ ├── CMakeLists.txt
│ ├── utils.cpp
│ ├── flutter_window.cpp
│ ├── Runner.rc
│ └── win32_window.h
├── .gitignore
├── flutter
│ ├── generated_plugin_registrant.h
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugins.cmake
│ └── CMakeLists.txt
└── CMakeLists.txt
├── lib
├── src
│ ├── interfaces
│ │ └── view_action.dart
│ ├── extensions
│ │ └── dark_mode.dart
│ ├── constants.dart
│ ├── ui
│ │ ├── widgets
│ │ │ ├── progress_indicator.dart
│ │ │ ├── top_bar.dart
│ │ │ ├── tabcoins.dart
│ │ │ ├── source_url.dart
│ │ │ ├── markdown.dart
│ │ │ ├── comments_children.dart
│ │ │ ├── bottom_bar.dart
│ │ │ ├── comments.dart
│ │ │ ├── item_content.dart
│ │ │ ├── answer.dart
│ │ │ └── item_comment.dart
│ │ ├── layouts
│ │ │ ├── page.dart
│ │ │ └── tab.dart
│ │ └── pages
│ │ │ ├── favorites.dart
│ │ │ ├── use_terms.dart
│ │ │ ├── home.dart
│ │ │ ├── my_contents.dart
│ │ │ ├── recents.dart
│ │ │ ├── profile.dart
│ │ │ ├── profile_user.dart
│ │ │ └── profile_edit.dart
│ ├── services
│ │ ├── user.dart
│ │ ├── http_response.dart
│ │ ├── auth.dart
│ │ └── content.dart
│ ├── preferences.dart
│ ├── models
│ │ ├── auth.dart
│ │ ├── user.dart
│ │ ├── content.dart
│ │ └── comment.dart
│ ├── enviroment_vars.dart
│ ├── utils
│ │ ├── open_link.dart
│ │ └── navigation.dart
│ ├── app.dart
│ └── controllers
│ │ ├── comment.dart
│ │ ├── app.dart
│ │ ├── favorites.dart
│ │ ├── content.dart
│ │ ├── user.dart
│ │ └── auth.dart
├── main.dart
└── assets
│ ├── logo.svg
│ └── logo-dark.svg
├── bin
└── commit_message.dart
├── lefthook.yml
├── test
└── widget_test.dart
├── .gitignore
├── LICENSE
├── analysis_options.yaml
├── .metadata
├── README.md
└── pubspec.yaml
/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/.env.dev:
--------------------------------------------------------------------------------
1 | WEBSERVER_HOST="http://:::3000"
--------------------------------------------------------------------------------
/.env.prod:
--------------------------------------------------------------------------------
1 | WEBSERVER_HOST="https://www.tabnews.com.br"
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/web/favicon.png
--------------------------------------------------------------------------------
/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/.github/blocks/all.json:
--------------------------------------------------------------------------------
1 | {
2 | "": {
3 | "default": "githubnext__blocks-examples__overview"
4 | }
5 | }
--------------------------------------------------------------------------------
/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/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/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/android/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/lib/src/interfaces/view_action.dart:
--------------------------------------------------------------------------------
1 | abstract class ViewAction {
2 | onError({required String message});
3 | onSuccess({dynamic data});
4 | }
5 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/logo-dark-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/logo-dark-40.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #252A30
4 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/logo-dark-1024 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/logo-dark-1024 1.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/logo-dark-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/logo-dark-60@2x.png
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/dev/progmar/tabnews/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package dev.progmar.tabnews
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-1024.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29 1.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-76.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-76@2x.png
--------------------------------------------------------------------------------
/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20@2x 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-20@2x 1.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29@2x 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-29@2x 1.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40@2x 1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-40@2x 1.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/avuenja/tabnews-app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/App Icons - App Store@2x-83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6 |
--------------------------------------------------------------------------------
/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/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/extensions/dark_mode.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 | import 'package:flutter/widgets.dart';
3 |
4 | extension DarkMode on BuildContext {
5 | bool get isDarkMode {
6 | final brightness = MediaQuery.of(this).platformBrightness;
7 |
8 | return brightness == Brightness.dark;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/lib/src/constants.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | abstract class AppConstants {
4 | static const String loggedInKey = 'LoggedIn';
5 | static const String authKey = 'AuthLogged';
6 | static const String userKey = 'UserLogged';
7 | }
8 |
9 | abstract class AppColors {
10 | static const Color primaryColor = Color.fromRGBO(36, 41, 47, 1);
11 | }
12 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/app.dart';
4 | import 'package:tabnews/src/enviroment_vars.dart';
5 | import 'package:tabnews/src/preferences.dart';
6 |
7 | void main() async {
8 | WidgetsFlutterBinding.ensureInitialized();
9 |
10 | await Preferences.init();
11 |
12 | await EnviromentVars.init(useProdEnv: true);
13 |
14 | runApp(const App());
15 | }
16 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void RegisterPlugins(flutter::PluginRegistry* registry) {
12 | UrlLauncherWindowsRegisterWithRegistrar(
13 | registry->GetRegistrarForPlugin("UrlLauncherWindows"));
14 | }
15 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/bin/commit_message.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | dynamic main() {
4 | final rootDir = Directory.current;
5 | final commitFile = File("${rootDir.path}/.git/COMMIT_EDITMSG");
6 | final commitMessage = commitFile.readAsStringSync();
7 |
8 | final regExp = RegExp(
9 | r'(fix|feat|wip|none|chore|refactor|docs|style|test)\(\w+\):\s?(\[\DEV-\d+])?.+',
10 | );
11 |
12 | final valid = regExp.hasMatch(commitMessage);
13 | if (!valid) exitCode = 1;
14 | }
15 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import shared_preferences_macos
9 | import url_launcher_macos
10 |
11 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
12 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
13 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
14 | }
15 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/progress_indicator.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/extensions/dark_mode.dart';
4 |
5 | class AppProgressIndicator extends StatelessWidget {
6 | const AppProgressIndicator({super.key});
7 |
8 | @override
9 | Widget build(BuildContext context) {
10 | return Center(
11 | child: CircularProgressIndicator(
12 | color: context.isDarkMode ? Colors.white : Colors.black,
13 | ),
14 | );
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void fl_register_plugins(FlPluginRegistry* registry) {
12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
15 | }
16 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "logo-dark-40.png",
5 | "idiom" : "universal",
6 | "scale" : "1x"
7 | },
8 | {
9 | "filename" : "logo-dark-60@2x.png",
10 | "idiom" : "universal",
11 | "scale" : "2x"
12 | },
13 | {
14 | "filename" : "logo-dark-1024 1.png",
15 | "idiom" : "universal",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "author" : "xcode",
21 | "version" : 1
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lefthook.yml:
--------------------------------------------------------------------------------
1 | pre-commit:
2 | parallel: true
3 | commands:
4 | tests:
5 | run: flutter test
6 | analyze:
7 | run: flutter analyze
8 | lint_code:
9 | glob: "*.dart"
10 | run: dart fix --dry-run lib && git add .
11 | format_code:
12 | glob: "*.dart"
13 | run: flutter format {staged_files} && git add .
14 |
15 | pre-push:
16 | parallel: true
17 | commands:
18 | tests:
19 | run: flutter test
20 |
21 | commit-msg:
22 | commands:
23 | validate:
24 | run: flutter pub run bin/commit_message.dart
25 |
--------------------------------------------------------------------------------
/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility in the flutter_test package. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter_test/flutter_test.dart';
9 |
10 | void main() {
11 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {});
12 | }
13 |
--------------------------------------------------------------------------------
/lib/assets/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/lib/assets/logo-dark.svg:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/lib/src/services/user.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:http/http.dart' as http;
3 | import 'package:tabnews/src/enviroment_vars.dart';
4 |
5 | import 'package:tabnews/src/models/user.dart';
6 |
7 | class UserService {
8 | String get apiUrl => '${EnviromentVars.getVars.webserver}/api/v1';
9 |
10 | Future fetchUser(String username) async {
11 | final response = await http.get(
12 | Uri.parse('$apiUrl/users/$username'),
13 | );
14 |
15 | if (response.statusCode == 200) {
16 | return User.fromJson(jsonDecode(response.body));
17 | } else {
18 | throw Exception('Failed to get public user');
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android APK
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - uses: actions/setup-java@v2
14 | with:
15 | distribution: "zulu"
16 | java-version: "11"
17 | - uses: subosito/flutter-action@v2
18 | with:
19 | channel: "stable"
20 | - run: flutter pub get
21 | - run: flutter build apk
22 | - uses: actions/upload-artifact@v3
23 | with:
24 | name: release-apk
25 | path: build/app/outputs/apk/release/app-release.apk
26 |
--------------------------------------------------------------------------------
/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 = tabnews
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = dev.progmar.tabnews
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2022 dev.progmar. All rights reserved.
15 |
--------------------------------------------------------------------------------
/lib/src/preferences.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async' show Future;
2 | import 'package:shared_preferences/shared_preferences.dart';
3 |
4 | class Preferences {
5 | static late final SharedPreferences _instance;
6 |
7 | static Future init() async =>
8 | _instance = await SharedPreferences.getInstance();
9 |
10 | static bool? getBool(String key) => _instance.getBool(key);
11 | static Future setBool(String key, bool value) =>
12 | _instance.setBool(key, value);
13 |
14 | static String? getString(String key) => _instance.getString(key);
15 | static Future setString(String key, String value) =>
16 | _instance.setString(key, value);
17 | }
18 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.1.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/lib/src/models/auth.dart:
--------------------------------------------------------------------------------
1 | class Auth {
2 | String? id;
3 | String? token;
4 | String? expiresAt;
5 | String? createdAt;
6 | String? updatedAt;
7 |
8 | Auth({
9 | this.id,
10 | this.token,
11 | this.expiresAt,
12 | this.createdAt,
13 | this.updatedAt,
14 | });
15 |
16 | Auth.fromJson(Map json) {
17 | id = json['id'];
18 | token = json['token'];
19 | expiresAt = json['expires_at'];
20 | createdAt = json['created_at'];
21 | updatedAt = json['updated_at'];
22 | }
23 |
24 | Map toJson() {
25 | final Map data = {};
26 | data['id'] = id;
27 | data['token'] = token;
28 | data['expires_at'] = expiresAt;
29 | data['created_at'] = createdAt;
30 | data['updated_at'] = updatedAt;
31 | return data;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | url_launcher_linux
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | url_launcher_windows
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | **/doc/api/
26 | **/ios/Flutter/.last_build_id
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .packages
31 | .pub-cache/
32 | .pub/
33 | /build/
34 |
35 | # Symbolication related
36 | app.*.symbols
37 |
38 | # Obfuscation related
39 | app.*.map.json
40 |
41 | # Android Studio will place build artifacts here
42 | /android/app/debug
43 | /android/app/profile
44 | /android/app/release
45 |
--------------------------------------------------------------------------------
/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 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Flutter (1.0.0)
3 | - shared_preferences_ios (0.0.1):
4 | - Flutter
5 | - url_launcher_ios (0.0.1):
6 | - Flutter
7 |
8 | DEPENDENCIES:
9 | - Flutter (from `Flutter`)
10 | - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
11 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
12 |
13 | EXTERNAL SOURCES:
14 | Flutter:
15 | :path: Flutter
16 | shared_preferences_ios:
17 | :path: ".symlinks/plugins/shared_preferences_ios/ios"
18 | url_launcher_ios:
19 | :path: ".symlinks/plugins/url_launcher_ios/ios"
20 |
21 | SPEC CHECKSUMS:
22 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
23 | shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
24 | url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
25 |
26 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
27 |
28 | COCOAPODS: 1.11.3
29 |
--------------------------------------------------------------------------------
/lib/src/enviroment_vars.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/foundation.dart';
2 | import 'package:flutter_dotenv/flutter_dotenv.dart';
3 |
4 | class EnviromentVars {
5 | static late EnviromentVars _singleton;
6 | static EnviromentVars get getVars => _singleton;
7 |
8 | late final String _webserver;
9 | String get webserver => _webserver;
10 |
11 | late final bool _debugEnv;
12 | bool get debugEnv => _debugEnv;
13 |
14 | static Future init({bool useProdEnv = false}) async {
15 | bool devEnviroment = kDebugMode && !useProdEnv;
16 | dotenv = DotEnv();
17 |
18 | if (devEnviroment) {
19 | await dotenv.load(fileName: ".env.dev");
20 | } else {
21 | await dotenv.load(fileName: ".env.prod");
22 | }
23 |
24 | _singleton = EnviromentVars();
25 | _singleton._webserver =
26 | dotenv.get("WEBSERVER_HOST", fallback: "www.tabnews.com.br");
27 | _singleton._debugEnv = devEnviroment;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/top_bar.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_svg/flutter_svg.dart';
3 |
4 | import 'package:tabnews/src/constants.dart';
5 |
6 | class AppTopBar extends StatelessWidget with PreferredSizeWidget {
7 | final List? actions;
8 |
9 | const AppTopBar({super.key, this.actions});
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return AppBar(
14 | centerTitle: false,
15 | title: Row(
16 | children: [
17 | SvgPicture.asset(
18 | 'lib/assets/logo.svg',
19 | semanticsLabel: 'TabNews',
20 | ),
21 | const SizedBox(width: 10.0),
22 | const Text('TabNews'),
23 | ],
24 | ),
25 | elevation: 0,
26 | backgroundColor: AppColors.primaryColor,
27 | actions: actions,
28 | );
29 | }
30 |
31 | @override
32 | Size get preferredSize => AppBar().preferredSize;
33 | }
34 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/tabcoins.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class Tabcoins extends StatefulWidget {
4 | final String tabcoins;
5 | final void Function() upvote;
6 | final void Function() downvote;
7 |
8 | const Tabcoins({
9 | super.key,
10 | required this.tabcoins,
11 | required this.upvote,
12 | required this.downvote,
13 | });
14 |
15 | @override
16 | State createState() => _TabcoinsState();
17 | }
18 |
19 | class _TabcoinsState extends State {
20 | @override
21 | Widget build(BuildContext context) {
22 | return Row(
23 | children: [
24 | IconButton(
25 | onPressed: widget.upvote,
26 | icon: const Icon(Icons.expand_less),
27 | ),
28 | Text(widget.tabcoins),
29 | IconButton(
30 | onPressed: widget.downvote,
31 | icon: const Icon(Icons.expand_more),
32 | ),
33 | ],
34 | );
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/lib/src/ui/layouts/page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/extensions/dark_mode.dart';
4 | import 'package:tabnews/src/ui/widgets/progress_indicator.dart';
5 | import 'package:tabnews/src/ui/widgets/top_bar.dart';
6 |
7 | class PageLayout extends StatelessWidget {
8 | final Widget body;
9 | final bool isLoading;
10 | final Future Function() onRefresh;
11 | final List? actions;
12 |
13 | const PageLayout({
14 | super.key,
15 | required this.body,
16 | required this.onRefresh,
17 | this.isLoading = false,
18 | this.actions,
19 | });
20 |
21 | @override
22 | Widget build(BuildContext context) {
23 | return Scaffold(
24 | appBar: AppTopBar(actions: actions),
25 | body: RefreshIndicator(
26 | color: context.isDarkMode ? Colors.white : Colors.black,
27 | onRefresh: onRefresh,
28 | child: isLoading ? const AppProgressIndicator() : body,
29 | ),
30 | );
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tabnews",
3 | "short_name": "tabnews",
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 | "src": "icons/Icon-maskable-192.png",
24 | "sizes": "192x192",
25 | "type": "image/png",
26 | "purpose": "maskable"
27 | },
28 | {
29 | "src": "icons/Icon-maskable-512.png",
30 | "sizes": "512x512",
31 | "type": "image/png",
32 | "purpose": "maskable"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/source_url.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/utils/open_link.dart';
4 |
5 | class SourceUrl extends StatelessWidget {
6 | final String sourceUrl;
7 |
8 | const SourceUrl({super.key, required this.sourceUrl});
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | return Row(
13 | children: [
14 | Text(
15 | 'Fonte: ',
16 | style: const TextStyle().copyWith(
17 | fontWeight: FontWeight.w700,
18 | ),
19 | ),
20 | Expanded(
21 | child: InkWell(
22 | onTap: () => OpenLink.open(
23 | sourceUrl,
24 | context,
25 | ),
26 | child: Text(
27 | sourceUrl,
28 | overflow: TextOverflow.ellipsis,
29 | style: const TextStyle().copyWith(
30 | color: Colors.blue,
31 | fontWeight: FontWeight.w700,
32 | ),
33 | ),
34 | ),
35 | ),
36 | ],
37 | );
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/markdown.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_markdown/flutter_markdown.dart';
3 | import 'package:markdown/markdown.dart' as md;
4 |
5 | import 'package:tabnews/src/utils/open_link.dart';
6 |
7 | class MarkedownReader extends StatelessWidget {
8 | final String body;
9 | final ScrollController? controller;
10 |
11 | const MarkedownReader({
12 | super.key,
13 | required this.body,
14 | this.controller,
15 | });
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | return Markdown(
20 | padding: const EdgeInsets.symmetric(
21 | vertical: 15.0,
22 | horizontal: 0.0,
23 | ),
24 | shrinkWrap: true,
25 | controller: controller,
26 | data: body,
27 | selectable: true,
28 | onTapLink: (text, href, title) {
29 | OpenLink.open(href, context);
30 | },
31 | extensionSet: md.ExtensionSet(
32 | md.ExtensionSet.gitHubWeb.blockSyntaxes,
33 | [
34 | ...md.ExtensionSet.gitHubWeb.inlineSyntaxes,
35 | ],
36 | ),
37 | );
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Marcelo Pecin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/lib/src/utils/open_link.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:url_launcher/url_launcher.dart';
3 |
4 | import 'package:tabnews/src/ui/pages/content.dart';
5 | import 'package:tabnews/src/utils/navigation.dart';
6 |
7 | abstract class OpenLink {
8 | static void open(String? href, BuildContext context) {
9 | if (href != null) {
10 | Uri uri = Uri.parse(href);
11 |
12 | if (_isTabNews(uri) && uri.pathSegments.length > 1) {
13 | _launchInApp(uri, context);
14 | } else {
15 | _launchExternal(uri);
16 | }
17 | }
18 | }
19 |
20 | static bool _isTabNews(Uri uri) {
21 | return uri.host == 'www.tabnews.com.br';
22 | }
23 |
24 | static void _launchExternal(Uri uri) async {
25 | if (await canLaunchUrl(uri)) {
26 | launchUrl(uri, mode: LaunchMode.externalApplication);
27 | }
28 | }
29 |
30 | static void _launchInApp(Uri uri, BuildContext context) {
31 | List segments = uri.pathSegments;
32 |
33 | String username = segments[0];
34 | String slug = segments[1];
35 |
36 | Navigation.push(context, ContentPage(username: username, slug: slug));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/src/app.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/constants.dart';
4 | import 'package:tabnews/src/ui/layouts/tab.dart';
5 |
6 | class App extends StatelessWidget {
7 | const App({super.key});
8 |
9 | @override
10 | Widget build(BuildContext context) {
11 | return MaterialApp(
12 | title: 'TabNews',
13 | debugShowCheckedModeBanner: false,
14 | darkTheme: ThemeData.dark().copyWith(
15 | primaryColor: Colors.white,
16 | colorScheme: const ColorScheme.light(
17 | primary: Colors.white60,
18 | secondary: Colors.white60,
19 | ),
20 | textSelectionTheme: TextSelectionThemeData(
21 | selectionColor: Colors.grey.shade700,
22 | ),
23 | ),
24 | theme: ThemeData(
25 | primaryColor: Colors.black,
26 | colorScheme: const ColorScheme.light(
27 | primary: AppColors.primaryColor,
28 | secondary: AppColors.primaryColor,
29 | ),
30 | textSelectionTheme: TextSelectionThemeData(
31 | selectionColor: Colors.grey.shade300,
32 | ),
33 | ),
34 | home: const TabLayout(),
35 | );
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/src/services/http_response.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | class HttpResponse {
4 | bool ok = false;
5 | String message = "";
6 | T? data;
7 | final int _statusCode;
8 | final String _body;
9 |
10 | HttpResponse(
11 | this._statusCode,
12 | this._body,
13 | ) {
14 | _verifyStatus();
15 | }
16 |
17 | void _verifyStatus() {
18 | switch (_statusCode) {
19 | case 200:
20 | case 201:
21 | ok = true;
22 | break;
23 | case 204:
24 | ok = true;
25 | break;
26 | case 400:
27 | break;
28 | case 401:
29 | break;
30 | case 404:
31 | break;
32 | case 500:
33 | message = "Sem conexão com servidor";
34 | break;
35 | default:
36 | message = "Erro inesperado";
37 | }
38 |
39 | _setResponse();
40 | }
41 |
42 | void _setResponse() {
43 | if (ok) {
44 | if (_body.isNotEmpty) {
45 | T response = jsonDecode(_body);
46 | data = response;
47 | }
48 | } else {
49 | if (message.isEmpty) {
50 | dynamic response = jsonDecode(_body);
51 |
52 | message = response['message'];
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/lib/src/controllers/comment.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/controllers/app.dart';
4 | import 'package:tabnews/src/interfaces/view_action.dart';
5 | import 'package:tabnews/src/services/content.dart';
6 | import 'package:tabnews/src/services/http_response.dart';
7 |
8 | class CommentController {
9 | final ViewAction _view;
10 | final ContentService _contentService = ContentService();
11 |
12 | final ValueNotifier _isLoading = ValueNotifier(false);
13 | ValueNotifier get isLoading => _isLoading;
14 |
15 | CommentController(this._view);
16 |
17 | void create(String body, String parentId) async {
18 | if (body.isEmpty) {
19 | _view.onError(message: 'É necessário preencher o campo obrigatório!');
20 |
21 | return;
22 | }
23 |
24 | _setLoading(true);
25 | final HttpResponse content = await _contentService.postComment(
26 | AppController.auth.value,
27 | parentId,
28 | body,
29 | );
30 |
31 | if (content.ok) {
32 | _view.onSuccess();
33 | } else {
34 | _view.onError(message: content.message);
35 | }
36 |
37 | _setLoading(false);
38 | }
39 |
40 | void _setLoading(bool value) {
41 | _isLoading.value = value;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/favorites.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/controllers/favorites.dart';
4 | import 'package:tabnews/src/ui/widgets/item_content.dart';
5 |
6 | class FavoritesPage extends StatefulWidget {
7 | const FavoritesPage({super.key});
8 |
9 | @override
10 | State createState() => _FavoritesPageState();
11 | }
12 |
13 | class _FavoritesPageState extends State {
14 | final FavoritesController _favoritesController = FavoritesController();
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return ValueListenableBuilder(
19 | valueListenable: _favoritesController.favorites,
20 | builder: (context, favorites, child) {
21 | if (favorites.isEmpty) {
22 | return const Center(
23 | child: Text('Você não possui favoritos!'),
24 | );
25 | } else {
26 | return ListView.builder(
27 | padding: const EdgeInsets.all(10.0),
28 | itemCount: favorites.length,
29 | itemBuilder: (context, index) {
30 | return ItemContent(
31 | content: favorites[index],
32 | );
33 | },
34 | );
35 | }
36 | },
37 | );
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lib/src/models/user.dart:
--------------------------------------------------------------------------------
1 | class User {
2 | String? id;
3 | String? username;
4 | String? email;
5 | bool? notifications;
6 | List? features;
7 | int? tabcoins;
8 | int? tabcash;
9 | String? createdAt;
10 | String? updatedAt;
11 |
12 | User({
13 | this.id,
14 | this.username,
15 | this.email,
16 | this.notifications,
17 | this.features,
18 | this.tabcoins,
19 | this.tabcash,
20 | this.createdAt,
21 | this.updatedAt,
22 | });
23 |
24 | User.fromJson(Map json) {
25 | id = json['id'];
26 | username = json['username'];
27 | email = json['email'];
28 | notifications = json['notifications'];
29 | features = json['features'].cast();
30 | tabcoins = json['tabcoins'];
31 | tabcash = json['tabcash'];
32 | createdAt = json['created_at'];
33 | updatedAt = json['updated_at'];
34 | }
35 |
36 | Map toJson() {
37 | final Map data = {};
38 | data['id'] = id;
39 | data['username'] = username;
40 | data['email'] = email;
41 | data['notifications'] = notifications;
42 | data['features'] = features;
43 | data['tabcoins'] = tabcoins;
44 | data['tabcash'] = tabcash;
45 | data['created_at'] = createdAt;
46 | data['updated_at'] = updatedAt;
47 | return data;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/comments_children.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:timeago/timeago.dart' as timeago;
3 |
4 | import 'package:tabnews/src/models/comment.dart';
5 | import 'package:tabnews/src/services/content.dart';
6 | import 'package:tabnews/src/ui/widgets/item_comment.dart';
7 |
8 | class CommentsWidget extends StatefulWidget {
9 | final List comments;
10 | final ScrollController controller;
11 | final void Function() onAnswer;
12 |
13 | const CommentsWidget({
14 | super.key,
15 | required this.comments,
16 | required this.controller,
17 | required this.onAnswer,
18 | });
19 |
20 | @override
21 | State createState() => _CommentsWidgetState();
22 | }
23 |
24 | class _CommentsWidgetState extends State {
25 | final api = ContentService();
26 |
27 | @override
28 | Widget build(BuildContext context) {
29 | timeago.setLocaleMessages('pt-BR', timeago.PtBrMessages());
30 |
31 | return ListView.separated(
32 | shrinkWrap: true,
33 | controller: widget.controller,
34 | itemCount: widget.comments.length,
35 | separatorBuilder: (context, index) => const Divider(),
36 | itemBuilder: (context, index) => ItemComment(
37 | comment: widget.comments[index],
38 | controller: widget.controller,
39 | onAnswer: widget.onAnswer,
40 | ),
41 | );
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(1280, 720);
30 | if (!window.CreateAndShow(L"tabnews", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '11.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | end
36 |
37 | post_install do |installer|
38 | installer.pods_project.targets.each do |target|
39 | flutter_additional_ios_build_settings(target)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/bottom_bar.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:tabnews/src/constants.dart';
5 |
6 | class AppBottomBar extends StatelessWidget {
7 | final int currentPage;
8 | final void Function(int) onTap;
9 |
10 | const AppBottomBar({
11 | super.key,
12 | required this.onTap,
13 | required this.currentPage,
14 | });
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return ClipRect(
19 | child: BackdropFilter(
20 | filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
21 | child: BottomNavigationBar(
22 | currentIndex: currentPage,
23 | selectedItemColor: Colors.white,
24 | unselectedItemColor: Colors.grey.shade400,
25 | type: BottomNavigationBarType.fixed,
26 | backgroundColor: AppColors.primaryColor,
27 | showSelectedLabels: false,
28 | showUnselectedLabels: false,
29 | onTap: onTap,
30 | items: const [
31 | BottomNavigationBarItem(
32 | icon: Icon(Icons.home),
33 | label: 'Home',
34 | ),
35 | BottomNavigationBarItem(
36 | icon: Icon(Icons.feed),
37 | label: 'Recentes',
38 | ),
39 | BottomNavigationBarItem(
40 | icon: Icon(Icons.favorite),
41 | label: 'Favoritos',
42 | ),
43 | BottomNavigationBarItem(
44 | icon: Icon(Icons.account_circle),
45 | label: 'Perfil',
46 | ),
47 | ],
48 | ),
49 | ),
50 | );
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/lib/src/controllers/app.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:tabnews/src/constants.dart';
5 | import 'package:tabnews/src/models/user.dart';
6 | import 'package:tabnews/src/preferences.dart';
7 | import 'package:tabnews/src/services/auth.dart';
8 |
9 | class AppController {
10 | static final AppController _singleton = AppController._internal();
11 |
12 | static final AuthService _authService = AuthService();
13 |
14 | factory AppController() {
15 | return _singleton;
16 | }
17 |
18 | AppController._internal();
19 |
20 | static const String _loggedKey = AppConstants.loggedInKey;
21 | static const String _authKey = AppConstants.authKey;
22 | static const String _userKey = AppConstants.userKey;
23 |
24 | static ValueNotifier isLoggedIn = ValueNotifier(
25 | Preferences.getBool(AppController._loggedKey) ?? false,
26 | );
27 | static ValueNotifier auth = ValueNotifier(
28 | Preferences.getString(AppController._authKey) ?? '',
29 | );
30 | static ValueNotifier user = ValueNotifier(
31 | AppController._getLoggedUser(),
32 | );
33 |
34 | static User _getLoggedUser() {
35 | String pref = Preferences.getString(_userKey) ?? '';
36 |
37 | if (pref.isNotEmpty) {
38 | User user = User.fromJson(jsonDecode(pref));
39 |
40 | return user;
41 | }
42 |
43 | return User.fromJson({});
44 | }
45 |
46 | static void updateUser() async {
47 | var userRefresh = await _authService.fetchUser(auth.value);
48 |
49 | Preferences.setString(_userKey, jsonEncode(userRefresh.data));
50 | user.value = _getLoggedUser();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/use_terms.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:tabnews/src/ui/widgets/markdown.dart';
3 | import 'package:tabnews/src/ui/widgets/top_bar.dart';
4 |
5 | class UseTermsPage extends StatelessWidget {
6 | final ScrollController _scrollController = ScrollController();
7 |
8 | UseTermsPage({super.key});
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | return Scaffold(
13 | appBar: const AppTopBar(),
14 | body: SingleChildScrollView(
15 | controller: _scrollController,
16 | padding: const EdgeInsets.all(15),
17 | child: Column(
18 | children: [
19 | const Text(
20 | 'Termos de Uso',
21 | style: TextStyle(
22 | fontSize: 24,
23 | fontWeight: FontWeight.w700,
24 | ),
25 | ),
26 | const Divider(height: 50),
27 | MarkedownReader(
28 | controller: _scrollController,
29 | body:
30 | '''O Aplicativo TabNews, é um projeto desenvolvido pela comunidade open-source, **e não é um client oficial** da plataforma TabNews.
31 | A marca **TabNews**, junto com o serviço e o domínio **tabnews.com.br** são propriedades intelectuais de uma empresa que temos localizada no Canadá chamada **Filipe Deschamps Tech Inc.**
32 | ---
33 | Lembrando que todos os termos de uso contidos na plataforma TabNews, ainda valem quando você utiliza o Appi para postagem de conteúdos.
34 | ---
35 | https://www.tabnews.com.br/termos-de-uso''',
36 | ),
37 | ],
38 | ),
39 | ),
40 | );
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/comments.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:timeago/timeago.dart' as timeago;
3 |
4 | import 'package:tabnews/src/models/comment.dart';
5 | import 'package:tabnews/src/services/content.dart';
6 | import 'package:tabnews/src/ui/widgets/item_comment.dart';
7 |
8 | class CommentsRootWidget extends StatefulWidget {
9 | final String slug;
10 | final ScrollController controller;
11 |
12 | const CommentsRootWidget({
13 | super.key,
14 | required this.slug,
15 | required this.controller,
16 | });
17 |
18 | @override
19 | State createState() => _CommentsRootWidgetState();
20 | }
21 |
22 | class _CommentsRootWidgetState extends State {
23 | List comments = [];
24 | final api = ContentService();
25 |
26 | Key _refreshKey = UniqueKey();
27 |
28 | @override
29 | void initState() {
30 | super.initState();
31 |
32 | _getComments();
33 | }
34 |
35 | Future _getComments() async {
36 | var comment = await api.fetchContentComments(widget.slug);
37 |
38 | setState(() {
39 | comments = comment;
40 | });
41 | }
42 |
43 | void _onAnswer() {
44 | setState(() {
45 | _refreshKey = UniqueKey();
46 | });
47 | }
48 |
49 | @override
50 | Widget build(BuildContext context) {
51 | timeago.setLocaleMessages('pt-BR', timeago.PtBrMessages());
52 |
53 | return ListView.separated(
54 | controller: widget.controller,
55 | itemCount: comments.length,
56 | separatorBuilder: (context, index) => const Divider(),
57 | itemBuilder: (context, index) => ItemComment(
58 | key: _refreshKey,
59 | comment: comments[index],
60 | controller: widget.controller,
61 | onAnswer: _onAnswer,
62 | ),
63 | );
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/.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.
5 |
6 | version:
7 | revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
8 | channel: stable
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
17 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
18 | - platform: android
19 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
20 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
21 | - platform: ios
22 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
23 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
24 | - platform: linux
25 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
26 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
27 | - platform: macos
28 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
29 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
30 | - platform: web
31 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
32 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
33 | - platform: windows
34 | create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
35 | base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
36 |
37 | # User provided section
38 |
39 | # List of Local paths (relative to this file) that should be
40 | # ignored by the migrate tool.
41 | #
42 | # Files that are not part of the templates will be ignored by default.
43 | unmanaged_files:
44 | - 'lib/main.dart'
45 | - 'ios/Runner.xcodeproj/project.pbxproj'
46 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
10 |
18 |
22 |
26 |
27 |
28 |
29 |
30 |
31 |
33 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | # Define the application target. To change its name, change BINARY_NAME in the
5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6 | # work.
7 | #
8 | # Any new source files that you add to the application should be added here.
9 | add_executable(${BINARY_NAME} WIN32
10 | "flutter_window.cpp"
11 | "main.cpp"
12 | "utils.cpp"
13 | "win32_window.cpp"
14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15 | "Runner.rc"
16 | "runner.exe.manifest"
17 | )
18 |
19 | # Apply the standard set of build settings. This can be removed for applications
20 | # that need different build settings.
21 | apply_standard_settings(${BINARY_NAME})
22 |
23 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
37 |
38 | # Run the Flutter tool portions of the build. This must not be removed.
39 | add_dependencies(${BINARY_NAME} flutter_assemble)
40 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Tabnews
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | tabnews
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 | CADisableMinimumFrameDurationOnPhone
47 |
48 | UIApplicationSupportsIndirectInputEvents
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/lib/src/utils/navigation.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | abstract class Navigation {
4 | static push(
5 | BuildContext context,
6 | Widget page,
7 | ) {
8 | Navigator.push(
9 | context,
10 | MaterialPageRoute(builder: (_) => page),
11 | );
12 | }
13 |
14 | static pushModal(
15 | BuildContext context,
16 | Widget page,
17 | ) {
18 | Navigator.push(
19 | context,
20 | MaterialPageRoute(
21 | fullscreenDialog: true,
22 | builder: (_) => page,
23 | ),
24 | );
25 | }
26 |
27 | static pushReplacement(
28 | BuildContext context,
29 | Widget page,
30 | ) {
31 | Navigator.pushReplacement(
32 | context,
33 | MaterialPageRoute(builder: (_) => page),
34 | );
35 | }
36 |
37 | static pushReplacementModal(
38 | BuildContext context,
39 | Widget page,
40 | ) {
41 | Navigator.pushReplacement(
42 | context,
43 | MaterialPageRoute(
44 | fullscreenDialog: true,
45 | builder: (_) => page,
46 | ),
47 | );
48 | }
49 |
50 | static pushAndRemoveUntil(
51 | BuildContext context,
52 | Widget page,
53 | Function predicate,
54 | ) {
55 | Navigator.pushAndRemoveUntil(
56 | context,
57 | MaterialPageRoute(builder: (_) => page),
58 | (route) => false,
59 | );
60 | }
61 |
62 | static pushAndRemoveUntilModal(
63 | BuildContext context,
64 | Widget page,
65 | Function predicate,
66 | ) {
67 | Navigator.pushAndRemoveUntil(
68 | context,
69 | MaterialPageRoute(
70 | fullscreenDialog: true,
71 | builder: (_) => page,
72 | ),
73 | (route) => false,
74 | );
75 | }
76 |
77 | static pop(BuildContext context) {
78 | Navigator.pop(context);
79 | }
80 |
81 | static popUntil(BuildContext context) {
82 | Navigator.popUntil(
83 | context,
84 | (route) => route.isFirst,
85 | );
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | std::string utf8_string;
52 | if (target_length == 0 || target_length > utf8_string.max_size()) {
53 | return utf8_string;
54 | }
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/lib/src/controllers/favorites.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | import 'package:tabnews/src/models/content.dart';
6 | import 'package:tabnews/src/preferences.dart';
7 |
8 | class FavoritesController {
9 | static final FavoritesController _singleton = FavoritesController._internal();
10 |
11 | factory FavoritesController() {
12 | return _singleton;
13 | }
14 |
15 | FavoritesController._internal();
16 |
17 | final ValueNotifier _isLoading = ValueNotifier(false);
18 | ValueNotifier get isLoading => _isLoading;
19 |
20 | final ValueNotifier> _favorites = ValueNotifier(
21 | FavoritesController._getSavedFavorites(),
22 | );
23 | ValueNotifier> get favorites => _favorites;
24 |
25 | static List _getSavedFavorites() {
26 | String pref = Preferences.getString('favorites') ?? '';
27 |
28 | if (pref.isNotEmpty) {
29 | List contents = jsonDecode(pref);
30 |
31 | return contents.map((e) => Content.fromJson(e)).toList();
32 | }
33 |
34 | return [];
35 | }
36 |
37 | void toggle(Content content) async {
38 | _setLoading(true);
39 | Content copyContent = content;
40 |
41 | if (_favorites.value.isNotEmpty) {
42 | if (_favorites.value
43 | .where((element) => element.id == content.id)
44 | .isNotEmpty) {
45 | _favorites.value = List.from(_favorites.value)
46 | ..removeWhere((element) => element.id == content.id);
47 | } else {
48 | copyContent.body = null;
49 | _favorites.value = List.from(_favorites.value)..add(copyContent);
50 | }
51 | } else {
52 | copyContent.body = null;
53 | _favorites.value = List.from(_favorites.value)..add(copyContent);
54 | }
55 |
56 | Preferences.setString('favorites', jsonEncode(_favorites.value));
57 |
58 | _setLoading(false);
59 | }
60 |
61 | void _setLoading(bool value) {
62 | _isLoading.value = value;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 | return true;
30 | }
31 |
32 | void FlutterWindow::OnDestroy() {
33 | if (flutter_controller_) {
34 | flutter_controller_ = nullptr;
35 | }
36 |
37 | Win32Window::OnDestroy();
38 | }
39 |
40 | LRESULT
41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
42 | WPARAM const wparam,
43 | LPARAM const lparam) noexcept {
44 | // Give Flutter, including plugins, an opportunity to handle window messages.
45 | if (flutter_controller_) {
46 | std::optional result =
47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
48 | lparam);
49 | if (result) {
50 | return *result;
51 | }
52 | }
53 |
54 | switch (message) {
55 | case WM_FONTCHANGE:
56 | flutter_controller_->engine()->ReloadSystemFonts();
57 | break;
58 | }
59 |
60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
61 | }
62 |
--------------------------------------------------------------------------------
/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | tabnews
33 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/lib/src/controllers/content.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/controllers/app.dart';
4 | import 'package:tabnews/src/interfaces/view_action.dart';
5 | import 'package:tabnews/src/models/content.dart';
6 | import 'package:tabnews/src/services/content.dart';
7 | import 'package:tabnews/src/services/http_response.dart';
8 |
9 | class ContentController {
10 | final ViewAction _view;
11 | final ContentService _contentService = ContentService();
12 |
13 | final ValueNotifier _isLoading = ValueNotifier(false);
14 | ValueNotifier get isLoading => _isLoading;
15 |
16 | ContentController(this._view);
17 |
18 | void create(String title, String body, String source) async {
19 | if (title.isEmpty || body.isEmpty) {
20 | _view.onError(message: 'É necessário preencher os campos obrigatórios!');
21 |
22 | return;
23 | }
24 |
25 | _setLoading(true);
26 | final HttpResponse content = await _contentService.postContent(
27 | AppController.auth.value,
28 | title,
29 | body,
30 | source,
31 | );
32 |
33 | if (content.ok) {
34 | _view.onSuccess();
35 | } else {
36 | _view.onError(message: content.message);
37 | }
38 |
39 | _setLoading(false);
40 | }
41 |
42 | void _setLoading(bool value) {
43 | _isLoading.value = value;
44 | }
45 |
46 | void getContent(String slug) async {
47 | _setLoading(true);
48 | var contentResp = await _contentService.fetchContent(slug);
49 |
50 | if (contentResp.ok) {
51 | if (contentResp.data['parent_id'] != null) {
52 | contentResp.data['parent'] = await _getParentContent(slug);
53 | }
54 |
55 | _view.onSuccess(data: contentResp.data);
56 | } else {
57 | _view.onError(message: contentResp.message);
58 | }
59 |
60 | _setLoading(false);
61 | }
62 |
63 | Future _getParentContent(String slug) async {
64 | var parentContent = await _contentService.fetchContentParent(slug);
65 |
66 | if (parentContent.ok) {
67 | return Content.fromJson(parentContent.data);
68 | } else {
69 | return null;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/lib/src/models/content.dart:
--------------------------------------------------------------------------------
1 | class Content {
2 | String? id;
3 | String? ownerId;
4 | String? parentId;
5 | String? slug;
6 | String? title;
7 | String? body;
8 | String? status;
9 | String? sourceUrl;
10 | String? createdAt;
11 | String? updatedAt;
12 | String? publishedAt;
13 | String? deletedAt;
14 | String? ownerUsername;
15 | int? tabcoins;
16 | int? childrenDeepCount;
17 | Content? parent;
18 |
19 | Content({
20 | this.id,
21 | this.ownerId,
22 | this.parentId,
23 | this.slug,
24 | this.title,
25 | this.body,
26 | this.status,
27 | this.sourceUrl,
28 | this.createdAt,
29 | this.updatedAt,
30 | this.publishedAt,
31 | this.deletedAt,
32 | this.ownerUsername,
33 | this.tabcoins,
34 | this.childrenDeepCount,
35 | this.parent,
36 | });
37 |
38 | Content.fromJson(Map json) {
39 | id = json['id'];
40 | ownerId = json['owner_id'];
41 | parentId = json['parent_id'];
42 | slug = json['slug'];
43 | title = json['title'];
44 | body = json['body'];
45 | status = json['status'];
46 | sourceUrl = json['source_url'];
47 | createdAt = json['created_at'];
48 | updatedAt = json['updated_at'];
49 | publishedAt = json['published_at'];
50 | deletedAt = json['deleted_at'];
51 | tabcoins = json['tabcoins'];
52 | ownerUsername = json['owner_username'];
53 | childrenDeepCount = json['children_deep_count'];
54 | parent = json['parent'];
55 | }
56 |
57 | Map toJson() {
58 | final Map data = {};
59 |
60 | data['id'] = id;
61 | data['owner_id'] = ownerId;
62 | data['parent_id'] = parentId;
63 | data['slug'] = slug;
64 | data['title'] = title;
65 | data['body'] = body;
66 | data['status'] = status;
67 | data['source_url'] = sourceUrl;
68 | data['created_at'] = createdAt;
69 | data['updated_at'] = updatedAt;
70 | data['published_at'] = publishedAt;
71 | data['deleted_at'] = deletedAt;
72 | data['tabcoins'] = tabcoins;
73 | data['owner_username'] = ownerUsername;
74 | data['children_deep_count'] = childrenDeepCount;
75 | data['parent'] = parent;
76 |
77 | return data;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/lib/src/controllers/user.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | import 'package:tabnews/src/constants.dart';
6 | import 'package:tabnews/src/controllers/app.dart';
7 | import 'package:tabnews/src/interfaces/view_action.dart';
8 | import 'package:tabnews/src/models/user.dart';
9 | import 'package:tabnews/src/preferences.dart';
10 | import 'package:tabnews/src/services/auth.dart';
11 | import 'package:tabnews/src/services/http_response.dart';
12 |
13 | class UserController {
14 | final ViewAction _view;
15 | final AuthService _authService = AuthService();
16 |
17 | final String _userKey = AppConstants.userKey;
18 |
19 | final ValueNotifier _isLoading = ValueNotifier(false);
20 | ValueNotifier get isLoading => _isLoading;
21 |
22 | final ValueNotifier _notifications = ValueNotifier(
23 | AppController.user.value.notifications ?? true,
24 | );
25 | ValueNotifier get notification => _notifications;
26 |
27 | UserController(this._view);
28 |
29 | void setNotifications(bool? value) {
30 | _notifications.value = value ?? true;
31 | }
32 |
33 | void update(String username, String email) async {
34 | if (username.isEmpty || email.isEmpty) {
35 | _view.onError(message: 'É necessário preencher todos os campos!');
36 |
37 | return;
38 | }
39 |
40 | _setLoading(true);
41 | final HttpResponse user = await _authService.updateUser(
42 | token: AppController.auth.value,
43 | username: AppController.user.value.username,
44 | newUsername:
45 | AppController.user.value.username != username ? username : '',
46 | newEmail: AppController.user.value.email != email ? email : '',
47 | newNotifications: _notifications.value,
48 | );
49 |
50 | if (user.ok) {
51 | var user = await _authService.fetchUser(AppController.auth.value);
52 |
53 | Preferences.setString(_userKey, jsonEncode(user.data));
54 |
55 | _setUser(User.fromJson(user.data));
56 |
57 | _view.onSuccess();
58 | } else {
59 | _view.onError(message: user.message);
60 | }
61 |
62 | _setLoading(false);
63 | }
64 |
65 | void _setLoading(bool value) {
66 | _isLoading.value = value;
67 | }
68 |
69 | void _setUser(User value) {
70 | AppController.user.value = value;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/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 flutter.compileSdkVersion
30 | ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47 | applicationId "dev.progmar.tabnews"
48 | // You can update the following values to match your application needs.
49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
50 | minSdkVersion flutter.minSdkVersion
51 | targetSdkVersion flutter.targetSdkVersion
52 | versionCode flutterVersionCode.toInteger()
53 | versionName flutterVersionName
54 | }
55 |
56 | buildTypes {
57 | release {
58 | // TODO: Add your own signing config for the release build.
59 | // Signing with the debug keys for now, so `flutter run --release` works.
60 | signingConfig signingConfigs.debug
61 | }
62 | }
63 | }
64 |
65 | flutter {
66 | source '../..'
67 | }
68 |
69 | dependencies {
70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71 | }
72 |
--------------------------------------------------------------------------------
/lib/src/models/comment.dart:
--------------------------------------------------------------------------------
1 | class Comment {
2 | String? id;
3 | String? ownerId;
4 | String? parentId;
5 | String? slug;
6 | String? title;
7 | String? body;
8 | String? status;
9 | String? sourceUrl;
10 | String? createdAt;
11 | String? updatedAt;
12 | String? publishedAt;
13 | String? deletedAt;
14 | String? ownerUsername;
15 | int? tabcoins;
16 | List? children;
17 | int? childrenDeepCount;
18 |
19 | Comment({
20 | this.id,
21 | this.ownerId,
22 | this.parentId,
23 | this.slug,
24 | this.title,
25 | this.body,
26 | this.status,
27 | this.sourceUrl,
28 | this.createdAt,
29 | this.updatedAt,
30 | this.publishedAt,
31 | this.deletedAt,
32 | this.ownerUsername,
33 | this.tabcoins,
34 | this.children,
35 | this.childrenDeepCount,
36 | });
37 |
38 | Comment.fromJson(Map json) {
39 | id = json['id'];
40 | ownerId = json['owner_id'];
41 | parentId = json['parent_id'];
42 | slug = json['slug'];
43 | title = json['title'];
44 | body = json['body'];
45 | status = json['status'];
46 | sourceUrl = json['source_url'];
47 | createdAt = json['created_at'];
48 | updatedAt = json['updated_at'];
49 | publishedAt = json['published_at'];
50 | deletedAt = json['deleted_at'];
51 | ownerUsername = json['owner_username'];
52 | tabcoins = json['tabcoins'];
53 |
54 | if (json['children'] != null) {
55 | children = [];
56 | json['children'].forEach((v) {
57 | children!.add(Comment.fromJson(v));
58 | });
59 | }
60 |
61 | childrenDeepCount = json['children_deep_count'];
62 | }
63 |
64 | Map toJson() {
65 | final Map data = {};
66 | data['id'] = id;
67 | data['owner_id'] = ownerId;
68 | data['parent_id'] = parentId;
69 | data['slug'] = slug;
70 | data['title'] = title;
71 | data['body'] = body;
72 | data['status'] = status;
73 | data['source_url'] = sourceUrl;
74 | data['created_at'] = createdAt;
75 | data['updated_at'] = updatedAt;
76 | data['published_at'] = publishedAt;
77 | data['deleted_at'] = deletedAt;
78 | data['owner_username'] = ownerUsername;
79 | data['tabcoins'] = tabcoins;
80 |
81 | if (children != null) {
82 | data['children'] = children!.map((v) => v.toJson()).toList();
83 | }
84 |
85 | data['children_deep_count'] = childrenDeepCount;
86 |
87 | return data;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/lib/src/services/auth.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:http/http.dart' as http;
3 | import 'package:tabnews/src/enviroment_vars.dart';
4 |
5 | import 'package:tabnews/src/services/http_response.dart';
6 |
7 | class AuthService {
8 | String get apiUrl => '${EnviromentVars.getVars.webserver}/api/v1';
9 |
10 | Future postLogin(String email, String password) async {
11 | final response = await http.post(
12 | Uri.parse('$apiUrl/sessions'),
13 | headers: {
14 | 'Content-Type': 'application/json; charset=UTF-8',
15 | },
16 | body: jsonEncode({
17 | 'email': email,
18 | 'password': password,
19 | }),
20 | );
21 |
22 | return HttpResponse(response.statusCode, response.body);
23 | }
24 |
25 | Future fetchUser(String token) async {
26 | final response = await http.get(
27 | Uri.parse('$apiUrl/user'),
28 | headers: {
29 | 'Set-Cookie': 'session_id=$token',
30 | 'Cookie': 'session_id=$token',
31 | 'Content-Type': 'application/json; charset=UTF-8',
32 | },
33 | );
34 |
35 | return HttpResponse(response.statusCode, response.body);
36 | }
37 |
38 | Future updateUser({
39 | required String token,
40 | required String? username,
41 | required String newUsername,
42 | required String newEmail,
43 | required bool? newNotifications,
44 | }) async {
45 | final response = await http.patch(
46 | Uri.parse('$apiUrl/users/$username'),
47 | headers: {
48 | 'Set-Cookie': 'session_id=$token',
49 | 'Cookie': 'session_id=$token',
50 | 'Content-Type': 'application/json; charset=UTF-8',
51 | },
52 | body: jsonEncode({
53 | newUsername.isNotEmpty ? 'username' : newUsername: null,
54 | newEmail.isNotEmpty ? 'email' : newEmail: null,
55 | 'notifications': newNotifications,
56 | }),
57 | );
58 |
59 | return HttpResponse(response.statusCode, response.body);
60 | }
61 |
62 | Future postRegister(
63 | String username,
64 | String email,
65 | String password,
66 | ) async {
67 | final response = await http.post(
68 | Uri.parse('$apiUrl/users'),
69 | headers: {
70 | 'Content-Type': 'application/json; charset=UTF-8',
71 | },
72 | body: jsonEncode({
73 | 'username': username,
74 | 'email': email,
75 | 'password': password,
76 | }),
77 | );
78 |
79 | return HttpResponse(response.statusCode, response.body);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/home.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
3 |
4 | import 'package:tabnews/src/extensions/dark_mode.dart';
5 | import 'package:tabnews/src/models/content.dart';
6 | import 'package:tabnews/src/services/content.dart';
7 | import 'package:tabnews/src/ui/widgets/item_content.dart';
8 | import 'package:tabnews/src/ui/widgets/progress_indicator.dart';
9 |
10 | class HomePage extends StatefulWidget {
11 | final ScrollController scrollController;
12 |
13 | const HomePage({super.key, required this.scrollController});
14 |
15 | @override
16 | State createState() => _HomePageState();
17 | }
18 |
19 | class _HomePageState extends State {
20 | late List contents;
21 | final _contentService = ContentService();
22 | bool isLoading = true;
23 | static const _perPage = 30;
24 |
25 | final PagingController _pagingController =
26 | PagingController(firstPageKey: 1);
27 |
28 | @override
29 | void initState() {
30 | super.initState();
31 |
32 | _pagingController.addPageRequestListener((pageKey) {
33 | _getContents(pageKey);
34 | });
35 | }
36 |
37 | @override
38 | void dispose() {
39 | _pagingController.dispose();
40 |
41 | super.dispose();
42 | }
43 |
44 | Future _getContents(int page) async {
45 | final content = await _contentService.fetchContents(page: page);
46 |
47 | final isLastPage = content.length < _perPage;
48 |
49 | if (isLastPage) {
50 | _pagingController.appendLastPage(content);
51 | } else {
52 | final nextPage = page + 1;
53 |
54 | _pagingController.appendPage(content, nextPage);
55 | }
56 | }
57 |
58 | @override
59 | Widget build(BuildContext context) {
60 | return RefreshIndicator(
61 | color: context.isDarkMode ? Colors.white : Colors.black,
62 | onRefresh: () => Future.sync(
63 | () => _pagingController.refresh(),
64 | ),
65 | child: PagedListView(
66 | padding: const EdgeInsets.all(10.0),
67 | pagingController: _pagingController,
68 | scrollController: widget.scrollController,
69 | builderDelegate: PagedChildBuilderDelegate(
70 | itemBuilder: (context, item, index) {
71 | return ItemContent(content: item);
72 | },
73 | firstPageProgressIndicatorBuilder: (_) =>
74 | const AppProgressIndicator(),
75 | newPageProgressIndicatorBuilder: (_) => const AppProgressIndicator(),
76 | ),
77 | ),
78 | );
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/my_contents.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
3 |
4 | import 'package:tabnews/src/controllers/app.dart';
5 | import 'package:tabnews/src/models/content.dart';
6 | import 'package:tabnews/src/services/content.dart';
7 | import 'package:tabnews/src/ui/layouts/page.dart';
8 | import 'package:tabnews/src/ui/widgets/item_content.dart';
9 | import 'package:tabnews/src/ui/widgets/progress_indicator.dart';
10 |
11 | class MyContentsPage extends StatefulWidget {
12 | const MyContentsPage({super.key});
13 |
14 | @override
15 | State createState() => _MyContentsPageState();
16 | }
17 |
18 | class _MyContentsPageState extends State {
19 | late List contents;
20 | final _contentService = ContentService();
21 | bool isLoading = true;
22 | static const _perPage = 30;
23 |
24 | final PagingController _pagingController =
25 | PagingController(firstPageKey: 1);
26 |
27 | @override
28 | void initState() {
29 | super.initState();
30 |
31 | _pagingController.addPageRequestListener((pageKey) {
32 | _getContents(pageKey);
33 | });
34 | }
35 |
36 | @override
37 | void dispose() {
38 | _pagingController.dispose();
39 |
40 | super.dispose();
41 | }
42 |
43 | Future _getContents(int page) async {
44 | final content = await _contentService.fetchMyContents(
45 | page: page,
46 | user: '${AppController.user.value.username}',
47 | );
48 |
49 | final isLastPage = content.length < _perPage;
50 |
51 | if (isLastPage) {
52 | _pagingController.appendLastPage(content);
53 | } else {
54 | final nextPage = page + 1;
55 |
56 | _pagingController.appendPage(content, nextPage);
57 | }
58 | }
59 |
60 | @override
61 | Widget build(BuildContext context) {
62 | return PageLayout(
63 | onRefresh: () => Future.sync(
64 | () => _pagingController.refresh(),
65 | ),
66 | body: PagedListView(
67 | padding: const EdgeInsets.all(10.0),
68 | pagingController: _pagingController,
69 | builderDelegate: PagedChildBuilderDelegate(
70 | itemBuilder: (context, item, index) {
71 | return ItemContent(
72 | content: item,
73 | );
74 | },
75 | firstPageProgressIndicatorBuilder: (_) =>
76 | const AppProgressIndicator(),
77 | newPageProgressIndicatorBuilder: (_) => const AppProgressIndicator(),
78 | ),
79 | ),
80 | );
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/recents.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
3 |
4 | import 'package:tabnews/src/extensions/dark_mode.dart';
5 | import 'package:tabnews/src/models/content.dart';
6 | import 'package:tabnews/src/services/content.dart';
7 | import 'package:tabnews/src/ui/widgets/item_content.dart';
8 | import 'package:tabnews/src/ui/widgets/progress_indicator.dart';
9 |
10 | class RecentsPage extends StatefulWidget {
11 | final ScrollController scrollController;
12 |
13 | const RecentsPage({super.key, required this.scrollController});
14 |
15 | @override
16 | State createState() => _RecentsPageState();
17 | }
18 |
19 | class _RecentsPageState extends State {
20 | late List contents;
21 | final _contentService = ContentService();
22 | bool isLoading = true;
23 | static const _perPage = 30;
24 |
25 | final PagingController _pagingController =
26 | PagingController(firstPageKey: 1);
27 |
28 | @override
29 | void initState() {
30 | super.initState();
31 |
32 | _pagingController.addPageRequestListener((pageKey) {
33 | _getContents(pageKey);
34 | });
35 | }
36 |
37 | @override
38 | void dispose() {
39 | _pagingController.dispose();
40 |
41 | super.dispose();
42 | }
43 |
44 | Future _getContents(int page) async {
45 | final content = await _contentService.fetchContentsNew(page: page);
46 |
47 | final isLastPage = content.length < _perPage;
48 |
49 | if (isLastPage) {
50 | _pagingController.appendLastPage(content);
51 | } else {
52 | final nextPage = page + 1;
53 |
54 | _pagingController.appendPage(content, nextPage);
55 | }
56 | }
57 |
58 | @override
59 | Widget build(BuildContext context) {
60 | return RefreshIndicator(
61 | color: context.isDarkMode ? Colors.white : Colors.black,
62 | onRefresh: () => Future.sync(
63 | () => _pagingController.refresh(),
64 | ),
65 | child: PagedListView(
66 | padding: const EdgeInsets.all(10.0),
67 | pagingController: _pagingController,
68 | scrollController: widget.scrollController,
69 | builderDelegate: PagedChildBuilderDelegate(
70 | itemBuilder: (context, item, index) {
71 | return ItemContent(content: item);
72 | },
73 | firstPageProgressIndicatorBuilder: (_) =>
74 | const AppProgressIndicator(),
75 | newPageProgressIndicatorBuilder: (_) => const AppProgressIndicator(),
76 | ),
77 | ),
78 | );
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/lib/src/ui/layouts/tab.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/controllers/app.dart';
4 | import 'package:tabnews/src/ui/pages/favorites.dart';
5 | import 'package:tabnews/src/ui/pages/home.dart';
6 | import 'package:tabnews/src/ui/pages/login.dart';
7 | import 'package:tabnews/src/ui/pages/profile.dart';
8 | import 'package:tabnews/src/ui/pages/recents.dart';
9 | import 'package:tabnews/src/ui/widgets/bottom_bar.dart';
10 | import 'package:tabnews/src/ui/widgets/top_bar.dart';
11 |
12 | class TabLayout extends StatefulWidget {
13 | const TabLayout({super.key});
14 |
15 | @override
16 | State createState() => _TabLayoutState();
17 | }
18 |
19 | class _TabLayoutState extends State with WidgetsBindingObserver {
20 | List pagesScrollController = [
21 | ScrollController(),
22 | ScrollController(),
23 | ];
24 |
25 | int _currentPage = 0;
26 | late final List _pages = [
27 | HomePage(scrollController: pagesScrollController[0]),
28 | RecentsPage(scrollController: pagesScrollController[1]),
29 | const FavoritesPage(),
30 | ValueListenableBuilder(
31 | valueListenable: AppController.isLoggedIn,
32 | builder: (context, isLoggedIn, child) {
33 | return isLoggedIn ? const ProfilePage() : const LoginPage();
34 | },
35 | ),
36 | ];
37 |
38 | void _onItemTapped(int index) {
39 | setState(() {
40 | if (index != _currentPage) {
41 | _currentPage = index;
42 | } else {
43 | pagesScrollController[_currentPage].animateTo(
44 | 0,
45 | duration: const Duration(
46 | milliseconds: 500,
47 | ),
48 | curve: Curves.fastOutSlowIn,
49 | );
50 | }
51 | });
52 | }
53 |
54 | @override
55 | void initState() {
56 | WidgetsBinding.instance.addObserver(this);
57 | super.initState();
58 | }
59 |
60 | @override
61 | void dispose() {
62 | WidgetsBinding.instance.removeObserver(this);
63 |
64 | super.dispose();
65 | }
66 |
67 | @override
68 | void didChangeAppLifecycleState(AppLifecycleState state) {
69 | if (AppController.isLoggedIn.value && state == AppLifecycleState.resumed) {
70 | AppController.updateUser();
71 | }
72 | }
73 |
74 | @override
75 | Widget build(BuildContext context) {
76 | return Scaffold(
77 | extendBody: true,
78 | appBar: const AppTopBar(),
79 | body: IndexedStack(
80 | index: _currentPage,
81 | children: _pages,
82 | ),
83 | bottomNavigationBar: AppBottomBar(
84 | onTap: _onItemTapped,
85 | currentPage: _currentPage,
86 | ),
87 | );
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/item_content.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:timeago/timeago.dart' as timeago;
3 |
4 | import 'package:tabnews/src/ui/pages/content.dart';
5 | import 'package:tabnews/src/ui/pages/profile_user.dart';
6 | import 'package:tabnews/src/utils/navigation.dart';
7 | import 'package:tabnews/src/extensions/dark_mode.dart';
8 | import 'package:tabnews/src/models/content.dart';
9 |
10 | class ItemContent extends StatelessWidget {
11 | final Content content;
12 |
13 | const ItemContent({
14 | super.key,
15 | required this.content,
16 | });
17 |
18 | @override
19 | Widget build(BuildContext context) {
20 | timeago.setLocaleMessages('pt-BR', timeago.PtBrMessages());
21 | var date = DateTime.parse(content.publishedAt!);
22 | bool isComment = false;
23 |
24 | if (content.parentId != null) {
25 | isComment = true;
26 | }
27 |
28 | return InkWell(
29 | onTap: () => Navigation.push(
30 | context,
31 | ContentPage(
32 | username: content.ownerUsername!,
33 | slug: content.slug!,
34 | ),
35 | ),
36 | child: Container(
37 | margin: const EdgeInsets.only(bottom: 15.0),
38 | padding: const EdgeInsets.all(15.0),
39 | decoration: BoxDecoration(
40 | color:
41 | context.isDarkMode ? Colors.grey.shade800 : Colors.grey.shade200,
42 | borderRadius: BorderRadius.circular(10.0),
43 | ),
44 | child: Column(
45 | mainAxisAlignment: MainAxisAlignment.start,
46 | crossAxisAlignment: CrossAxisAlignment.stretch,
47 | children: [
48 | Text(
49 | isComment ? '${content.body}' : '${content.title}',
50 | style: const TextStyle().copyWith(
51 | fontSize: 15.0,
52 | fontWeight: FontWeight.w700,
53 | ),
54 | ),
55 | const SizedBox(height: 15.0),
56 | Column(
57 | crossAxisAlignment: CrossAxisAlignment.end,
58 | children: [
59 | InkWell(
60 | onTap: () => Navigation.push(
61 | context,
62 | ProfileUserPage(
63 | username: '${content.ownerUsername}',
64 | ),
65 | ),
66 | child: Text('${content.ownerUsername}'),
67 | ),
68 | const SizedBox(height: 5.0),
69 | Text(
70 | '${content.tabcoins} tabcoins · ${content.childrenDeepCount} comentários · ${timeago.format(date, locale: "pt-BR")}',
71 | style: TextStyle(
72 | color: context.isDarkMode
73 | ? Colors.grey.shade400
74 | : Colors.grey.shade700,
75 | ),
76 | ),
77 | ],
78 | ),
79 | ],
80 | ),
81 | ),
82 | );
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TabNews App
2 |
3 | [](https://github.com/avuenja/tabnews-app/actions/workflows/android.yml)
4 |
5 | Aplicativo TabNews feito com muito ♥️ e Flutter pela comunidade, para o site [TabNews](https://www.tabnews.com.br).
6 |
7 | ## Features:
8 |
9 | - [x] Dark mode
10 | - [x] Leitura de conteúdos
11 | - [x] Pull To Refresh
12 | - [x] Infite Scroll
13 | - [x] Visualização de Comentários das publicações
14 | - [x] Login do usuário
15 | - [x] Meus conteúdos
16 | - [x] Gerencimaneto de conta
17 | - [x] Criação de conta pelo App
18 | - [x] Resposta dos conteúdos
19 | - [x] Interação com Tabcoins
20 | - [x] Postagens de conteúdos
21 | - [x] Visualização do perfil de outros usuários
22 | - [x] Favoritos (local database)
23 | - [ ] Opção ler mais tarde (local database)
24 | - [ ] Buscar conteúdos (?)
25 |
26 | ## Instalar e rodar o projeto
27 |
28 | ### Dependências globais
29 |
30 | Você precisa ter o Flutter instalado e configurado na sua máquina:
31 |
32 | - [Flutter](https://docs.flutter.dev/get-started/install) 3.0 (ou qualquer versão **3** superior)
33 |
34 | ### Dependências locais
35 |
36 | Então após baixar/clonar o repositório, não se esqueça de instalar as dependências locais do projeto:
37 |
38 | ```bash
39 | flutter pub get
40 | ```
41 |
42 | ### Rodar o projeto
43 |
44 | Para rodar o projeto localmente, basta rodar o comando abaixo:
45 |
46 | ```bash
47 | flutter run
48 | ```
49 |
50 | Isto irá rodar o projeto no seu emulador/simulador ou dispositivo real conectado.
51 |
52 | **Lembrando que as vezes é necessário abrir o emulador/simulador antes de rodar o comando de run.**
53 |
54 | ### Buildar o projeto
55 |
56 | Para buildar o projeto, basta rodar o seguitne comando:
57 |
58 | **Android APK**
59 |
60 | ```
61 | flutter build apk
62 | ```
63 |
64 | Diretório de saída do APK: _(build/app/outputs/flutter-apk/app-release.apk)_
65 |
66 | **Apple iOS**
67 |
68 | _Sugiro buildar diretamente pelo **Xcode**, selecionando seu dispositivo como device. E também para utilizar sem a conexão USB, é necessário buildar utilizando o mode **Profile**_
69 |
70 | ## Showcase:
71 |
72 | 
73 |
74 |
75 |
76 |
77 | ## Commit das alterações
78 |
79 | O projeto utiliza a especificação de [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
80 | O sistema foi configurado com o [lefthook](https://github.com/evilmartians/lefthook), e adiconado as configurações em `lefthook.yml` e criado as configurações das mensagens em `bin/commit_message.dart`.
81 |
82 | ## Contribuidores
83 |
84 | Acesse a página de [Insights](https://github.com/avuenja/tabnews-app/graphs/contributors) do projeto.
85 |
--------------------------------------------------------------------------------
/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/lib/src/controllers/auth.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | import 'package:tabnews/src/constants.dart';
6 | import 'package:tabnews/src/controllers/app.dart';
7 | import 'package:tabnews/src/interfaces/view_action.dart';
8 | import 'package:tabnews/src/models/user.dart';
9 | import 'package:tabnews/src/preferences.dart';
10 | import 'package:tabnews/src/services/auth.dart';
11 | import 'package:tabnews/src/services/http_response.dart';
12 |
13 | class AuthController {
14 | final ViewAction _view;
15 | final AuthService _authService = AuthService();
16 |
17 | final String _loggedKey = AppConstants.loggedInKey;
18 | final String _authKey = AppConstants.authKey;
19 | final String _userKey = AppConstants.userKey;
20 |
21 | final ValueNotifier _isLoading = ValueNotifier(false);
22 | ValueNotifier get isLoading => _isLoading;
23 |
24 | final ValueNotifier _isRegister = ValueNotifier(false);
25 | ValueNotifier get isRegister => _isRegister;
26 |
27 | AuthController(this._view);
28 |
29 | void login(String email, String password) async {
30 | if (email.isEmpty || password.isEmpty) {
31 | _view.onError(message: 'É necessário preencher todos os campos!');
32 |
33 | return;
34 | }
35 |
36 | _setLoading(true);
37 | final HttpResponse auth = await _authService.postLogin(email, password);
38 |
39 | if (auth.ok) {
40 | var user = await _authService.fetchUser(auth.data['token']);
41 |
42 | Preferences.setString(_authKey, auth.data['token']);
43 | Preferences.setString(_userKey, jsonEncode(user.data));
44 | Preferences.setBool(_loggedKey, true);
45 |
46 | _setLoggedIn(true);
47 | _setToken(auth.data['token']);
48 | _setUser(User.fromJson(user.data));
49 |
50 | _view.onSuccess();
51 | } else {
52 | _view.onError(message: auth.message);
53 | }
54 |
55 | _setLoading(false);
56 | }
57 |
58 | void logout() {
59 | Preferences.setString(_authKey, '');
60 | Preferences.setString(_userKey, '');
61 | Preferences.setBool(_loggedKey, false);
62 | _setLoggedIn(false);
63 | _setToken('');
64 | _setUser(User());
65 | }
66 |
67 | void register(String username, String email, String password) async {
68 | if (username.isEmpty || email.isEmpty || password.isEmpty) {
69 | _view.onError(message: 'É necessário preencher todos os campos!');
70 |
71 | return;
72 | }
73 |
74 | _setLoading(true);
75 | final HttpResponse register = await _authService.postRegister(
76 | username,
77 | email,
78 | password,
79 | );
80 |
81 | if (register.ok) {
82 | _setRegister(true);
83 |
84 | _view.onSuccess();
85 | } else {
86 | _view.onError(message: register.message);
87 | }
88 |
89 | _setLoading(false);
90 | }
91 |
92 | void _setLoading(bool value) {
93 | _isLoading.value = value;
94 | }
95 |
96 | void _setRegister(bool value) {
97 | _isRegister.value = value;
98 | }
99 |
100 | void _setLoggedIn(bool value) {
101 | AppController.isLoggedIn.value = value;
102 | }
103 |
104 | void _setToken(String value) {
105 | AppController.auth.value = value;
106 | }
107 |
108 | void _setUser(User value) {
109 | AppController.user.value = value;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "App Icons - App Store@2x-20@2x.png",
5 | "idiom" : "iphone",
6 | "scale" : "2x",
7 | "size" : "20x20"
8 | },
9 | {
10 | "filename" : "App Icons - App Store@2x-20@3x.png",
11 | "idiom" : "iphone",
12 | "scale" : "3x",
13 | "size" : "20x20"
14 | },
15 | {
16 | "filename" : "App Icons - App Store@2x-29.png",
17 | "idiom" : "iphone",
18 | "scale" : "1x",
19 | "size" : "29x29"
20 | },
21 | {
22 | "filename" : "App Icons - App Store@2x-29@2x.png",
23 | "idiom" : "iphone",
24 | "scale" : "2x",
25 | "size" : "29x29"
26 | },
27 | {
28 | "filename" : "App Icons - App Store@2x-29@3x.png",
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "29x29"
32 | },
33 | {
34 | "filename" : "App Icons - App Store@2x-40@2x.png",
35 | "idiom" : "iphone",
36 | "scale" : "2x",
37 | "size" : "40x40"
38 | },
39 | {
40 | "filename" : "App Icons - App Store@2x-40@3x.png",
41 | "idiom" : "iphone",
42 | "scale" : "3x",
43 | "size" : "40x40"
44 | },
45 | {
46 | "filename" : "App Icons - App Store@2x-60@2x.png",
47 | "idiom" : "iphone",
48 | "scale" : "2x",
49 | "size" : "60x60"
50 | },
51 | {
52 | "filename" : "App Icons - App Store@2x-60@3x.png",
53 | "idiom" : "iphone",
54 | "scale" : "3x",
55 | "size" : "60x60"
56 | },
57 | {
58 | "filename" : "App Icons - App Store@2x-20.png",
59 | "idiom" : "ipad",
60 | "scale" : "1x",
61 | "size" : "20x20"
62 | },
63 | {
64 | "filename" : "App Icons - App Store@2x-20@2x 1.png",
65 | "idiom" : "ipad",
66 | "scale" : "2x",
67 | "size" : "20x20"
68 | },
69 | {
70 | "filename" : "App Icons - App Store@2x-29 1.png",
71 | "idiom" : "ipad",
72 | "scale" : "1x",
73 | "size" : "29x29"
74 | },
75 | {
76 | "filename" : "App Icons - App Store@2x-29@2x 1.png",
77 | "idiom" : "ipad",
78 | "scale" : "2x",
79 | "size" : "29x29"
80 | },
81 | {
82 | "filename" : "App Icons - App Store@2x-40.png",
83 | "idiom" : "ipad",
84 | "scale" : "1x",
85 | "size" : "40x40"
86 | },
87 | {
88 | "filename" : "App Icons - App Store@2x-40@2x 1.png",
89 | "idiom" : "ipad",
90 | "scale" : "2x",
91 | "size" : "40x40"
92 | },
93 | {
94 | "filename" : "App Icons - App Store@2x-76.png",
95 | "idiom" : "ipad",
96 | "scale" : "1x",
97 | "size" : "76x76"
98 | },
99 | {
100 | "filename" : "App Icons - App Store@2x-76@2x.png",
101 | "idiom" : "ipad",
102 | "scale" : "2x",
103 | "size" : "76x76"
104 | },
105 | {
106 | "filename" : "App Icons - App Store@2x-83.5@2x.png",
107 | "idiom" : "ipad",
108 | "scale" : "2x",
109 | "size" : "83.5x83.5"
110 | },
111 | {
112 | "filename" : "App Icons - App Store@2x-1024.png",
113 | "idiom" : "ios-marketing",
114 | "scale" : "1x",
115 | "size" : "1024x1024"
116 | }
117 | ],
118 | "info" : {
119 | "author" : "xcode",
120 | "version" : 1
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "dev.progmar" "\0"
93 | VALUE "FileDescription", "tabnews" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "tabnews" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2022 dev.progmar. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "tabnews.exe" "\0"
98 | VALUE "ProductName", "tabnews" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/profile.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/controllers/app.dart';
4 | import 'package:tabnews/src/controllers/auth.dart';
5 | import 'package:tabnews/src/interfaces/view_action.dart';
6 | import 'package:tabnews/src/ui/pages/my_contents.dart';
7 | import 'package:tabnews/src/ui/pages/new_content.dart';
8 | import 'package:tabnews/src/ui/pages/profile_edit.dart';
9 | import 'package:tabnews/src/utils/navigation.dart';
10 |
11 | class ProfilePage extends StatefulWidget {
12 | const ProfilePage({super.key});
13 |
14 | @override
15 | State createState() => _ProfilePageState();
16 | }
17 |
18 | class _ProfilePageState extends State implements ViewAction {
19 | late final AuthController _authController;
20 |
21 | @override
22 | void initState() {
23 | super.initState();
24 |
25 | _authController = AuthController(this);
26 | }
27 |
28 | @override
29 | onSuccess({data}) {}
30 |
31 | @override
32 | onError({required String message}) {
33 | ScaffoldMessenger.of(context).showSnackBar(
34 | SnackBar(
35 | content: Text(message),
36 | ),
37 | );
38 | }
39 |
40 | @override
41 | Widget build(BuildContext context) {
42 | return Container(
43 | padding: const EdgeInsets.symmetric(
44 | vertical: 10.0,
45 | horizontal: 10.0,
46 | ),
47 | child: Column(
48 | mainAxisAlignment: MainAxisAlignment.center,
49 | children: [
50 | ValueListenableBuilder(
51 | valueListenable: AppController.user,
52 | builder: (context, user, child) {
53 | return Column(
54 | children: [
55 | Text(
56 | '${user.username}',
57 | style: const TextStyle().copyWith(
58 | fontSize: 28.0,
59 | fontWeight: FontWeight.w700,
60 | ),
61 | ),
62 | const SizedBox(height: 15.0),
63 | Row(
64 | mainAxisAlignment: MainAxisAlignment.center,
65 | children: [
66 | _buildColorContainer(Colors.blue),
67 | Text('${user.tabcoins ?? 0}'),
68 | const SizedBox(width: 10.0),
69 | _buildColorContainer(Colors.green),
70 | Text('${user.tabcash ?? 0}'),
71 | ],
72 | ),
73 | ],
74 | );
75 | },
76 | ),
77 | const SizedBox(height: 60.0),
78 | ListTile(
79 | onTap: () => Navigation.push(context, const MyContentsPage()),
80 | title: const Text('Meu conteúdo'),
81 | ),
82 | const Divider(color: Colors.grey),
83 | ListTile(
84 | onTap: () => Navigation.push(context, const NewContentPage()),
85 | title: const Text('Publicar novo conteúdo'),
86 | ),
87 | ListTile(
88 | onTap: () => Navigation.push(context, const ProfileEditPage()),
89 | title: const Text('Editar perfil'),
90 | ),
91 | const Divider(color: Colors.grey),
92 | ListTile(
93 | onTap: () => _authController.logout(),
94 | title: Text(
95 | 'Deslogar',
96 | style: const TextStyle().copyWith(
97 | color: Colors.red,
98 | ),
99 | ),
100 | ),
101 | ],
102 | ),
103 | );
104 | }
105 |
106 | Widget _buildColorContainer(Color color) {
107 | return Container(
108 | margin: const EdgeInsets.all(5.0),
109 | decoration: BoxDecoration(
110 | color: color,
111 | borderRadius: BorderRadius.circular(2.5),
112 | ),
113 | width: 12.0,
114 | height: 12.0,
115 | );
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/profile_user.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
3 |
4 | import 'package:tabnews/src/models/content.dart';
5 | import 'package:tabnews/src/models/user.dart';
6 | import 'package:tabnews/src/services/content.dart';
7 | import 'package:tabnews/src/services/user.dart';
8 | import 'package:tabnews/src/ui/layouts/page.dart';
9 | import 'package:tabnews/src/ui/widgets/item_content.dart';
10 | import 'package:tabnews/src/ui/widgets/progress_indicator.dart';
11 |
12 | class ProfileUserPage extends StatefulWidget {
13 | final String username;
14 |
15 | const ProfileUserPage({super.key, required this.username});
16 |
17 | @override
18 | State createState() => _ProfileUserPageState();
19 | }
20 |
21 | class _ProfileUserPageState extends State {
22 | final userService = UserService();
23 | final _contentService = ContentService();
24 | bool _isLoading = true;
25 | late User _user;
26 |
27 | static const _perPage = 30;
28 | final PagingController _pagingController =
29 | PagingController(firstPageKey: 1);
30 |
31 | final ScrollController _controller = ScrollController();
32 |
33 | @override
34 | void initState() {
35 | super.initState();
36 |
37 | _getUser();
38 | _pagingController.addPageRequestListener((pageKey) {
39 | _getContents(pageKey);
40 | });
41 | }
42 |
43 | @override
44 | void dispose() {
45 | _controller.dispose();
46 | _pagingController.dispose();
47 |
48 | super.dispose();
49 | }
50 |
51 | Future _getContents(int page) async {
52 | final content = await _contentService.fetchMyContents(
53 | page: page,
54 | user: widget.username,
55 | );
56 |
57 | final isLastPage = content.length < _perPage;
58 |
59 | if (isLastPage) {
60 | _pagingController.appendLastPage(content);
61 | } else {
62 | final nextPage = page + 1;
63 |
64 | _pagingController.appendPage(content, nextPage);
65 | }
66 | }
67 |
68 | _getUser() async {
69 | var userRet = await userService.fetchUser(widget.username);
70 |
71 | setState(() {
72 | _user = userRet;
73 | _isLoading = false;
74 | });
75 | }
76 |
77 | @override
78 | Widget build(BuildContext context) {
79 | return PageLayout(
80 | onRefresh: () async {},
81 | body: _isLoading
82 | ? const AppProgressIndicator()
83 | : SingleChildScrollView(
84 | controller: _controller,
85 | padding: const EdgeInsets.all(15.0),
86 | child: Column(
87 | children: [
88 | Text(
89 | '${_user.username}',
90 | style: const TextStyle().copyWith(
91 | fontSize: 24.0,
92 | fontWeight: FontWeight.w700,
93 | ),
94 | ),
95 | const SizedBox(height: 15.0),
96 | const Divider(),
97 | const SizedBox(height: 15.0),
98 | PagedListView(
99 | shrinkWrap: true,
100 | scrollController: _controller,
101 | pagingController: _pagingController,
102 | builderDelegate: PagedChildBuilderDelegate(
103 | itemBuilder: (context, item, index) {
104 | return ItemContent(content: item);
105 | },
106 | firstPageProgressIndicatorBuilder: (_) =>
107 | const AppProgressIndicator(),
108 | newPageProgressIndicatorBuilder: (_) =>
109 | const AppProgressIndicator(),
110 | ),
111 | ),
112 | ],
113 | ),
114 | ),
115 | );
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.14)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12 |
13 | # === Flutter Library ===
14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
15 |
16 | # Published to parent scope for install step.
17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
21 |
22 | list(APPEND FLUTTER_LIBRARY_HEADERS
23 | "flutter_export.h"
24 | "flutter_windows.h"
25 | "flutter_messenger.h"
26 | "flutter_plugin_registrar.h"
27 | "flutter_texture_registrar.h"
28 | )
29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
30 | add_library(flutter INTERFACE)
31 | target_include_directories(flutter INTERFACE
32 | "${EPHEMERAL_DIR}"
33 | )
34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
35 | add_dependencies(flutter flutter_assemble)
36 |
37 | # === Wrapper ===
38 | list(APPEND CPP_WRAPPER_SOURCES_CORE
39 | "core_implementations.cc"
40 | "standard_codec.cc"
41 | )
42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
44 | "plugin_registrar.cc"
45 | )
46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
47 | list(APPEND CPP_WRAPPER_SOURCES_APP
48 | "flutter_engine.cc"
49 | "flutter_view_controller.cc"
50 | )
51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
52 |
53 | # Wrapper sources needed for a plugin.
54 | add_library(flutter_wrapper_plugin STATIC
55 | ${CPP_WRAPPER_SOURCES_CORE}
56 | ${CPP_WRAPPER_SOURCES_PLUGIN}
57 | )
58 | apply_standard_settings(flutter_wrapper_plugin)
59 | set_target_properties(flutter_wrapper_plugin PROPERTIES
60 | POSITION_INDEPENDENT_CODE ON)
61 | set_target_properties(flutter_wrapper_plugin PROPERTIES
62 | CXX_VISIBILITY_PRESET hidden)
63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
64 | target_include_directories(flutter_wrapper_plugin PUBLIC
65 | "${WRAPPER_ROOT}/include"
66 | )
67 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
68 |
69 | # Wrapper sources needed for the runner.
70 | add_library(flutter_wrapper_app STATIC
71 | ${CPP_WRAPPER_SOURCES_CORE}
72 | ${CPP_WRAPPER_SOURCES_APP}
73 | )
74 | apply_standard_settings(flutter_wrapper_app)
75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
76 | target_include_directories(flutter_wrapper_app PUBLIC
77 | "${WRAPPER_ROOT}/include"
78 | )
79 | add_dependencies(flutter_wrapper_app flutter_assemble)
80 |
81 | # === Flutter tool backend ===
82 | # _phony_ is a non-existent file to force this command to run every time,
83 | # since currently there's no way to get a full input/output list from the
84 | # flutter tool.
85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
87 | add_custom_command(
88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
90 | ${CPP_WRAPPER_SOURCES_APP}
91 | ${PHONY_OUTPUT}
92 | COMMAND ${CMAKE_COMMAND} -E env
93 | ${FLUTTER_TOOL_ENVIRONMENT}
94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
95 | windows-x64 $
96 | VERBATIM
97 | )
98 | add_custom_target(flutter_assemble DEPENDS
99 | "${FLUTTER_LIBRARY}"
100 | ${FLUTTER_LIBRARY_HEADERS}
101 | ${CPP_WRAPPER_SOURCES_CORE}
102 | ${CPP_WRAPPER_SOURCES_PLUGIN}
103 | ${CPP_WRAPPER_SOURCES_APP}
104 | )
105 |
--------------------------------------------------------------------------------
/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen* screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "tabnews");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | } else {
47 | gtk_window_set_title(window, "tabnews");
48 | }
49 |
50 | gtk_window_set_default_size(window, 1280, 720);
51 | gtk_widget_show(GTK_WIDGET(window));
52 |
53 | g_autoptr(FlDartProject) project = fl_dart_project_new();
54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
55 |
56 | FlView* view = fl_view_new(project);
57 | gtk_widget_show(GTK_WIDGET(view));
58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
59 |
60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
61 |
62 | gtk_widget_grab_focus(GTK_WIDGET(view));
63 | }
64 |
65 | // Implements GApplication::local_command_line.
66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
67 | MyApplication* self = MY_APPLICATION(application);
68 | // Strip out the first argument as it is the binary name.
69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
70 |
71 | g_autoptr(GError) error = nullptr;
72 | if (!g_application_register(application, nullptr, &error)) {
73 | g_warning("Failed to register: %s", error->message);
74 | *exit_status = 1;
75 | return TRUE;
76 | }
77 |
78 | g_application_activate(application);
79 | *exit_status = 0;
80 |
81 | return TRUE;
82 | }
83 |
84 | // Implements GObject::dispose.
85 | static void my_application_dispose(GObject* object) {
86 | MyApplication* self = MY_APPLICATION(object);
87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
89 | }
90 |
91 | static void my_application_class_init(MyApplicationClass* klass) {
92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
95 | }
96 |
97 | static void my_application_init(MyApplication* self) {}
98 |
99 | MyApplication* my_application_new() {
100 | return MY_APPLICATION(g_object_new(my_application_get_type(),
101 | "application-id", APPLICATION_ID,
102 | "flags", G_APPLICATION_NON_UNIQUE,
103 | nullptr));
104 | }
105 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.14)
3 | project(tabnews LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "tabnews")
8 |
9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10 | # versions of CMake.
11 | cmake_policy(SET CMP0063 NEW)
12 |
13 | # Define build configuration option.
14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15 | if(IS_MULTICONFIG)
16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17 | CACHE STRING "" FORCE)
18 | else()
19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20 | set(CMAKE_BUILD_TYPE "Debug" CACHE
21 | STRING "Flutter build mode" FORCE)
22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23 | "Debug" "Profile" "Release")
24 | endif()
25 | endif()
26 | # Define settings for the Profile build mode.
27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31 |
32 | # Use Unicode for all projects.
33 | add_definitions(-DUNICODE -D_UNICODE)
34 |
35 | # Compilation settings that should be applied to most targets.
36 | #
37 | # Be cautious about adding new options here, as plugins use this function by
38 | # default. In most cases, you should add new options to specific targets instead
39 | # of modifying this function.
40 | function(APPLY_STANDARD_SETTINGS TARGET)
41 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43 | target_compile_options(${TARGET} PRIVATE /EHsc)
44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
46 | endfunction()
47 |
48 | # Flutter library and tool build rules.
49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50 | add_subdirectory(${FLUTTER_MANAGED_DIR})
51 |
52 | # Application build; see runner/CMakeLists.txt.
53 | add_subdirectory("runner")
54 |
55 | # Generated plugin build rules, which manage building the plugins and adding
56 | # them to the application.
57 | include(flutter/generated_plugins.cmake)
58 |
59 |
60 | # === Installation ===
61 | # Support files are copied into place next to the executable, so that it can
62 | # run in place. This is done instead of making a separate bundle (as on Linux)
63 | # so that building and running from within Visual Studio will work.
64 | set(BUILD_BUNDLE_DIR "$")
65 | # Make the "install" step default, as it's required to run.
66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
69 | endif()
70 |
71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
73 |
74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
75 | COMPONENT Runtime)
76 |
77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
78 | COMPONENT Runtime)
79 |
80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
81 | COMPONENT Runtime)
82 |
83 | if(PLUGIN_BUNDLED_LIBRARIES)
84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
86 | COMPONENT Runtime)
87 | endif()
88 |
89 | # Fully re-copy the assets directory on each build to avoid having stale files
90 | # from a previous install.
91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
92 | install(CODE "
93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
94 | " COMPONENT Runtime)
95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
97 |
98 | # Install the AOT library on non-Debug builds only.
99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
100 | CONFIGURATIONS Profile;Release
101 | COMPONENT Runtime)
102 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: tabnews
2 | description: TabNews App made with Flutter
3 |
4 | # The following line prevents the package from being accidentally published to
5 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
6 | publish_to: "none" # Remove this line if you wish to publish to pub.dev
7 |
8 | # The following defines the version and build number for your application.
9 | # A version number is three numbers separated by dots, like 1.2.43
10 | # followed by an optional build number separated by a +.
11 | # Both the version and the builder number may be overridden in flutter
12 | # build by specifying --build-name and --build-number, respectively.
13 | # In Android, build-name is used as versionName while build-number used as versionCode.
14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
16 | # Read more about iOS versioning at
17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18 | # In Windows, build-name is used as the major, minor, and patch parts
19 | # of the product and file versions while build-number is used as the build suffix.
20 | version: 1.0.0+1
21 |
22 | environment:
23 | sdk: ">=2.18.4 <3.0.0"
24 |
25 | # Dependencies specify other packages that your package needs in order to work.
26 | # To automatically upgrade your package dependencies to the latest versions
27 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
28 | # dependencies can be manually updated by changing the version numbers below to
29 | # the latest version available on pub.dev. To see which dependencies have newer
30 | # versions available, run `flutter pub outdated`.
31 | dependencies:
32 | flutter:
33 | sdk: flutter
34 |
35 | # The following adds the Cupertino Icons font to your application.
36 | # Use with the CupertinoIcons class for iOS style icons.
37 | cupertino_icons: ^1.0.2
38 | timeago: ^3.3.0
39 | flutter_svg: ^1.1.6
40 | flutter_markdown: ^0.6.13
41 | http: ^0.13.5
42 | infinite_scroll_pagination: ^3.2.0
43 | shared_preferences: ^2.0.15
44 | markdown: ^6.0.1
45 | markdown_editable_textinput: ^2.1.0
46 | url_launcher: ^6.1.7
47 | flutter_dotenv: ^5.0.2
48 |
49 | dev_dependencies:
50 | flutter_test:
51 | sdk: flutter
52 |
53 | # The "flutter_lints" package below contains a set of recommended lints to
54 | # encourage good coding practices. The lint set provided by the package is
55 | # activated in the `analysis_options.yaml` file located at the root of your
56 | # package. See that file for information about deactivating specific lint
57 | # rules and activating additional ones.
58 | flutter_lints: ^2.0.0
59 |
60 | # For information on the generic Dart part of this file, see the
61 | # following page: https://dart.dev/tools/pub/pubspec
62 |
63 | # The following section is specific to Flutter packages.
64 | flutter:
65 | # The following line ensures that the Material Icons font is
66 | # included with your application, so that you can use the icons in
67 | # the material Icons class.
68 | uses-material-design: true
69 |
70 | # To add assets to your application, add an assets section, like this:
71 | assets:
72 | - lib/assets/
73 | - .env.dev
74 | - .env.prod
75 |
76 | # An image asset can refer to one or more resolution-specific "variants", see
77 | # https://flutter.dev/assets-and-images/#resolution-aware
78 |
79 | # For details regarding adding assets from package dependencies, see
80 | # https://flutter.dev/assets-and-images/#from-packages
81 |
82 | # To add custom fonts to your application, add a fonts section here,
83 | # in this "flutter" section. Each entry in this list should have a
84 | # "family" key with the font family name, and a "fonts" key with a
85 | # list giving the asset and other descriptors for the font. For
86 | # example:
87 | # fonts:
88 | # - family: Schyler
89 | # fonts:
90 | # - asset: fonts/Schyler-Regular.ttf
91 | # - asset: fonts/Schyler-Italic.ttf
92 | # style: italic
93 | # - family: Trajan Pro
94 | # fonts:
95 | # - asset: fonts/TrajanPro.ttf
96 | # - asset: fonts/TrajanPro_Bold.ttf
97 | # weight: 700
98 | #
99 | # For details regarding fonts from package dependencies,
100 | # see https://flutter.dev/custom-fonts/#from-packages
101 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/answer.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:markdown_editable_textinput/format_markdown.dart';
3 | import 'package:markdown_editable_textinput/markdown_text_input.dart';
4 |
5 | import 'package:tabnews/src/controllers/comment.dart';
6 | import 'package:tabnews/src/extensions/dark_mode.dart';
7 | import 'package:tabnews/src/interfaces/view_action.dart';
8 | import 'package:tabnews/src/ui/widgets/markdown.dart';
9 |
10 | class Answer extends StatefulWidget {
11 | final bool inComment;
12 | final String parentId;
13 | final void Function() onAnswer;
14 |
15 | const Answer({
16 | super.key,
17 | this.inComment = false,
18 | required this.parentId,
19 | required this.onAnswer,
20 | });
21 |
22 | @override
23 | State createState() => _AnswerState();
24 | }
25 |
26 | class _AnswerState extends State implements ViewAction {
27 | late CommentController _commentController;
28 |
29 | bool isAnswering = false;
30 | bool isViewMarkdown = false;
31 |
32 | TextEditingController bodyTextController = TextEditingController();
33 |
34 | @override
35 | void initState() {
36 | super.initState();
37 |
38 | _commentController = CommentController(this);
39 | }
40 |
41 | @override
42 | onSuccess({data}) {
43 | bodyTextController.clear();
44 |
45 | ScaffoldMessenger.of(context).showSnackBar(
46 | const SnackBar(
47 | content: Text(
48 | 'Comentário publicado com sucesso!',
49 | ),
50 | ),
51 | );
52 |
53 | setState(() {
54 | isAnswering = false;
55 | });
56 |
57 | widget.onAnswer();
58 | }
59 |
60 | @override
61 | onError({required String message}) {
62 | ScaffoldMessenger.of(context).showSnackBar(
63 | SnackBar(
64 | content: Text(message),
65 | ),
66 | );
67 | }
68 |
69 | @override
70 | void dispose() {
71 | bodyTextController.dispose();
72 |
73 | super.dispose();
74 | }
75 |
76 | void cancel() {
77 | bodyTextController.clear();
78 |
79 | setState(() {
80 | isAnswering = false;
81 | });
82 | }
83 |
84 | @override
85 | Widget build(BuildContext context) {
86 | if (widget.inComment) {
87 | return _buildAnswer();
88 | }
89 |
90 | return Container(
91 | padding: const EdgeInsets.all(10.0),
92 | decoration: BoxDecoration(
93 | border: Border.all(
94 | color:
95 | context.isDarkMode ? Colors.grey.shade700 : Colors.grey.shade300,
96 | ),
97 | borderRadius: BorderRadius.circular(5.0),
98 | ),
99 | child: _buildAnswer(),
100 | );
101 | }
102 |
103 | Widget _buildAnswer() {
104 | return isAnswering
105 | ? Column(
106 | children: [
107 | isViewMarkdown
108 | ? SizedBox(
109 | height: 420.0,
110 | child: MarkedownReader(body: bodyTextController.text),
111 | )
112 | : MarkdownTextInput(
113 | maxLines: 20,
114 | label: 'Comentário',
115 | controller: bodyTextController,
116 | actions: MarkdownType.values,
117 | (value) {},
118 | bodyTextController.text,
119 | ),
120 | Row(
121 | mainAxisAlignment: MainAxisAlignment.center,
122 | crossAxisAlignment: CrossAxisAlignment.center,
123 | children: [
124 | TextButton(
125 | onPressed: () {
126 | setState(() {
127 | isViewMarkdown = !isViewMarkdown;
128 | });
129 | },
130 | child: Text(isViewMarkdown ? 'Escrever' : 'Visualizar'),
131 | ),
132 | const Spacer(),
133 | TextButton(
134 | onPressed: cancel,
135 | child: const Text('Cancelar'),
136 | ),
137 | const SizedBox(width: 5.0),
138 | ElevatedButton(
139 | onPressed: () => _commentController.create(
140 | bodyTextController.text,
141 | widget.parentId,
142 | ),
143 | child: const Text('Publicar'),
144 | ),
145 | ],
146 | ),
147 | ],
148 | )
149 | : Row(
150 | children: [
151 | ElevatedButton(
152 | onPressed: () {
153 | setState(() {
154 | isAnswering = true;
155 | });
156 | },
157 | child: const Text('Responder'),
158 | ),
159 | ],
160 | );
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/lib/src/ui/widgets/item_comment.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:timeago/timeago.dart' as timeago;
3 |
4 | import 'package:tabnews/src/controllers/app.dart';
5 | import 'package:tabnews/src/services/content.dart';
6 | import 'package:tabnews/src/ui/pages/profile_user.dart';
7 | import 'package:tabnews/src/ui/widgets/answer.dart';
8 | import 'package:tabnews/src/ui/widgets/comments_children.dart';
9 | import 'package:tabnews/src/ui/widgets/tabcoins.dart';
10 | import 'package:tabnews/src/utils/navigation.dart';
11 | import 'package:tabnews/src/extensions/dark_mode.dart';
12 | import 'package:tabnews/src/models/comment.dart';
13 | import 'package:tabnews/src/ui/widgets/markdown.dart';
14 |
15 | class ItemComment extends StatefulWidget {
16 | final Comment comment;
17 | final ScrollController controller;
18 | final void Function() onAnswer;
19 |
20 | const ItemComment({
21 | super.key,
22 | required this.comment,
23 | required this.controller,
24 | required this.onAnswer,
25 | });
26 |
27 | @override
28 | State createState() => _ItemCommentState();
29 | }
30 |
31 | class _ItemCommentState extends State {
32 | Comment get comment => widget.comment;
33 | ScrollController get controller => widget.controller;
34 |
35 | final _contentService = ContentService();
36 |
37 | _tabcoins(String vote) async {
38 | var tabcoinsResp = await _contentService.postTabcoins(
39 | '${comment.ownerUsername}/${comment.slug}',
40 | vote == 'upvote' ? 'credit' : 'debit',
41 | );
42 |
43 | if (tabcoinsResp.ok) {
44 | setState(() {
45 | comment.tabcoins = tabcoinsResp.data['tabcoins'];
46 | });
47 | } else {
48 | _onResponse(tabcoinsResp.message);
49 | }
50 | }
51 |
52 | void _onResponse(String message) {
53 | ScaffoldMessenger.of(context).showSnackBar(
54 | SnackBar(
55 | content: Text(message),
56 | ),
57 | );
58 | }
59 |
60 | @override
61 | Widget build(BuildContext context) {
62 | timeago.setLocaleMessages('pt-BR', timeago.PtBrMessages());
63 |
64 | return Container(
65 | padding: const EdgeInsets.only(top: 10.0),
66 | child: Column(
67 | crossAxisAlignment: CrossAxisAlignment.stretch,
68 | children: [
69 | Row(
70 | crossAxisAlignment: CrossAxisAlignment.center,
71 | children: [
72 | InkWell(
73 | onTap: () => Navigation.push(
74 | context,
75 | ProfileUserPage(username: '${comment.ownerUsername}'),
76 | ),
77 | child: Text('${comment.ownerUsername}'),
78 | ),
79 | Text(
80 | ' · ${timeago.format(DateTime.parse(comment.publishedAt!), locale: "pt-BR")}',
81 | style: const TextStyle().copyWith(
82 | color: context.isDarkMode
83 | ? Colors.grey.shade400
84 | : Colors.grey.shade700,
85 | ),
86 | ),
87 | const Spacer(),
88 | ValueListenableBuilder(
89 | valueListenable: AppController.isLoggedIn,
90 | builder: (context, isLoggedIn, _) {
91 | if (!isLoggedIn) {
92 | return const SizedBox();
93 | }
94 |
95 | return Tabcoins(
96 | upvote: () => _tabcoins('upvote'),
97 | tabcoins: '${comment.tabcoins}',
98 | downvote: () => _tabcoins('downvote'),
99 | );
100 | },
101 | ),
102 | ],
103 | ),
104 | MarkedownReader(
105 | body: comment.body!,
106 | controller: controller,
107 | ),
108 | ValueListenableBuilder(
109 | valueListenable: AppController.isLoggedIn,
110 | builder: (context, isLoggedIn, child) {
111 | if (isLoggedIn) {
112 | return Column(
113 | children: [
114 | const SizedBox(height: 15.0),
115 | Answer(
116 | parentId: comment.id!,
117 | inComment: true,
118 | onAnswer: widget.onAnswer,
119 | ),
120 | const SizedBox(height: 15.0),
121 | ],
122 | );
123 | } else {
124 | return const SizedBox();
125 | }
126 | },
127 | ),
128 | comment.children!.isNotEmpty
129 | ? Padding(
130 | padding: const EdgeInsets.only(left: 15.0),
131 | child: CommentsWidget(
132 | comments: comment.children!,
133 | controller: controller,
134 | onAnswer: widget.onAnswer,
135 | ),
136 | )
137 | : const SizedBox(),
138 | ],
139 | ),
140 | );
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/lib/src/services/content.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:http/http.dart' as http;
4 | import 'package:tabnews/src/controllers/app.dart';
5 | import 'package:tabnews/src/enviroment_vars.dart';
6 | import 'package:tabnews/src/models/comment.dart';
7 |
8 | import 'package:tabnews/src/models/content.dart';
9 | import 'package:tabnews/src/services/http_response.dart';
10 |
11 | class ContentService {
12 | String get apiUrl => "${EnviromentVars.getVars.webserver}/api/v1/contents";
13 |
14 | Future> fetchContents({int page = 1}) async {
15 | final response = await http.get(Uri.parse('$apiUrl?page=$page'));
16 |
17 | if (response.statusCode == 200) {
18 | var dataJson = jsonDecode(response.body);
19 | List contents = [];
20 |
21 | dataJson.forEach((item) {
22 | contents.add(Content.fromJson(item));
23 | });
24 |
25 | return contents;
26 | } else {
27 | throw Exception('Failed to load contents');
28 | }
29 | }
30 |
31 | Future> fetchContentsNew({int page = 1}) async {
32 | final response = await http.get(
33 | Uri.parse('$apiUrl?strategy=new&page=$page'),
34 | );
35 |
36 | if (response.statusCode == 200) {
37 | var dataJson = jsonDecode(response.body);
38 | List contents = [];
39 |
40 | dataJson.forEach((item) {
41 | contents.add(Content.fromJson(item));
42 | });
43 |
44 | return contents;
45 | } else {
46 | throw Exception('Failed to load new contents');
47 | }
48 | }
49 |
50 | Future fetchContent(String slug) async {
51 | final response = await http.get(Uri.parse('$apiUrl/$slug'));
52 |
53 | return HttpResponse(response.statusCode, response.body);
54 | }
55 |
56 | Future fetchContentParent(String slug) async {
57 | final response = await http.get(Uri.parse('$apiUrl/$slug/parent'));
58 |
59 | return HttpResponse(response.statusCode, response.body);
60 | }
61 |
62 | Future> fetchContentComments(String slug) async {
63 | final response = await http.get(Uri.parse('$apiUrl/$slug/children'));
64 |
65 | if (response.statusCode == 200) {
66 | var dataJson = jsonDecode(response.body);
67 | List comments = [];
68 |
69 | dataJson.forEach((item) {
70 | comments.add(Comment.fromJson(item));
71 | });
72 |
73 | return comments;
74 | } else {
75 | throw Exception('Failed to load singular content children');
76 | }
77 | }
78 |
79 | Future> fetchMyContents({
80 | int page = 1,
81 | required String user,
82 | }) async {
83 | final response = await http.get(
84 | Uri.parse('$apiUrl/$user?strategy=new&page=$page'),
85 | );
86 |
87 | if (response.statusCode == 200) {
88 | var dataJson = jsonDecode(response.body);
89 | List contents = [];
90 |
91 | dataJson.forEach((item) {
92 | contents.add(Content.fromJson(item));
93 | });
94 |
95 | return contents;
96 | } else {
97 | throw Exception('Failed to load my contents');
98 | }
99 | }
100 |
101 | Future postContent(
102 | String token,
103 | String title,
104 | String body,
105 | String source,
106 | ) async {
107 | final response = await http.post(
108 | Uri.parse(apiUrl),
109 | headers: {
110 | 'Set-Cookie': 'session_id=$token',
111 | 'Cookie': 'session_id=$token',
112 | 'Content-Type': 'application/json; charset=UTF-8',
113 | },
114 | body: jsonEncode({
115 | 'title': title,
116 | 'body': body,
117 | 'status': 'published',
118 | source.isNotEmpty ? 'source_url' : source: null,
119 | }),
120 | );
121 |
122 | return HttpResponse(response.statusCode, response.body);
123 | }
124 |
125 | Future postComment(
126 | String token,
127 | String parentId,
128 | String body,
129 | ) async {
130 | final response = await http.post(
131 | Uri.parse(apiUrl),
132 | headers: {
133 | 'Set-Cookie': 'session_id=$token',
134 | 'Cookie': 'session_id=$token',
135 | 'Content-Type': 'application/json; charset=UTF-8',
136 | },
137 | body: jsonEncode({
138 | 'parent_id': parentId,
139 | 'body': body,
140 | 'status': 'published',
141 | }),
142 | );
143 |
144 | return HttpResponse(response.statusCode, response.body);
145 | }
146 |
147 | Future postTabcoins(String slug, String type) async {
148 | final response = await http.post(
149 | Uri.parse('$apiUrl/$slug/tabcoins'),
150 | headers: {
151 | 'Set-Cookie': 'session_id=${AppController.auth.value}',
152 | 'Cookie': 'session_id=${AppController.auth.value}',
153 | 'Content-Type': 'application/json; charset=UTF-8',
154 | },
155 | body: jsonEncode({
156 | 'transaction_type': type,
157 | }),
158 | );
159 |
160 | AppController.updateUser();
161 |
162 | return HttpResponse(response.statusCode, response.body);
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Project-level configuration.
2 | cmake_minimum_required(VERSION 3.10)
3 | project(runner LANGUAGES CXX)
4 |
5 | # The name of the executable created for the application. Change this to change
6 | # the on-disk name of your application.
7 | set(BINARY_NAME "tabnews")
8 | # The unique GTK application identifier for this application. See:
9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 | set(APPLICATION_ID "dev.progmar.tabnews")
11 |
12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
13 | # versions of CMake.
14 | cmake_policy(SET CMP0063 NEW)
15 |
16 | # Load bundled libraries from the lib/ directory relative to the binary.
17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
18 |
19 | # Root filesystem for cross-building.
20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT)
21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
27 | endif()
28 |
29 | # Define build configuration options.
30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31 | set(CMAKE_BUILD_TYPE "Debug" CACHE
32 | STRING "Flutter build mode" FORCE)
33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
34 | "Debug" "Profile" "Release")
35 | endif()
36 |
37 | # Compilation settings that should be applied to most targets.
38 | #
39 | # Be cautious about adding new options here, as plugins use this function by
40 | # default. In most cases, you should add new options to specific targets instead
41 | # of modifying this function.
42 | function(APPLY_STANDARD_SETTINGS TARGET)
43 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
47 | endfunction()
48 |
49 | # Flutter library and tool build rules.
50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
51 | add_subdirectory(${FLUTTER_MANAGED_DIR})
52 |
53 | # System-level dependencies.
54 | find_package(PkgConfig REQUIRED)
55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
56 |
57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
58 |
59 | # Define the application target. To change its name, change BINARY_NAME above,
60 | # not the value here, or `flutter run` will no longer work.
61 | #
62 | # Any new source files that you add to the application should be added here.
63 | add_executable(${BINARY_NAME}
64 | "main.cc"
65 | "my_application.cc"
66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
67 | )
68 |
69 | # Apply the standard set of build settings. This can be removed for applications
70 | # that need different build settings.
71 | apply_standard_settings(${BINARY_NAME})
72 |
73 | # Add dependency libraries. Add any application-specific dependencies here.
74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
76 |
77 | # Run the Flutter tool portions of the build. This must not be removed.
78 | add_dependencies(${BINARY_NAME} flutter_assemble)
79 |
80 | # Only the install-generated bundle's copy of the executable will launch
81 | # correctly, since the resources must in the right relative locations. To avoid
82 | # people trying to run the unbundled copy, put it in a subdirectory instead of
83 | # the default top-level location.
84 | set_target_properties(${BINARY_NAME}
85 | PROPERTIES
86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
87 | )
88 |
89 | # Generated plugin build rules, which manage building the plugins and adding
90 | # them to the application.
91 | include(flutter/generated_plugins.cmake)
92 |
93 |
94 | # === Installation ===
95 | # By default, "installing" just makes a relocatable bundle in the build
96 | # directory.
97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
100 | endif()
101 |
102 | # Start with a clean build bundle directory every time.
103 | install(CODE "
104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
105 | " COMPONENT Runtime)
106 |
107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
109 |
110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
111 | COMPONENT Runtime)
112 |
113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
114 | COMPONENT Runtime)
115 |
116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
117 | COMPONENT Runtime)
118 |
119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
120 | install(FILES "${bundled_library}"
121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
122 | COMPONENT Runtime)
123 | endforeach(bundled_library)
124 |
125 | # Fully re-copy the assets directory on each build to avoid having stale files
126 | # from a previous install.
127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
128 | install(CODE "
129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
130 | " COMPONENT Runtime)
131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
133 |
134 | # Install the AOT library on non-Debug builds only.
135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
137 | COMPONENT Runtime)
138 | endif()
139 |
--------------------------------------------------------------------------------
/lib/src/ui/pages/profile_edit.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'package:tabnews/src/constants.dart';
4 | import 'package:tabnews/src/controllers/app.dart';
5 | import 'package:tabnews/src/controllers/user.dart';
6 | import 'package:tabnews/src/interfaces/view_action.dart';
7 | import 'package:tabnews/src/ui/layouts/page.dart';
8 |
9 | class ProfileEditPage extends StatefulWidget {
10 | const ProfileEditPage({super.key});
11 |
12 | @override
13 | State createState() => _ProfileEditPageState();
14 | }
15 |
16 | class _ProfileEditPageState extends State
17 | implements ViewAction {
18 | late final UserController _userController;
19 |
20 | final _formKey = GlobalKey();
21 | final TextEditingController usernameTextController = TextEditingController(
22 | text: AppController.user.value.username,
23 | );
24 | final TextEditingController emailTextController = TextEditingController(
25 | text: AppController.user.value.email,
26 | );
27 |
28 | @override
29 | void initState() {
30 | super.initState();
31 |
32 | _userController = UserController(this);
33 | }
34 |
35 | @override
36 | onSuccess({data}) {}
37 |
38 | @override
39 | onError({required String message}) {
40 | ScaffoldMessenger.of(context).showSnackBar(
41 | SnackBar(
42 | content: Text(message),
43 | ),
44 | );
45 | }
46 |
47 | @override
48 | Widget build(BuildContext context) {
49 | return PageLayout(
50 | onRefresh: () async {},
51 | body: Center(
52 | child: Padding(
53 | padding: const EdgeInsets.all(30.0),
54 | child: Form(
55 | key: _formKey,
56 | child: Column(
57 | mainAxisAlignment: MainAxisAlignment.center,
58 | crossAxisAlignment: CrossAxisAlignment.stretch,
59 | children: [
60 | TextFormField(
61 | enableSuggestions: false,
62 | autocorrect: false,
63 | cursorColor: AppColors.primaryColor,
64 | decoration: const InputDecoration(
65 | focusedBorder: UnderlineInputBorder(
66 | borderSide: BorderSide(
67 | color: AppColors.primaryColor,
68 | width: 2.0,
69 | ),
70 | ),
71 | hintText: 'Nome de usuário',
72 | ),
73 | controller: usernameTextController,
74 | ),
75 | const SizedBox(height: 15.0),
76 | TextFormField(
77 | keyboardType: TextInputType.emailAddress,
78 | cursorColor: AppColors.primaryColor,
79 | decoration: const InputDecoration(
80 | focusedBorder: UnderlineInputBorder(
81 | borderSide: BorderSide(
82 | color: AppColors.primaryColor,
83 | width: 2.0,
84 | ),
85 | ),
86 | hintText: 'Email',
87 | ),
88 | controller: emailTextController,
89 | ),
90 | const SizedBox(height: 15.0),
91 | Row(
92 | mainAxisAlignment: MainAxisAlignment.end,
93 | crossAxisAlignment: CrossAxisAlignment.center,
94 | children: [
95 | ValueListenableBuilder(
96 | valueListenable: _userController.notification,
97 | builder: (context, notifications, child) {
98 | return Checkbox(
99 | fillColor: MaterialStateProperty.all(
100 | AppColors.primaryColor,
101 | ),
102 | value: notifications,
103 | onChanged: _userController.setNotifications,
104 | );
105 | },
106 | ),
107 | const Text('Receber notificações por email'),
108 | ],
109 | ),
110 | const SizedBox(height: 30.0),
111 | ValueListenableBuilder(
112 | valueListenable: _userController.isLoading,
113 | builder: (context, isLoading, child) {
114 | return ElevatedButton(
115 | style: ButtonStyle(
116 | elevation: MaterialStateProperty.all(0.0),
117 | backgroundColor: MaterialStateProperty.all(
118 | AppColors.primaryColor.withOpacity(
119 | isLoading ? 0.5 : 1.0,
120 | ),
121 | ),
122 | foregroundColor: MaterialStateProperty.all(
123 | Colors.white,
124 | ),
125 | shape: MaterialStateProperty.all(
126 | RoundedRectangleBorder(
127 | borderRadius: BorderRadius.circular(4.0),
128 | ),
129 | ),
130 | ),
131 | onPressed: isLoading
132 | ? null
133 | : () => _userController.update(
134 | usernameTextController.text,
135 | emailTextController.text,
136 | ),
137 | child: Text(
138 | isLoading ? 'Aguarde...' : 'Salvar',
139 | style: const TextStyle().copyWith(
140 | fontSize: 16.0,
141 | ),
142 | ),
143 | );
144 | },
145 | ),
146 | ],
147 | ),
148 | ),
149 | ),
150 | ),
151 | );
152 | }
153 | }
154 |
--------------------------------------------------------------------------------