├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── dependabot.yml └── workflows │ └── main.yaml ├── .gitignore ├── .metadata ├── .vscode └── launch.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── ic_launcher-playstore.png │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── markosyan │ │ │ │ └── flutterhub │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ ├── ic_launcher_foreground.png │ │ │ └── splash.png │ │ │ ├── drawable-mdpi │ │ │ ├── ic_launcher_foreground.png │ │ │ └── splash.png │ │ │ ├── drawable-night-v21 │ │ │ ├── background.png │ │ │ └── launch_background.xml │ │ │ ├── drawable-night │ │ │ ├── background.png │ │ │ └── launch_background.xml │ │ │ ├── drawable-v21 │ │ │ ├── background.png │ │ │ └── launch_background.xml │ │ │ ├── drawable-xhdpi │ │ │ ├── ic_launcher_foreground.png │ │ │ └── splash.png │ │ │ ├── drawable-xxhdpi │ │ │ ├── ic_launcher_foreground.png │ │ │ └── splash.png │ │ │ ├── drawable-xxxhdpi │ │ │ ├── ic_launcher_foreground.png │ │ │ └── splash.png │ │ │ ├── drawable │ │ │ ├── background.png │ │ │ └── launch_background.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── values-night-v31 │ │ │ └── styles.xml │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ ├── values-v31 │ │ │ └── styles.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── app_logo.svg ├── assets └── images │ ├── app_icon.png │ ├── app_icon_adaptive.png │ ├── app_icon_border.png │ ├── app_icon_round.png │ └── app_logo.png ├── build.yaml ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ ├── LaunchBackground.imageset │ │ ├── Contents.json │ │ ├── background.png │ │ └── darkbackground.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── app.dart ├── configs │ ├── app_store.dart │ ├── app_store.g.dart │ ├── app_theme.dart │ └── constants.dart ├── features │ ├── core │ │ ├── data │ │ │ ├── datasources │ │ │ │ └── restapi │ │ │ │ │ ├── login_service.dart │ │ │ │ │ ├── repos_service.dart │ │ │ │ │ ├── rest_service.chopper.dart │ │ │ │ │ ├── rest_service.dart │ │ │ │ │ ├── search_service.dart │ │ │ │ │ ├── trending_service.dart │ │ │ │ │ ├── user_service.dart │ │ │ │ │ └── users_service.dart │ │ │ ├── models │ │ │ │ ├── failure.dart │ │ │ │ ├── failure.freezed.dart │ │ │ │ └── failure.g.dart │ │ │ └── repositories │ │ │ │ └── repositories.dart │ │ ├── domain │ │ │ ├── entities │ │ │ │ ├── models.dart │ │ │ │ ├── models.freezed.dart │ │ │ │ ├── models.g.dart │ │ │ │ ├── repository.dart │ │ │ │ ├── repository_language.dart │ │ │ │ ├── repository_search.dart │ │ │ │ ├── token.dart │ │ │ │ ├── trending_repository.dart │ │ │ │ ├── trending_user.dart │ │ │ │ ├── user.dart │ │ │ │ └── user_search.dart │ │ │ ├── repositories │ │ │ │ └── repositories.dart │ │ │ └── usecases │ │ │ │ ├── usecase.dart │ │ │ │ └── usecases.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ └── cubits.dart │ │ │ └── widgets │ │ │ ├── app_logo.dart │ │ │ ├── common_widgets.dart │ │ │ ├── empty_widget.dart │ │ │ ├── grid_item.dart │ │ │ └── network_image.dart │ ├── home │ │ └── presentation │ │ │ └── pages │ │ │ └── home_page.dart │ ├── languages │ │ ├── domain │ │ │ └── usecases │ │ │ │ └── languages_usecase.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── languages_cubit.dart │ │ │ ├── languages_cubit.freezed.dart │ │ │ ├── languages_cubit.g.dart │ │ │ └── languages_state.dart │ │ │ ├── pages │ │ │ └── languages_page.dart │ │ │ └── widgets │ │ │ ├── language_header_widget.dart │ │ │ └── language_tile.dart │ ├── login │ │ ├── data │ │ │ ├── models │ │ │ │ ├── password_input.dart │ │ │ │ ├── personal_token_input.dart │ │ │ │ └── username_input.dart │ │ │ └── repositories │ │ │ │ └── login_repository.dart │ │ ├── domain │ │ │ ├── repositories │ │ │ │ └── login_repository.dart │ │ │ └── usecases │ │ │ │ └── login_usecase.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── login_cubit.dart │ │ │ ├── login_cubit.freezed.dart │ │ │ └── login_state.dart │ │ │ ├── pages │ │ │ └── login_page.dart │ │ │ └── widgets │ │ │ ├── basic_login_widget.dart │ │ │ ├── login_button.dart │ │ │ ├── login_tab_bar.dart │ │ │ ├── oauth_login_widget.dart │ │ │ └── personal_login_widget.dart │ ├── menu │ │ ├── data │ │ │ ├── models │ │ │ │ └── rate_limit.dart │ │ │ └── repositories │ │ │ │ └── user_repository.dart │ │ ├── domain │ │ │ ├── repositories │ │ │ │ └── user_repository.dart │ │ │ └── usecases │ │ │ │ └── user_usecase.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── menu_cubit.dart │ │ │ └── menu_state.dart │ │ │ ├── pages │ │ │ └── menu_drawer_page.dart │ │ │ └── widgets │ │ │ ├── menu_tile.dart │ │ │ └── rate_limit_widget.dart │ ├── repositories │ │ ├── data │ │ │ └── repositories │ │ │ │ └── repositories_repository.dart │ │ ├── domain │ │ │ ├── entities │ │ │ │ └── repositories_type.dart │ │ │ ├── repositories │ │ │ │ └── repositories_repository.dart │ │ │ └── usecases │ │ │ │ └── repositories_usecases.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── repositories_cubit.dart │ │ │ ├── repositories_cubit.freezed.dart │ │ │ ├── repositories_cubit.g.dart │ │ │ └── repositories_state.dart │ │ │ └── pages │ │ │ └── repositories_page.dart │ ├── repository │ │ ├── data │ │ │ └── repositories │ │ │ │ └── repos_repository.dart │ │ ├── domain │ │ │ ├── repositories │ │ │ │ └── repos_repository.dart │ │ │ └── usecases │ │ │ │ └── get_repository_usecase.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── repository_cubit.dart │ │ │ ├── repository_cubit.freezed.dart │ │ │ ├── repository_cubit.g.dart │ │ │ └── repository_state.dart │ │ │ └── pages │ │ │ └── repository_page.dart │ ├── search │ │ ├── data │ │ │ └── repositories │ │ │ │ └── search_repository.dart │ │ ├── domain │ │ │ ├── repositories │ │ │ │ └── search_repository.dart │ │ │ └── usecases │ │ │ │ ├── search_repositories_usecase.dart │ │ │ │ └── search_users_usecase.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── search_cubit.dart │ │ │ ├── search_cubit.freezed.dart │ │ │ ├── search_cubit.g.dart │ │ │ └── search_state.dart │ │ │ ├── pages │ │ │ └── search_delegate_page.dart │ │ │ └── widgets │ │ │ ├── repository_tile.dart │ │ │ ├── sort_repository_dropdown.dart │ │ │ ├── sort_user_dropdown.dart │ │ │ └── user_tile.dart │ ├── settings │ │ └── presentation │ │ │ ├── pages │ │ │ └── settings_page.dart │ │ │ └── widgets │ │ │ ├── language_widget.dart │ │ │ ├── setting_tile.dart │ │ │ ├── theme_mode_switch.dart │ │ │ └── theme_selector.dart │ ├── trending │ │ ├── data │ │ │ └── repositories │ │ │ │ └── trend_repository.dart │ │ ├── domain │ │ │ ├── repositories │ │ │ │ └── trend_repository.dart │ │ │ └── usecases │ │ │ │ ├── trending_repositories_usecase.dart │ │ │ │ └── trending_users_usecase.dart │ │ └── presentation │ │ │ ├── cubit │ │ │ ├── trending_cubit.dart │ │ │ ├── trending_cubit.freezed.dart │ │ │ ├── trending_cubit.g.dart │ │ │ └── trending_state.dart │ │ │ ├── pages │ │ │ └── trending_page.dart │ │ │ └── widgets │ │ │ ├── search_tab_bar.dart │ │ │ ├── since_tab_bar.dart │ │ │ ├── trending_repository_tile.dart │ │ │ └── trending_user_tile.dart │ └── user │ │ ├── data │ │ └── repositories │ │ │ └── users_repository.dart │ │ ├── domain │ │ ├── repositories │ │ │ └── users_repository.dart │ │ └── usecases │ │ │ └── get_user_usecase.dart │ │ └── presentation │ │ ├── cubit │ │ ├── user_cubit.dart │ │ ├── user_cubit.freezed.dart │ │ ├── user_cubit.g.dart │ │ └── user_state.dart │ │ └── pages │ │ └── user_page.dart ├── generated │ ├── intl │ │ ├── messages_all.dart │ │ ├── messages_en_US.dart │ │ ├── messages_hy_AM.dart │ │ └── messages_ru_RU.dart │ └── l10n.dart ├── l10n │ ├── intl_en_US.arb │ ├── intl_hy_AM.arb │ ├── intl_ru_RU.arb │ └── localizations.dart ├── main.dart └── utils │ ├── app_router.dart │ ├── bloc_observer.dart │ ├── di.dart │ ├── extensions.dart │ ├── helpers.dart │ ├── scroll_behavior.dart │ ├── secure_storage.dart │ └── shared_pref.dart ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Podfile.lock ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── test ├── features │ ├── presentation │ │ └── cubit │ │ │ └── trending │ │ │ └── trending_cubit_test.dart │ └── repositories │ │ └── data │ │ └── datasources │ │ └── restapi │ │ ├── repos_service_test.dart │ │ ├── search_service_test.dart │ │ └── users_service_test.dart └── widget_test.dart ├── web ├── auth.html ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html ├── manifest.json └── splash │ ├── img │ ├── dark-1x.png │ ├── dark-2x.png │ ├── dark-3x.png │ ├── dark-4x.png │ ├── light-1x.png │ ├── light-2x.png │ ├── light-3x.png │ └── light-4x.png │ ├── splash.js │ └── style.css └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | enable-beta-ecosystems: true 8 | updates: 9 | - package-ecosystem: "github-actions" # See documentation for possible values 10 | directory: "/" # Location of package manifests 11 | schedule: 12 | interval: "monthly" 13 | reviewers: 14 | - "khoren93" 15 | 16 | - package-ecosystem: "pub" 17 | directory: "/" 18 | schedule: 19 | interval: "monthly" 20 | reviewers: 21 | - "khoren93" 22 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Flutter CI 2 | 3 | # This workflow is triggered on pushes to the repository. 4 | on: 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | build: 11 | # This job will run on ubuntu virtual machine 12 | runs-on: ubuntu-latest 13 | steps: 14 | # Setup Java environment in order to build the Android app. 15 | - uses: actions/checkout@v4 16 | - uses: actions/setup-java@v4 17 | with: 18 | java-version: 11 19 | distribution: temurin 20 | 21 | # Setup the flutter environment. 22 | - uses: subosito/flutter-action@v2 23 | with: 24 | channel: "stable" 25 | cache: true 26 | 27 | - name: Install dependencies 28 | run: flutter pub get 29 | 30 | - name: Verify formatting 31 | run: dart format . 32 | 33 | - name: Analyze project source 34 | run: dart analyze 35 | 36 | - name: Run tests 37 | run: flutter test 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | 48 | # Ignore all generated files 49 | # lib/generated 50 | # *.chopper.dart 51 | # *.freezed.dart 52 | # *.g.dart -------------------------------------------------------------------------------- /.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: ee4e09cce01d6f2d7f4baebd247fde02e5008851 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: ee4e09cce01d6f2d7f4baebd247fde02e5008851 17 | base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 18 | - platform: macos 19 | create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 20 | base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "flutterhub", 9 | "request": "launch", 10 | "type": "dart" 11 | }, 12 | { 13 | "name": "flutterhub (profile mode)", 14 | "request": "launch", 15 | "type": "dart", 16 | "flutterMode": "profile" 17 | }, 18 | { 19 | "name": "flutterhub (release mode)", 20 | "request": "launch", 21 | "type": "dart", 22 | "flutterMode": "release" 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Khoren Markosyan 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 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | linter: 4 | rules: 5 | 6 | analyzer: 7 | exclude: 8 | - "lib/generated_plugin_registrant.dart" 9 | - "**/*.g.dart" 10 | - "**/*.freezed.dart" 11 | - "**/*.chopper.dart" 12 | errors: 13 | invalid_annotation_target: ignore -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 46 | applicationId "com.markosyan.flutterhub" 47 | minSdkVersion 21 48 | targetSdkVersion flutter.targetSdkVersion 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /android/app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/markosyan/flutterhub/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.markosyan.flutterhub 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-hdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-hdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-mdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-mdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-night-v21/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-night-v21/background.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-night-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-night/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-night/background.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-night/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-v21/background.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-xhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-xxhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-xxxhdpi/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable-xxxhdpi/splash.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/drawable/background.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night-v31/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 17 | 20 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-v31/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #01579B 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 17 | 20 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.21' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.2.0' 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 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/images/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/assets/images/app_icon.png -------------------------------------------------------------------------------- /assets/images/app_icon_adaptive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/assets/images/app_icon_adaptive.png -------------------------------------------------------------------------------- /assets/images/app_icon_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/assets/images/app_icon_border.png -------------------------------------------------------------------------------- /assets/images/app_icon_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/assets/images/app_icon_round.png -------------------------------------------------------------------------------- /assets/images/app_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/assets/images/app_logo.png -------------------------------------------------------------------------------- /build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | builders: 4 | json_serializable: 5 | options: 6 | explicit_to_json: true 7 | field_rename: snake 8 | freezed: 9 | options: -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_native_splash (0.0.1): 4 | - Flutter 5 | - flutter_secure_storage (3.3.1): 6 | - Flutter 7 | - flutter_web_auth (0.4.1): 8 | - Flutter 9 | - FMDB (2.7.5): 10 | - FMDB/standard (= 2.7.5) 11 | - FMDB/standard (2.7.5) 12 | - path_provider_ios (0.0.1): 13 | - Flutter 14 | - shared_preferences_ios (0.0.1): 15 | - Flutter 16 | - sqflite (0.0.2): 17 | - Flutter 18 | - FMDB (>= 2.7.5) 19 | - url_launcher_ios (0.0.1): 20 | - Flutter 21 | 22 | DEPENDENCIES: 23 | - Flutter (from `Flutter`) 24 | - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) 25 | - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) 26 | - flutter_web_auth (from `.symlinks/plugins/flutter_web_auth/ios`) 27 | - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) 28 | - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) 29 | - sqflite (from `.symlinks/plugins/sqflite/ios`) 30 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 31 | 32 | SPEC REPOS: 33 | trunk: 34 | - FMDB 35 | 36 | EXTERNAL SOURCES: 37 | Flutter: 38 | :path: Flutter 39 | flutter_native_splash: 40 | :path: ".symlinks/plugins/flutter_native_splash/ios" 41 | flutter_secure_storage: 42 | :path: ".symlinks/plugins/flutter_secure_storage/ios" 43 | flutter_web_auth: 44 | :path: ".symlinks/plugins/flutter_web_auth/ios" 45 | path_provider_ios: 46 | :path: ".symlinks/plugins/path_provider_ios/ios" 47 | shared_preferences_ios: 48 | :path: ".symlinks/plugins/shared_preferences_ios/ios" 49 | sqflite: 50 | :path: ".symlinks/plugins/sqflite/ios" 51 | url_launcher_ios: 52 | :path: ".symlinks/plugins/url_launcher_ios/ios" 53 | 54 | SPEC CHECKSUMS: 55 | Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a 56 | flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef 57 | flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec 58 | flutter_web_auth: 09a0abd245f1a07a3ff4dcf1247a048d89ee12a9 59 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a 60 | path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 61 | shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad 62 | sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 63 | url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de 64 | 65 | PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c 66 | 67 | COCOAPODS: 1.11.3 68 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "background.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "appearances" : [ 10 | { 11 | "appearance" : "luminosity", 12 | "value" : "dark" 13 | } 14 | ], 15 | "filename" : "darkbackground.png", 16 | "idiom" : "universal", 17 | "scale" : "1x" 18 | }, 19 | { 20 | "idiom" : "universal", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "appearances" : [ 25 | { 26 | "appearance" : "luminosity", 27 | "value" : "dark" 28 | } 29 | ], 30 | "idiom" : "universal", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "universal", 35 | "scale" : "3x" 36 | }, 37 | { 38 | "appearances" : [ 39 | { 40 | "appearance" : "luminosity", 41 | "value" : "dark" 42 | } 43 | ], 44 | "idiom" : "universal", 45 | "scale" : "3x" 46 | } 47 | ], 48 | "info" : { 49 | "author" : "xcode", 50 | "version" : 1 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchBackground.imageset/darkbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/LaunchBackground.imageset/darkbackground.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "LaunchImage.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "LaunchImage@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "filename" : "LaunchImage@3x.png", 15 | "idiom" : "universal", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "author" : "xcode", 21 | "version" : 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | FlutterHub 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutterhub 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLSchemes 29 | 30 | flutterhub 31 | 32 | 33 | 34 | CFBundleVersion 35 | $(FLUTTER_BUILD_NUMBER) 36 | LSRequiresIPhoneOS 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIMainStoryboardFile 41 | Main 42 | UIStatusBarHidden 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UISupportedInterfaceOrientations~ipad 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationPortraitUpsideDown 54 | UIInterfaceOrientationLandscapeLeft 55 | UIInterfaceOrientationLandscapeRight 56 | 57 | UIViewControllerBasedStatusBarAppearance 58 | 59 | CADisableMinimumFrameDurationOnPhone 60 | 61 | 62 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_localizations/flutter_localizations.dart'; 4 | import 'package:flutter_mobx/flutter_mobx.dart'; 5 | import 'package:flutterhub/utils/extensions.dart'; 6 | 7 | import 'utils/app_router.dart'; 8 | import 'configs/app_store.dart'; 9 | import 'configs/app_theme.dart'; 10 | import 'utils/di.dart'; 11 | import 'features/languages/presentation/cubit/languages_cubit.dart'; 12 | import 'features/login/presentation/cubit/login_cubit.dart'; 13 | import 'features/search/presentation/cubit/search_cubit.dart'; 14 | import 'features/trending/presentation/cubit/trending_cubit.dart'; 15 | import 'generated/l10n.dart'; 16 | import 'l10n/localizations.dart'; 17 | import 'utils/scroll_behavior.dart'; 18 | 19 | class MyApp extends StatefulWidget { 20 | const MyApp({super.key}); 21 | 22 | @override 23 | State createState() => _MyAppState(); 24 | } 25 | 26 | class _MyAppState extends State { 27 | final _appRouter = AppRouter(); 28 | 29 | @override 30 | Widget build(BuildContext context) { 31 | return MultiBlocProvider( 32 | providers: [ 33 | BlocProvider(create: (_) => di()), 34 | BlocProvider(create: (_) => di()), 35 | BlocProvider(create: (_) => di()), 36 | BlocProvider(create: (_) => di()), 37 | ], 38 | child: Observer( 39 | builder: (_) => MaterialApp( 40 | title: 'FlutterHub', 41 | theme: AppTheme.flexLightTheme(), 42 | darkTheme: AppTheme.flexDarkTheme(), 43 | themeMode: appStore.themeMode, 44 | localizationsDelegates: const [ 45 | S.delegate, 46 | MyRefreshLocalizations.delegate, 47 | GlobalMaterialLocalizations.delegate, 48 | GlobalWidgetsLocalizations.delegate, 49 | GlobalCupertinoLocalizations.delegate, 50 | ], 51 | supportedLocales: S.delegate.supportedLocales, 52 | locale: appStore.selectedLanguage.parseLocale(), 53 | onGenerateRoute: _appRouter.onGenerateRoute, 54 | scrollBehavior: MyCustomScrollBehavior(), 55 | debugShowCheckedModeBanner: false, 56 | ), 57 | ), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/configs/app_store.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | import 'package:flutterhub/features/menu/data/models/rate_limit.dart'; 4 | import 'package:flutterhub/utils/secure_storage.dart'; 5 | import 'package:flutterhub/utils/shared_pref.dart'; 6 | import 'package:mobx/mobx.dart'; 7 | 8 | part 'app_store.g.dart'; 9 | 10 | AppStore appStore = AppStore(); 11 | 12 | class AppStore = AppStoreBase with _$AppStore; 13 | 14 | const currentUserPref = 'currentUserPref'; 15 | const isUserLoggedInPref = 'isUserLoggedInPref'; 16 | const themeModePref = 'themeModePref'; 17 | const colorSchemeIndexPref = 'colorSchemeIndexPref'; 18 | const isNotificationsOnPref = 'isNotificationsOnPref'; 19 | const languagePref = 'languagePref'; 20 | 21 | abstract class AppStoreBase with Store { 22 | @observable 23 | bool hasInternetConnection = true; 24 | 25 | @observable 26 | Token? token; 27 | 28 | @observable 29 | User? currentUser; 30 | 31 | @observable 32 | bool isUserLoggedIn = false; 33 | 34 | @observable 35 | ThemeMode themeMode = ThemeMode.system; 36 | 37 | @observable 38 | int colorSchemeIndex = 4; 39 | 40 | @observable 41 | bool isNotificationsOn = true; 42 | 43 | @observable 44 | String selectedLanguage = 'en_US'; 45 | 46 | @observable 47 | RateLimit rateLimit = RateLimit(); 48 | 49 | @action 50 | Future saveToken(Token value) async { 51 | token = value; 52 | isUserLoggedIn = true; 53 | await SecureStorage.instance.saveToken(value); 54 | } 55 | 56 | @action 57 | Future deleteToken() async { 58 | token = null; 59 | isUserLoggedIn = false; 60 | rateLimit = RateLimit(); 61 | await SecureStorage.instance.deleteToken(); 62 | } 63 | 64 | @action 65 | Future saveUser(User value) async { 66 | currentUser = value; 67 | await setPrefValue(currentUserPref, value.toJson()); 68 | } 69 | 70 | @action 71 | Future deleteUser() async { 72 | currentUser = null; 73 | await removePrefKey(currentUserPref); 74 | } 75 | 76 | @action 77 | Future setThemeMode(ThemeMode value) async { 78 | themeMode = value; 79 | setPrefValue(themeModePref, themeMode.toString()); 80 | } 81 | 82 | @action 83 | Future setColorSchemeIndex(int value) async { 84 | colorSchemeIndex = value; 85 | await setPrefValue(colorSchemeIndexPref, colorSchemeIndex); 86 | } 87 | 88 | @action 89 | Future toggleNotificationsMode({bool? value}) async { 90 | isNotificationsOn = value ?? !isNotificationsOn; 91 | setPrefValue(isNotificationsOnPref, isNotificationsOn); 92 | } 93 | 94 | @action 95 | Future setLanguage(String aLanguage) async { 96 | selectedLanguage = aLanguage; 97 | await setPrefValue(languagePref, aLanguage); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/configs/app_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flex_color_scheme/flex_color_scheme.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:google_fonts/google_fonts.dart'; 4 | 5 | import 'app_store.dart'; 6 | 7 | class AppTheme { 8 | AppTheme._(); 9 | 10 | static ThemeData flexLightTheme() => FlexThemeData.light( 11 | colors: FlexColor.schemesList[appStore.colorSchemeIndex].light, 12 | fontFamily: GoogleFonts.roboto().fontFamily, 13 | tabBarStyle: FlexTabBarStyle.forAppBar, 14 | surfaceMode: FlexSurfaceMode.highScaffoldLevelSurface, 15 | blendLevel: 12, 16 | ); 17 | 18 | static ThemeData flexDarkTheme() => FlexThemeData.dark( 19 | colors: FlexColor.schemesList[appStore.colorSchemeIndex].dark, 20 | fontFamily: GoogleFonts.roboto().fontFamily, 21 | tabBarStyle: FlexTabBarStyle.forAppBar, 22 | surfaceMode: FlexSurfaceMode.highScaffoldLevelSurface, 23 | blendLevel: 6, 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /lib/configs/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const kGithubApiBaseUrl = 'https://api.github.com'; 4 | const kStarHistoryBaseUrl = 'https://star-history.com'; 5 | const kProfileSummaryBaseUrl = 'https://profile-summary-for-github.com'; 6 | 7 | // ALL KEYS ARE DEMONSTRATIVE AND ARE USED FOR THE TEST. 8 | const kGithubClientId = 'b2fe416e9e6796ee6363'; 9 | const kGithubClientSecret = 'a93cf9cbffecb02d44c24918c9a31a6933580737'; 10 | const kGithubScope = 'user+repo+notifications+read:org'; 11 | const kGithubRedirectUrl = 'flutterhub'; 12 | const kPerPage = 20; 13 | 14 | const kUnexpectedError = 'Unexpected error'; 15 | const kUnknownServerError = 'Unknown server error'; 16 | const kNoInternetConnection = 'No internet connection'; 17 | 18 | /// space between widgets 19 | const spaceSmall = 2.0; 20 | const spaceSmall2 = 4.0; 21 | const spaceMedium = 8.0; 22 | const spaceDefault = 16.0; 23 | const spaceLarge = 24.0; 24 | const spaceLarge2 = 32.0; 25 | const spaceLarge3 = 40.0; 26 | const spaceLarge4 = 96.0; 27 | 28 | const spaceMaxWidth = 736.0; 29 | const spaceMaxGridItemWidth = 192.0; 30 | 31 | /// padding widgets 32 | const paddingSmall = EdgeInsets.all(spaceSmall2); 33 | const paddingSmallMedium = 34 | EdgeInsets.symmetric(vertical: spaceSmall2, horizontal: spaceMedium); 35 | const paddingSmallDefault = 36 | EdgeInsets.symmetric(vertical: spaceSmall2, horizontal: spaceDefault); 37 | const paddingDefault = EdgeInsets.all(spaceDefault); 38 | const paddingDefaultLargeBottom = 39 | EdgeInsets.fromLTRB(spaceDefault, spaceDefault, spaceDefault, spaceLarge4); 40 | -------------------------------------------------------------------------------- /lib/features/core/data/datasources/restapi/login_service.dart: -------------------------------------------------------------------------------- 1 | part of 'rest_service.dart'; 2 | 3 | @ChopperApi(baseUrl: 'https://github.com/login') 4 | abstract class LoginService extends ChopperService { 5 | static LoginService create([ChopperClient? client]) => _$LoginService(client); 6 | 7 | @Post( 8 | path: '/oauth/access_token', 9 | headers: {'Accept': 'application/json'}, 10 | optionalBody: true, 11 | ) 12 | Future> createAccessToken( 13 | @Query('client_id') String clientId, 14 | @Query('client_secret') String clientSecret, 15 | @Query() String code, 16 | @Query('redirect_uri') String redirectUri, 17 | @Query() String state, 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/core/data/datasources/restapi/repos_service.dart: -------------------------------------------------------------------------------- 1 | part of 'rest_service.dart'; 2 | 3 | @ChopperApi(baseUrl: '/repos') 4 | abstract class ReposService extends ChopperService { 5 | static ReposService create([ChopperClient? client]) => _$ReposService(client); 6 | 7 | @Get(path: '/{fullname}') 8 | Future> repository( 9 | @Path() String fullname, 10 | ); 11 | 12 | @Get(path: '/{fullname}/forks') 13 | Future>> forks( 14 | @Path() String fullname, 15 | @Query() int page, 16 | @Query('per_page') int perPage, 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /lib/features/core/data/datasources/restapi/search_service.dart: -------------------------------------------------------------------------------- 1 | part of 'rest_service.dart'; 2 | 3 | @ChopperApi(baseUrl: '/search') 4 | abstract class SearchService extends ChopperService { 5 | static SearchService create([ChopperClient? client]) => 6 | _$SearchService(client); 7 | 8 | @Get(path: '/repositories') 9 | Future> searchRepositories( 10 | @Query('q') String query, 11 | @Query() String order, 12 | @Query() String sort, 13 | @Query() int page, 14 | @Query('per_page') int perPage, 15 | ); 16 | 17 | @Get(path: '/users') 18 | Future> searchUsers( 19 | @Query('q') String query, 20 | @Query() String order, 21 | @Query() String sort, 22 | @Query() int page, 23 | @Query('per_page') int perPage, 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /lib/features/core/data/datasources/restapi/trending_service.dart: -------------------------------------------------------------------------------- 1 | part of 'rest_service.dart'; 2 | 3 | @ChopperApi(baseUrl: '') 4 | abstract class TrendingService extends ChopperService { 5 | static TrendingService create([ChopperClient? client]) => 6 | _$TrendingService(client); 7 | 8 | @Get(path: '/repositories') 9 | Future>> trendingRepositories( 10 | @Query() String language, 11 | @Query() String since, 12 | ); 13 | 14 | @Get(path: '/developers') 15 | Future>> trendingDevelopers( 16 | @Query() String language, 17 | @Query() String since, 18 | ); 19 | 20 | @Get(path: '/languages') 21 | Future>> languages(); 22 | } 23 | -------------------------------------------------------------------------------- /lib/features/core/data/datasources/restapi/user_service.dart: -------------------------------------------------------------------------------- 1 | part of 'rest_service.dart'; 2 | 3 | @ChopperApi(baseUrl: '/user') 4 | abstract class UserService extends ChopperService { 5 | static UserService create([ChopperClient? client]) => _$UserService(client); 6 | 7 | @Get() 8 | Future> user(); 9 | } 10 | -------------------------------------------------------------------------------- /lib/features/core/data/datasources/restapi/users_service.dart: -------------------------------------------------------------------------------- 1 | part of 'rest_service.dart'; 2 | 3 | @ChopperApi(baseUrl: '/users') 4 | abstract class UsersService extends ChopperService { 5 | static UsersService create([ChopperClient? client]) => _$UsersService(client); 6 | 7 | @Get(path: '/{owner}') 8 | Future> user( 9 | @Path() String owner, 10 | ); 11 | 12 | @Get(path: '/{username}/repos') 13 | Future>> repositories( 14 | @Path() String username, 15 | @Query() int page, 16 | @Query('per_page') int perPage, 17 | ); 18 | 19 | @Get(path: '/{username}/starred') 20 | Future>> starredRepositories( 21 | @Path() String username, 22 | @Query() int page, 23 | @Query('per_page') int perPage, 24 | ); 25 | 26 | @Get(path: '/{username}/subscriptions') 27 | Future>> watchingRepositories( 28 | @Path() String username, 29 | @Query() int page, 30 | @Query('per_page') int perPage, 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /lib/features/core/data/models/failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutterhub/configs/constants.dart'; 3 | import 'package:freezed_annotation/freezed_annotation.dart'; 4 | 5 | part 'failure.freezed.dart'; 6 | part 'failure.g.dart'; 7 | 8 | abstract class Failure extends Equatable { 9 | const Failure(); 10 | 11 | @override 12 | List get props => []; 13 | 14 | String messageText() { 15 | if (this is ServerFailure) { 16 | return (this as ServerFailure).message ?? ''; 17 | } else { 18 | return kUnexpectedError; 19 | } 20 | } 21 | 22 | String documentationUrlText() { 23 | if (this is ServerFailure) { 24 | return (this as ServerFailure).documentationUrl ?? ''; 25 | } else { 26 | return kUnexpectedError; 27 | } 28 | } 29 | } 30 | 31 | @Freezed() 32 | class ServerFailure extends Failure with _$ServerFailure { 33 | const ServerFailure._(); 34 | 35 | const factory ServerFailure({ 36 | String? message, 37 | String? documentationUrl, 38 | List? errors, 39 | }) = _ServerFailure; 40 | 41 | factory ServerFailure.fromJson(Map json) => 42 | _$ServerFailureFromJson(json); 43 | 44 | static unknown() => const ServerFailure( 45 | message: kUnknownServerError, 46 | ); 47 | } 48 | 49 | @Freezed() 50 | class ServerError with _$ServerError { 51 | const ServerError._(); 52 | 53 | const factory ServerError({ 54 | String? code, 55 | String? message, 56 | String? field, 57 | String? resource, 58 | }) = _ServerError; 59 | 60 | factory ServerError.fromJson(Map json) => 61 | _$ServerErrorFromJson(json); 62 | } 63 | 64 | // Object to ServerFailure conversion functions 65 | extension ServerFailureExt on Object? { 66 | ServerFailure toServerFailure() { 67 | if (this is Map) { 68 | return ServerFailure.fromJson(this as Map); 69 | } else { 70 | return ServerFailure.unknown(); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/features/core/data/models/failure.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'failure.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$ServerFailureImpl _$$ServerFailureImplFromJson(Map json) => 10 | _$ServerFailureImpl( 11 | message: json['message'] as String?, 12 | documentationUrl: json['documentation_url'] as String?, 13 | errors: (json['errors'] as List?) 14 | ?.map((e) => ServerError.fromJson(e as Map)) 15 | .toList(), 16 | ); 17 | 18 | Map _$$ServerFailureImplToJson(_$ServerFailureImpl instance) => 19 | { 20 | 'message': instance.message, 21 | 'documentation_url': instance.documentationUrl, 22 | 'errors': instance.errors?.map((e) => e.toJson()).toList(), 23 | }; 24 | 25 | _$ServerErrorImpl _$$ServerErrorImplFromJson(Map json) => 26 | _$ServerErrorImpl( 27 | code: json['code'] as String?, 28 | message: json['message'] as String?, 29 | field: json['field'] as String?, 30 | resource: json['resource'] as String?, 31 | ); 32 | 33 | Map _$$ServerErrorImplToJson(_$ServerErrorImpl instance) => 34 | { 35 | 'code': instance.code, 36 | 'message': instance.message, 37 | 'field': instance.field, 38 | 'resource': instance.resource, 39 | }; 40 | -------------------------------------------------------------------------------- /lib/features/core/data/repositories/repositories.dart: -------------------------------------------------------------------------------- 1 | export 'package:flutterhub/features/repository/data/repositories/repos_repository.dart'; 2 | export 'package:flutterhub/features/search/data/repositories/search_repository.dart'; 3 | export 'package:flutterhub/features/trending/data/repositories/trend_repository.dart'; 4 | export 'package:flutterhub/features/menu/data/repositories/user_repository.dart'; 5 | export 'package:flutterhub/features/user/data/repositories/users_repository.dart'; 6 | export 'package:flutterhub/features/login/data/repositories/login_repository.dart'; 7 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/models.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:freezed_annotation/freezed_annotation.dart'; 4 | 5 | part 'models.freezed.dart'; 6 | part 'models.g.dart'; 7 | part 'repository_language.dart'; 8 | part 'repository_search.dart'; 9 | part 'repository.dart'; 10 | part 'token.dart'; 11 | part 'trending_repository.dart'; 12 | part 'trending_user.dart'; 13 | part 'user_search.dart'; 14 | part 'user.dart'; 15 | 16 | extension StringExtension on String? { 17 | int? parseColor() { 18 | if (this == null) return null; 19 | return int.tryParse(this?.replaceAll('#', '0xff') ?? ''); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/repository.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | @Freezed() 4 | class Repository with _$Repository { 5 | const Repository._(); 6 | const factory Repository({ 7 | String? name, 8 | String? fullName, 9 | bool? private, 10 | User? owner, 11 | String? htmlUrl, 12 | String? description, 13 | bool? fork, 14 | DateTime? createdAt, 15 | DateTime? updatedAt, 16 | String? homepage, 17 | double? size, 18 | int? stargazersCount, 19 | String? language, 20 | String? languageColor, 21 | int? forksCount, 22 | bool? archived, 23 | int? openIssuesCount, 24 | List? topics, 25 | String? defaultBranch, 26 | int? subscribersCount, 27 | Repository? parent, 28 | }) = _Repository; 29 | 30 | factory Repository.fromJson(Map json) => 31 | _$RepositoryFromJson(json); 32 | 33 | int? get color => languageColor.parseColor(); 34 | } 35 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/repository_language.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | @Freezed() 4 | class RepositoryLanguage with _$RepositoryLanguage { 5 | const RepositoryLanguage._(); 6 | const factory RepositoryLanguage({ 7 | String? name, 8 | @JsonKey(name: 'urlParam') String? urlParam, 9 | }) = _RepositoryLanguage; 10 | 11 | factory RepositoryLanguage.fromJson(Map json) => 12 | _$RepositoryLanguageFromJson(json); 13 | } 14 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/repository_search.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | @Freezed() 4 | class RepositorySearch with _$RepositorySearch { 5 | const RepositorySearch._(); 6 | 7 | const factory RepositorySearch({ 8 | List? items, 9 | int? totalCount, 10 | bool? incompleteResults, 11 | }) = _RepositorySearch; 12 | 13 | factory RepositorySearch.fromJson(Map json) => 14 | _$RepositorySearchFromJson(json); 15 | 16 | bool get isEmpty => items?.isEmpty ?? true; 17 | bool get hasNextPage => items?.isNotEmpty ?? false; 18 | } 19 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/token.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | enum TokenType { oauth, personal, basic } 4 | 5 | @Freezed() 6 | class Token with _$Token { 7 | const Token._(); 8 | const factory Token({ 9 | TokenType? type, 10 | String? basicToken, 11 | String? personalToken, 12 | String? accessToken, 13 | String? tokenType, 14 | String? scope, 15 | }) = _Token; 16 | 17 | factory Token.fromJson(Map json) => _$TokenFromJson(json); 18 | 19 | String toJsonString() => jsonEncode(toJson()); 20 | 21 | String? get token { 22 | switch (type) { 23 | case TokenType.oauth: 24 | return 'token $accessToken'; 25 | case TokenType.personal: 26 | return 'token $personalToken'; 27 | case TokenType.basic: 28 | return 'Basic $basicToken'; 29 | default: 30 | return null; 31 | } 32 | } 33 | 34 | bool get isValid { 35 | switch (type) { 36 | case TokenType.oauth: 37 | return accessToken != null; 38 | case TokenType.personal: 39 | return personalToken != null; 40 | case TokenType.basic: 41 | return basicToken != null; 42 | default: 43 | return false; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/trending_repository.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | @Freezed() 4 | class TrendingRepository with _$TrendingRepository { 5 | const TrendingRepository._(); 6 | const factory TrendingRepository({ 7 | String? author, 8 | String? name, 9 | String? avatar, 10 | String? url, 11 | String? description, 12 | String? language, 13 | @JsonKey(name: 'languageColor') String? languageColor, 14 | int? stars, 15 | int? forks, 16 | @JsonKey(name: 'currentPeriodStars') int? currentPeriodStars, 17 | @JsonKey(name: 'builtBy') List? builtBy, 18 | }) = _TrendingRepository; 19 | 20 | factory TrendingRepository.fromJson(Map json) => 21 | _$TrendingRepositoryFromJson(json); 22 | 23 | String get fullName => '$author/$name'; 24 | int? get color => languageColor.parseColor(); 25 | } 26 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/trending_user.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | @Freezed() 4 | class TrendingUser with _$TrendingUser { 5 | const TrendingUser._(); 6 | const factory TrendingUser({ 7 | String? username, 8 | String? name, 9 | String? url, 10 | String? avatar, 11 | TrendingRepository? repo, 12 | String? type, 13 | }) = _TrendingUser; 14 | 15 | factory TrendingUser.fromJson(Map json) => 16 | _$TrendingUserFromJson(json); 17 | } 18 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/user.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | enum UserType { 4 | @JsonValue('User') 5 | user, 6 | @JsonValue('Organization') 7 | organization, 8 | } 9 | 10 | @Freezed() 11 | class User with _$User { 12 | const User._(); 13 | const factory User({ 14 | String? login, 15 | String? avatarUrl, 16 | String? htmlUrl, 17 | UserType? type, 18 | String? name, 19 | String? company, 20 | String? blog, 21 | String? location, 22 | String? email, 23 | String? bio, 24 | int? publicRepos, 25 | int? publicGists, 26 | int? followers, 27 | int? following, 28 | DateTime? createdAt, 29 | DateTime? updatedAt, 30 | int? starredRepositoriesCount, 31 | int? repositoriesCount, 32 | int? issuesCount, 33 | int? watchingCount, 34 | }) = _User; 35 | 36 | factory User.fromJson(Map json) => _$UserFromJson(json); 37 | } 38 | -------------------------------------------------------------------------------- /lib/features/core/domain/entities/user_search.dart: -------------------------------------------------------------------------------- 1 | part of 'models.dart'; 2 | 3 | @Freezed() 4 | class UserSearch with _$UserSearch { 5 | const UserSearch._(); 6 | const factory UserSearch({ 7 | List? items, 8 | int? totalCount, 9 | bool? incompleteResults, 10 | }) = _UserSearch; 11 | 12 | factory UserSearch.fromJson(Map json) => 13 | _$UserSearchFromJson(json); 14 | 15 | bool get isEmpty => items?.isEmpty ?? true; 16 | bool get hasNextPage => items?.isNotEmpty ?? false; 17 | } 18 | -------------------------------------------------------------------------------- /lib/features/core/domain/repositories/repositories.dart: -------------------------------------------------------------------------------- 1 | export 'package:flutterhub/features/repository/domain/repositories/repos_repository.dart'; 2 | export 'package:flutterhub/features/search/domain/repositories/search_repository.dart'; 3 | export 'package:flutterhub/features/trending/domain/repositories/trend_repository.dart'; 4 | export 'package:flutterhub/features/menu/domain/repositories/user_repository.dart'; 5 | export 'package:flutterhub/features/user/domain/repositories/users_repository.dart'; 6 | export 'package:flutterhub/features/login/domain/repositories/login_repository.dart'; 7 | -------------------------------------------------------------------------------- /lib/features/core/domain/usecases/usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | 4 | abstract class UseCase { 5 | Future> call(Params params); 6 | } 7 | -------------------------------------------------------------------------------- /lib/features/core/domain/usecases/usecases.dart: -------------------------------------------------------------------------------- 1 | export 'package:flutterhub/features/login/domain/usecases/login_usecase.dart'; 2 | export 'package:flutterhub/features/repository/domain/usecases/get_repository_usecase.dart'; 3 | export 'package:flutterhub/features/user/domain/usecases/get_user_usecase.dart'; 4 | export 'package:flutterhub/features/languages/domain/usecases/languages_usecase.dart'; 5 | export 'package:flutterhub/features/search/domain/usecases/search_repositories_usecase.dart'; 6 | export 'package:flutterhub/features/search/domain/usecases/search_users_usecase.dart'; 7 | export 'package:flutterhub/features/trending/domain/usecases/trending_repositories_usecase.dart'; 8 | export 'package:flutterhub/features/trending/domain/usecases/trending_users_usecase.dart'; 9 | export 'package:flutterhub/features/menu/domain/usecases/user_usecase.dart'; 10 | -------------------------------------------------------------------------------- /lib/features/core/presentation/cubit/cubits.dart: -------------------------------------------------------------------------------- 1 | export 'package:flutterhub/features/login/presentation/cubit/login_cubit.dart'; 2 | export 'package:flutterhub/features/repository/presentation/cubit/repository_cubit.dart'; 3 | export 'package:flutterhub/features/search/presentation/cubit/search_cubit.dart'; 4 | export 'package:flutterhub/features/trending/presentation/cubit/trending_cubit.dart'; 5 | export 'package:flutterhub/features/languages/presentation/cubit/languages_cubit.dart'; 6 | export 'package:flutterhub/features/user/presentation/cubit/user_cubit.dart'; 7 | -------------------------------------------------------------------------------- /lib/features/core/presentation/widgets/app_logo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class AppLogo extends StatelessWidget { 4 | const AppLogo({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Image.asset('assets/images/app_logo.png'); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/features/core/presentation/widgets/common_widgets.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/configs/constants.dart'; 3 | 4 | class ContainerX extends StatelessWidget { 5 | const ContainerX({super.key, this.child}); 6 | 7 | final Widget? child; 8 | @override 9 | Widget build(BuildContext context) { 10 | return Center( 11 | child: Container( 12 | constraints: const BoxConstraints(maxWidth: spaceMaxWidth), 13 | child: child, 14 | ), 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/features/home/presentation/pages/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutterhub/utils/di.dart'; 4 | import 'package:flutterhub/features/trending/presentation/pages/trending_page.dart'; 5 | import 'package:flutterhub/features/user/presentation/cubit/user_cubit.dart'; 6 | 7 | class HomePage extends StatelessWidget { 8 | const HomePage({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return BlocProvider( 13 | create: (context) => UserCubit(di()), 14 | child: const TrendingPage(), 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/features/languages/domain/usecases/languages_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | import 'package:flutterhub/features/trending/domain/repositories/trend_repository.dart'; 5 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 6 | 7 | class LanguagesUsecase extends UseCase, void> { 8 | LanguagesUsecase(this._repository); 9 | final TrendRepository _repository; 10 | 11 | @override 12 | Future>> call(params) async { 13 | try { 14 | return _repository.languages(); 15 | } catch (e) { 16 | return Left(ServerFailure.unknown()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/languages/presentation/cubit/languages_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | import 'package:flutterhub/features/languages/domain/usecases/languages_usecase.dart'; 5 | import 'package:freezed_annotation/freezed_annotation.dart'; 6 | 7 | import '../../../../configs/constants.dart'; 8 | 9 | part 'languages_state.dart'; 10 | part 'languages_cubit.freezed.dart'; 11 | part 'languages_cubit.g.dart'; 12 | 13 | class LanguagesCubit extends Cubit { 14 | LanguagesCubit( 15 | this.languagesUsecase, 16 | ) : super(const LanguagesState.initial()); 17 | 18 | final LanguagesUsecase languagesUsecase; 19 | 20 | List _languages = []; 21 | RepositoryLanguage? _selectedLanguage; 22 | 23 | void fetchLanguages() async { 24 | emit(const LanguagesState.fetchInProgress()); 25 | try { 26 | final result = await languagesUsecase(() => null); 27 | result.fold( 28 | (l) => emit(LanguagesState.fetchError( 29 | message: l.messageText(), 30 | )), 31 | (r) { 32 | _languages = r; 33 | emit(r.isEmpty 34 | ? const LanguagesState.fetchEmpty() 35 | : LanguagesState.fetchSuccess( 36 | items: _languages, 37 | selected: _selectedLanguage, 38 | )); 39 | }, 40 | ); 41 | } catch (e) { 42 | debugPrint(e.toString()); 43 | emit(const LanguagesState.fetchError(message: kUnexpectedError)); 44 | } 45 | } 46 | 47 | void searchLanguages(String query) async { 48 | List items = _languages; 49 | if (query.isNotEmpty) { 50 | items = _languages 51 | .where((language) => 52 | (language.urlParam ?? '').contains(query.toLowerCase())) 53 | .toList(); 54 | } 55 | emit(items.isEmpty 56 | ? const LanguagesState.fetchEmpty() 57 | : LanguagesState.fetchSuccess( 58 | items: items, 59 | selected: _selectedLanguage, 60 | )); 61 | } 62 | 63 | void selectLanguage(RepositoryLanguage? language) { 64 | _selectedLanguage = language; 65 | emit(LanguagesState.fetchSuccess( 66 | items: _languages, 67 | selected: _selectedLanguage, 68 | )); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/features/languages/presentation/cubit/languages_cubit.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'languages_cubit.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$InitialImpl _$$InitialImplFromJson(Map json) => 10 | _$InitialImpl( 11 | $type: json['runtimeType'] as String?, 12 | ); 13 | 14 | Map _$$InitialImplToJson(_$InitialImpl instance) => 15 | { 16 | 'runtimeType': instance.$type, 17 | }; 18 | 19 | _$FetchInProgressImpl _$$FetchInProgressImplFromJson( 20 | Map json) => 21 | _$FetchInProgressImpl( 22 | $type: json['runtimeType'] as String?, 23 | ); 24 | 25 | Map _$$FetchInProgressImplToJson( 26 | _$FetchInProgressImpl instance) => 27 | { 28 | 'runtimeType': instance.$type, 29 | }; 30 | 31 | _$FetchEmptyImpl _$$FetchEmptyImplFromJson(Map json) => 32 | _$FetchEmptyImpl( 33 | $type: json['runtimeType'] as String?, 34 | ); 35 | 36 | Map _$$FetchEmptyImplToJson(_$FetchEmptyImpl instance) => 37 | { 38 | 'runtimeType': instance.$type, 39 | }; 40 | 41 | _$FetchSuccessImpl _$$FetchSuccessImplFromJson(Map json) => 42 | _$FetchSuccessImpl( 43 | items: (json['items'] as List) 44 | .map((e) => RepositoryLanguage.fromJson(e as Map)) 45 | .toList(), 46 | selected: json['selected'] == null 47 | ? null 48 | : RepositoryLanguage.fromJson( 49 | json['selected'] as Map), 50 | $type: json['runtimeType'] as String?, 51 | ); 52 | 53 | Map _$$FetchSuccessImplToJson(_$FetchSuccessImpl instance) => 54 | { 55 | 'items': instance.items.map((e) => e.toJson()).toList(), 56 | 'selected': instance.selected?.toJson(), 57 | 'runtimeType': instance.$type, 58 | }; 59 | 60 | _$FetchErrorImpl _$$FetchErrorImplFromJson(Map json) => 61 | _$FetchErrorImpl( 62 | message: json['message'] as String?, 63 | $type: json['runtimeType'] as String?, 64 | ); 65 | 66 | Map _$$FetchErrorImplToJson(_$FetchErrorImpl instance) => 67 | { 68 | 'message': instance.message, 69 | 'runtimeType': instance.$type, 70 | }; 71 | -------------------------------------------------------------------------------- /lib/features/languages/presentation/cubit/languages_state.dart: -------------------------------------------------------------------------------- 1 | part of 'languages_cubit.dart'; 2 | 3 | @freezed 4 | class LanguagesState with _$LanguagesState { 5 | const factory LanguagesState.initial() = _Initial; 6 | 7 | const factory LanguagesState.fetchInProgress() = _FetchInProgress; 8 | const factory LanguagesState.fetchEmpty() = _FetchEmpty; 9 | const factory LanguagesState.fetchSuccess({ 10 | required List items, 11 | required RepositoryLanguage? selected, 12 | }) = _FetchSuccess; 13 | const factory LanguagesState.fetchError({ 14 | String? message, 15 | }) = _FetchError; 16 | 17 | factory LanguagesState.fromJson(Map json) => 18 | _$LanguagesStateFromJson(json); 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/languages/presentation/widgets/language_header_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/configs/constants.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | import 'package:flutterhub/generated/l10n.dart'; 5 | 6 | class LanguageHeaderWidget extends StatelessWidget { 7 | const LanguageHeaderWidget({ 8 | super.key, 9 | required this.context, 10 | required this.language, 11 | }); 12 | 13 | final BuildContext context; 14 | final RepositoryLanguage? language; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Padding( 19 | padding: paddingDefault, 20 | child: Text( 21 | S.current.languageResults(language?.name ?? ''), 22 | style: Theme.of(context).textTheme.titleMedium, 23 | ), 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/features/languages/presentation/widgets/language_tile.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 4 | 5 | class LanguageTile extends StatelessWidget { 6 | const LanguageTile({ 7 | super.key, 8 | required this.item, 9 | this.selected = false, 10 | this.onTap, 11 | }); 12 | 13 | final RepositoryLanguage item; 14 | final bool selected; 15 | final Function(RepositoryLanguage)? onTap; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return Card( 20 | child: ListTile( 21 | title: Text(item.name ?? ''), 22 | trailing: selected ? const Icon(FontAwesomeIcons.check) : null, 23 | selected: selected, 24 | onTap: () { 25 | onTap?.call(item); 26 | }, 27 | ), 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/features/login/data/models/password_input.dart: -------------------------------------------------------------------------------- 1 | import 'package:formz/formz.dart'; 2 | 3 | enum PasswordValidationError { empty } 4 | 5 | class Password extends FormzInput { 6 | const Password.pure() : super.pure(''); 7 | const Password.dirty([super.value = '']) : super.dirty(); 8 | 9 | @override 10 | PasswordValidationError? validator(String? value) { 11 | return value?.isNotEmpty == true ? null : PasswordValidationError.empty; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/features/login/data/models/personal_token_input.dart: -------------------------------------------------------------------------------- 1 | import 'package:formz/formz.dart'; 2 | 3 | enum PersonalTokenValidationError { empty } 4 | 5 | class PersonalToken extends FormzInput { 6 | const PersonalToken.pure() : super.pure(''); 7 | const PersonalToken.dirty([super.value = '']) : super.dirty(); 8 | 9 | @override 10 | PersonalTokenValidationError? validator(String? value) { 11 | return value?.isNotEmpty == true 12 | ? null 13 | : PersonalTokenValidationError.empty; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/features/login/data/models/username_input.dart: -------------------------------------------------------------------------------- 1 | import 'package:formz/formz.dart'; 2 | 3 | enum UsernameValidationError { empty } 4 | 5 | class Username extends FormzInput { 6 | const Username.pure() : super.pure(''); 7 | const Username.dirty([super.value = '']) : super.dirty(); 8 | 9 | @override 10 | UsernameValidationError? validator(String? value) { 11 | return value?.isNotEmpty == true ? null : UsernameValidationError.empty; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/features/login/data/repositories/login_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/login/domain/repositories/login_repository.dart'; 6 | 7 | class LoginRepositoryImpl implements LoginRepository { 8 | LoginRepositoryImpl(this._restService); 9 | final LoginService _restService; 10 | 11 | @override 12 | Future> createAccessToken( 13 | AccessTokenParams params) async { 14 | final result = await _restService.createAccessToken( 15 | params.clientId, 16 | params.clientSecret, 17 | params.code, 18 | params.redirectUri, 19 | params.state, 20 | ); 21 | if (result.isSuccessful) { 22 | return right( 23 | result.body?.copyWith(type: TokenType.oauth) ?? const Token()); 24 | } else { 25 | return left(result.error.toServerFailure()); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/features/login/domain/repositories/login_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | 5 | abstract class LoginRepository { 6 | Future> createAccessToken( 7 | AccessTokenParams params, 8 | ); 9 | } 10 | 11 | class AccessTokenParams { 12 | AccessTokenParams( 13 | this.clientId, 14 | this.clientSecret, 15 | this.code, 16 | this.redirectUri, 17 | this.state, 18 | ); 19 | final String clientId; 20 | final String clientSecret; 21 | final String code; 22 | final String redirectUri; 23 | final String state; 24 | } 25 | -------------------------------------------------------------------------------- /lib/features/login/domain/usecases/login_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/login/domain/repositories/login_repository.dart'; 6 | 7 | class CreateAccessTokenUsecase extends UseCase { 8 | CreateAccessTokenUsecase(this._repository); 9 | final LoginRepository _repository; 10 | 11 | @override 12 | Future> call(AccessTokenParams params) async { 13 | try { 14 | return _repository.createAccessToken(params); 15 | } catch (e) { 16 | return Left(ServerFailure.unknown()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/login/presentation/cubit/login_state.dart: -------------------------------------------------------------------------------- 1 | part of 'login_cubit.dart'; 2 | 3 | @freezed 4 | class LoginState with _$LoginState { 5 | const factory LoginState.oauth({ 6 | @Default(FormzSubmissionStatus.initial) FormzSubmissionStatus status, 7 | @Default(false) bool isValid, 8 | String? message, 9 | }) = _OAuth; 10 | 11 | const factory LoginState.personal({ 12 | @Default(FormzSubmissionStatus.initial) FormzSubmissionStatus status, 13 | @Default(false) bool isValid, 14 | @Default(PersonalToken.pure()) PersonalToken token, 15 | String? message, 16 | }) = _Personal; 17 | 18 | const factory LoginState.basic({ 19 | @Default(FormzSubmissionStatus.initial) FormzSubmissionStatus status, 20 | @Default(false) bool isValid, 21 | @Default(Username.pure()) Username username, 22 | @Default(Password.pure()) Password password, 23 | String? message, 24 | }) = _Basic; 25 | } 26 | -------------------------------------------------------------------------------- /lib/features/login/presentation/widgets/login_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 4 | import 'package:formz/formz.dart'; 5 | 6 | import '../../../../generated/l10n.dart'; 7 | import '../cubit/login_cubit.dart'; 8 | 9 | class LoginButton extends StatelessWidget { 10 | const LoginButton({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return BlocConsumer( 15 | listener: (context, state) { 16 | if (state.status.isInProgress) { 17 | FocusScope.of(context).unfocus(); 18 | } 19 | }, 20 | builder: (context, state) { 21 | return state.when( 22 | oauth: (status, isValid, message) => status.isInProgress 23 | ? const CircularProgressIndicator() 24 | : ElevatedButton.icon( 25 | icon: const Icon(FontAwesomeIcons.github), 26 | label: Text(S.current.loginOAuthButton), 27 | onPressed: () => 28 | context.read().onOAuthLoginPressed(), 29 | ), 30 | personal: (status, isValid, token, message) => status.isInProgress 31 | ? const CircularProgressIndicator() 32 | : ElevatedButton.icon( 33 | icon: const Icon(FontAwesomeIcons.github), 34 | label: Text(S.current.loginPersonalButton), 35 | onPressed: isValid 36 | ? () => 37 | context.read().onPersonalLoginPressed() 38 | : null, 39 | ), 40 | basic: (status, isValid, username, password, message) => 41 | status.isInProgress 42 | ? const CircularProgressIndicator() 43 | : ElevatedButton.icon( 44 | icon: const Icon(FontAwesomeIcons.github), 45 | label: Text(S.current.loginBasicButton), 46 | onPressed: isValid 47 | ? () => 48 | context.read().onBasicLoginPressed() 49 | : null, 50 | ), 51 | ); 52 | }, 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/features/login/presentation/widgets/login_tab_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../../../configs/constants.dart'; 4 | import '../../../../generated/l10n.dart'; 5 | 6 | enum LoginType { oauth, personal, basic } 7 | 8 | extension LoginTypeExtension on LoginType { 9 | String get title { 10 | switch (this) { 11 | case LoginType.oauth: 12 | return S.current.loginOAuthTab; 13 | case LoginType.personal: 14 | return S.current.loginPersonalTab; 15 | case LoginType.basic: 16 | return S.current.loginBasicTab; 17 | default: 18 | return ''; 19 | } 20 | } 21 | } 22 | 23 | Widget buildLoginTabs(BuildContext context, TabController controller) { 24 | return Container( 25 | margin: paddingSmallDefault, 26 | height: 40, 27 | decoration: BoxDecoration( 28 | color: Theme.of(context).primaryColor.withOpacity(0.8), 29 | borderRadius: BorderRadius.circular(20.0), 30 | ), 31 | child: TabBar( 32 | controller: controller, 33 | indicator: BoxDecoration( 34 | color: Theme.of(context).colorScheme.primary, 35 | borderRadius: BorderRadius.circular(20.0), 36 | ), 37 | tabs: LoginType.values.map((model) { 38 | return Tab( 39 | text: model.title, 40 | ); 41 | }).toList(), 42 | ), 43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /lib/features/login/presentation/widgets/oauth_login_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../../../configs/constants.dart'; 4 | import '../../../../generated/l10n.dart'; 5 | import 'login_button.dart'; 6 | 7 | class OAuthLoginWidget extends StatelessWidget { 8 | const OAuthLoginWidget({super.key}); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Padding( 13 | padding: paddingSmallDefault, 14 | child: Column( 15 | children: [ 16 | _buildTitle(context), 17 | const SizedBox(height: spaceDefault), 18 | _buildDescription(context), 19 | const SizedBox(height: spaceDefault), 20 | const LoginButton(), 21 | ], 22 | ), 23 | ); 24 | } 25 | 26 | _buildTitle(BuildContext context) { 27 | return Text( 28 | S.current.loginOAuthTitle, 29 | textAlign: TextAlign.center, 30 | style: Theme.of(context).textTheme.headlineSmall, 31 | ); 32 | } 33 | 34 | _buildDescription(BuildContext context) { 35 | return Text( 36 | S.current.loginOAuthDescription, 37 | textAlign: TextAlign.center, 38 | style: Theme.of(context).textTheme.bodyMedium, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/features/login/presentation/widgets/personal_login_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutterhub/configs/constants.dart'; 4 | import 'package:flutterhub/generated/l10n.dart'; 5 | 6 | import '../cubit/login_cubit.dart'; 7 | import 'login_button.dart'; 8 | 9 | class PersonalLoginWidget extends StatelessWidget { 10 | const PersonalLoginWidget({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Padding( 15 | padding: paddingSmallDefault, 16 | child: Column( 17 | children: [ 18 | _buildTitle(context), 19 | const SizedBox(height: spaceDefault), 20 | _buildDescription(context), 21 | const SizedBox(height: spaceDefault), 22 | const TokenInput(), 23 | const SizedBox(height: spaceDefault), 24 | const LoginButton(), 25 | ], 26 | ), 27 | ); 28 | } 29 | 30 | _buildTitle(BuildContext context) { 31 | return Text( 32 | S.current.loginPersonalTitle, 33 | style: Theme.of(context).textTheme.headlineMedium, 34 | ); 35 | } 36 | 37 | _buildDescription(BuildContext context) { 38 | return Text( 39 | S.current.loginPersonalDescription(kGithubScope), 40 | textAlign: TextAlign.center, 41 | style: Theme.of(context).textTheme.bodySmall, 42 | ); 43 | } 44 | } 45 | 46 | class TokenInput extends StatelessWidget { 47 | const TokenInput({super.key}); 48 | 49 | @override 50 | Widget build(BuildContext context) { 51 | return BlocBuilder( 52 | builder: (context, state) { 53 | return state.whenOrNull( 54 | personal: (status, isValid, token, message) => TextFormField( 55 | decoration: InputDecoration( 56 | labelText: S.current.loginPersonalLoginHint, 57 | errorText: token.isNotValid ? 'invalid token' : null, 58 | ), 59 | onChanged: (value) => 60 | context.read().onPersonalTokenChanged(value), 61 | ), 62 | ) ?? 63 | Container(); 64 | }, 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/features/menu/data/models/rate_limit.dart: -------------------------------------------------------------------------------- 1 | class RateLimit { 2 | final int limit; 3 | final int remaining; 4 | final int reset; 5 | 6 | RateLimit({this.limit = 0, this.remaining = 0, this.reset = 0}); 7 | 8 | DateTime get resetDate => DateTime.fromMillisecondsSinceEpoch(reset * 1000); 9 | Duration get resetTime => resetDate.difference(DateTime.now()); 10 | String get resetMinutes => resetTime.inMinutes.toString().padLeft(2, '0'); 11 | String get resetSeconds => 12 | (resetTime.inSeconds % 60).toString().padLeft(2, '0'); 13 | } 14 | -------------------------------------------------------------------------------- /lib/features/menu/data/repositories/user_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/menu/domain/repositories/user_repository.dart'; 6 | 7 | class UserRepositoryImpl implements UserRepository { 8 | UserRepositoryImpl(this._restService); 9 | final UserService _restService; 10 | 11 | @override 12 | Future> user(AuthenticatedUserParams params) async { 13 | final result = await _restService.user(); 14 | if (result.isSuccessful) { 15 | return right(result.body ?? const User()); 16 | } else { 17 | return left(result.error.toServerFailure()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/features/menu/domain/repositories/user_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | 5 | abstract class UserRepository { 6 | Future> user( 7 | AuthenticatedUserParams params, 8 | ); 9 | } 10 | 11 | class AuthenticatedUserParams { 12 | AuthenticatedUserParams(); 13 | } 14 | -------------------------------------------------------------------------------- /lib/features/menu/domain/usecases/user_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import '../repositories/user_repository.dart'; 6 | 7 | class GetAuthenticatedUserUsecase 8 | extends UseCase { 9 | GetAuthenticatedUserUsecase(this._repository); 10 | final UserRepository _repository; 11 | 12 | @override 13 | Future> call(AuthenticatedUserParams params) async { 14 | try { 15 | return _repository.user(params); 16 | } catch (e) { 17 | return Left(ServerFailure.unknown()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/features/menu/presentation/cubit/menu_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:equatable/equatable.dart'; 3 | 4 | part 'menu_state.dart'; 5 | 6 | class MenuCubit extends Cubit { 7 | MenuCubit() : super(MenuInitial()); 8 | } 9 | -------------------------------------------------------------------------------- /lib/features/menu/presentation/cubit/menu_state.dart: -------------------------------------------------------------------------------- 1 | part of 'menu_cubit.dart'; 2 | 3 | abstract class MenuState extends Equatable { 4 | const MenuState(); 5 | 6 | @override 7 | List get props => []; 8 | } 9 | 10 | class MenuInitial extends MenuState {} 11 | -------------------------------------------------------------------------------- /lib/features/menu/presentation/widgets/menu_tile.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class MenuTile extends StatelessWidget { 4 | const MenuTile( 5 | this.context, { 6 | super.key, 7 | this.leading, 8 | this.title, 9 | this.trailing, 10 | this.onTap, 11 | }); 12 | 13 | final BuildContext context; 14 | final IconData? leading; 15 | final String? title; 16 | final Widget? trailing; 17 | final Function()? onTap; 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return ListTile( 22 | leading: leading != null 23 | ? Icon( 24 | leading, 25 | color: Theme.of(context).colorScheme.secondary, 26 | ) 27 | : null, 28 | title: Text(title ?? ''), 29 | trailing: trailing, 30 | onTap: onTap, 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/features/menu/presentation/widgets/rate_limit_widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutterhub/configs/constants.dart'; 5 | import 'package:flutterhub/features/menu/data/models/rate_limit.dart'; 6 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 7 | 8 | import '../../../../configs/app_store.dart'; 9 | import '../../../../generated/l10n.dart'; 10 | 11 | class RateLimitWidget extends StatefulWidget { 12 | const RateLimitWidget({super.key}); 13 | 14 | @override 15 | State createState() => _RateLimitWidgetState(); 16 | } 17 | 18 | class _RateLimitWidgetState extends State { 19 | Timer? _timer; 20 | 21 | @override 22 | void initState() { 23 | // Run timer to update the rate limit every second 24 | _timer = Timer.periodic(const Duration(seconds: 1), (timer) { 25 | setState(() {}); 26 | }); 27 | super.initState(); 28 | } 29 | 30 | @override 31 | void dispose() { 32 | _timer?.cancel(); 33 | super.dispose(); 34 | } 35 | 36 | @override 37 | Widget build(BuildContext context) { 38 | if (appStore.rateLimit.resetTime.isNegative) { 39 | appStore.rateLimit = RateLimit(); 40 | } 41 | final rm = appStore.rateLimit; 42 | if (rm.limit == 0) { 43 | return Container(); 44 | } 45 | return ListTile( 46 | title: Text(S.current.rateLimit), 47 | subtitle: Text('${rm.remaining}/${rm.limit}'), 48 | trailing: Row( 49 | mainAxisSize: MainAxisSize.min, 50 | children: [ 51 | Text('${rm.resetMinutes}:${rm.resetSeconds}'), 52 | const SizedBox(width: spaceDefault), 53 | Icon( 54 | FontAwesomeIcons.solidCircle, 55 | size: 14, 56 | color: rm.remaining == 0 ? Colors.red : Colors.green, 57 | ) 58 | ], 59 | ), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/features/repositories/data/repositories/repositories_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | import 'package:flutterhub/features/core/data/models/failure.dart'; 4 | import 'package:dartz/dartz.dart'; 5 | import 'package:flutterhub/features/repositories/domain/repositories/repositories_repository.dart'; 6 | 7 | class RepositoriesRepositoryImpl implements RepositoriesRepository { 8 | RepositoriesRepositoryImpl(this._usersService, this._reposService); 9 | final UsersService _usersService; 10 | final ReposService _reposService; 11 | 12 | @override 13 | Future>> userRepositories( 14 | UserRepositoriesParams params) async { 15 | final result = await _usersService.repositories( 16 | params.username, 17 | params.page, 18 | params.perPage, 19 | ); 20 | if (result.isSuccessful) { 21 | return right(result.body ?? []); 22 | } else { 23 | return left(result.error.toServerFailure()); 24 | } 25 | } 26 | 27 | @override 28 | Future>> userStarredRepositories( 29 | UserRepositoriesParams params) async { 30 | final result = await _usersService.starredRepositories( 31 | params.username, 32 | params.page, 33 | params.perPage, 34 | ); 35 | if (result.isSuccessful) { 36 | return right(result.body ?? []); 37 | } else { 38 | return left(result.error.toServerFailure()); 39 | } 40 | } 41 | 42 | @override 43 | Future>> userWatchingRepositories( 44 | UserRepositoriesParams params) async { 45 | final result = await _usersService.watchingRepositories( 46 | params.username, 47 | params.page, 48 | params.perPage, 49 | ); 50 | if (result.isSuccessful) { 51 | return right(result.body ?? []); 52 | } else { 53 | return left(result.error.toServerFailure()); 54 | } 55 | } 56 | 57 | @override 58 | Future>> forks( 59 | RepositoriesParams params) async { 60 | final result = await _reposService.forks( 61 | params.fullname, 62 | params.page, 63 | params.perPage, 64 | ); 65 | if (result.isSuccessful) { 66 | return right(result.body ?? []); 67 | } else { 68 | return left(result.error.toServerFailure()); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /lib/features/repositories/domain/entities/repositories_type.dart: -------------------------------------------------------------------------------- 1 | enum RepositoriesType { 2 | userRepositories, 3 | userStarredRepositories, 4 | userWatchingRepositories, 5 | forks, 6 | } 7 | -------------------------------------------------------------------------------- /lib/features/repositories/domain/repositories/repositories_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | 4 | import '../../../core/data/models/failure.dart'; 5 | 6 | abstract class RepositoriesRepository { 7 | Future>> userRepositories( 8 | UserRepositoriesParams params, 9 | ); 10 | 11 | Future>> userStarredRepositories( 12 | UserRepositoriesParams params, 13 | ); 14 | 15 | Future>> userWatchingRepositories( 16 | UserRepositoriesParams params, 17 | ); 18 | 19 | Future>> forks( 20 | RepositoriesParams params, 21 | ); 22 | } 23 | 24 | class UserRepositoriesParams { 25 | UserRepositoriesParams(this.username, this.page, this.perPage); 26 | final String username; 27 | final int page; 28 | final int perPage; 29 | } 30 | 31 | class RepositoriesParams { 32 | RepositoriesParams(this.fullname, this.page, this.perPage); 33 | final String fullname; 34 | final int page; 35 | final int perPage; 36 | } 37 | -------------------------------------------------------------------------------- /lib/features/repositories/domain/usecases/repositories_usecases.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | import 'package:flutterhub/features/repositories/domain/repositories/repositories_repository.dart'; 4 | 5 | import '../../../core/data/models/failure.dart'; 6 | import '../../../core/domain/usecases/usecase.dart'; 7 | 8 | class UserRepositoriesUsecase 9 | extends UseCase, UserRepositoriesParams> { 10 | UserRepositoriesUsecase(this._repository); 11 | final RepositoriesRepository _repository; 12 | 13 | @override 14 | Future>> call( 15 | UserRepositoriesParams params) async { 16 | try { 17 | return _repository.userRepositories(params); 18 | } catch (e) { 19 | return Left(ServerFailure.unknown()); 20 | } 21 | } 22 | } 23 | 24 | class UserStarredRepositoriesUsecase 25 | extends UseCase, UserRepositoriesParams> { 26 | UserStarredRepositoriesUsecase(this._repository); 27 | final RepositoriesRepository _repository; 28 | 29 | @override 30 | Future>> call( 31 | UserRepositoriesParams params) async { 32 | try { 33 | return _repository.userStarredRepositories(params); 34 | } catch (e) { 35 | return Left(ServerFailure.unknown()); 36 | } 37 | } 38 | } 39 | 40 | class UserWatchingRepositoriesUsecase 41 | extends UseCase, UserRepositoriesParams> { 42 | UserWatchingRepositoriesUsecase(this._repository); 43 | final RepositoriesRepository _repository; 44 | 45 | @override 46 | Future>> call( 47 | UserRepositoriesParams params) async { 48 | try { 49 | return _repository.userWatchingRepositories(params); 50 | } catch (e) { 51 | return Left(ServerFailure.unknown()); 52 | } 53 | } 54 | } 55 | 56 | class ForkRepositoriesUsecase 57 | extends UseCase, RepositoriesParams> { 58 | ForkRepositoriesUsecase(this._repository); 59 | final RepositoriesRepository _repository; 60 | 61 | @override 62 | Future>> call( 63 | RepositoriesParams params) async { 64 | try { 65 | return _repository.forks(params); 66 | } catch (e) { 67 | return Left(ServerFailure.unknown()); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/features/repositories/presentation/cubit/repositories_cubit.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'repositories_cubit.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$InitialImpl _$$InitialImplFromJson(Map json) => 10 | _$InitialImpl( 11 | $type: json['runtimeType'] as String?, 12 | ); 13 | 14 | Map _$$InitialImplToJson(_$InitialImpl instance) => 15 | { 16 | 'runtimeType': instance.$type, 17 | }; 18 | 19 | _$FetchInProgressImpl _$$FetchInProgressImplFromJson( 20 | Map json) => 21 | _$FetchInProgressImpl( 22 | $type: json['runtimeType'] as String?, 23 | ); 24 | 25 | Map _$$FetchInProgressImplToJson( 26 | _$FetchInProgressImpl instance) => 27 | { 28 | 'runtimeType': instance.$type, 29 | }; 30 | 31 | _$FetchEmptyImpl _$$FetchEmptyImplFromJson(Map json) => 32 | _$FetchEmptyImpl( 33 | $type: json['runtimeType'] as String?, 34 | ); 35 | 36 | Map _$$FetchEmptyImplToJson(_$FetchEmptyImpl instance) => 37 | { 38 | 'runtimeType': instance.$type, 39 | }; 40 | 41 | _$FetchSuccessImpl _$$FetchSuccessImplFromJson(Map json) => 42 | _$FetchSuccessImpl( 43 | items: (json['items'] as List) 44 | .map((e) => Repository.fromJson(e as Map)) 45 | .toList(), 46 | hasNextPage: json['has_next_page'] as bool, 47 | $type: json['runtimeType'] as String?, 48 | ); 49 | 50 | Map _$$FetchSuccessImplToJson(_$FetchSuccessImpl instance) => 51 | { 52 | 'items': instance.items.map((e) => e.toJson()).toList(), 53 | 'has_next_page': instance.hasNextPage, 54 | 'runtimeType': instance.$type, 55 | }; 56 | 57 | _$FetchErrorImpl _$$FetchErrorImplFromJson(Map json) => 58 | _$FetchErrorImpl( 59 | message: json['message'] as String?, 60 | $type: json['runtimeType'] as String?, 61 | ); 62 | 63 | Map _$$FetchErrorImplToJson(_$FetchErrorImpl instance) => 64 | { 65 | 'message': instance.message, 66 | 'runtimeType': instance.$type, 67 | }; 68 | -------------------------------------------------------------------------------- /lib/features/repositories/presentation/cubit/repositories_state.dart: -------------------------------------------------------------------------------- 1 | part of 'repositories_cubit.dart'; 2 | 3 | @freezed 4 | class RepositoriesState with _$RepositoriesState { 5 | const factory RepositoriesState.initial() = _Initial; 6 | 7 | const factory RepositoriesState.reposFetchInProgress() = _FetchInProgress; 8 | const factory RepositoriesState.reposFetchEmpty() = _FetchEmpty; 9 | const factory RepositoriesState.reposFetchSuccess({ 10 | required List items, 11 | required bool hasNextPage, 12 | }) = _FetchSuccess; 13 | const factory RepositoriesState.reposFetchError({ 14 | String? message, 15 | }) = _FetchError; 16 | 17 | factory RepositoriesState.fromJson(Map json) => 18 | _$RepositoriesStateFromJson(json); 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/repository/data/repositories/repos_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/repository/domain/repositories/repos_repository.dart'; 6 | 7 | class ReposRepositoryImpl implements ReposRepository { 8 | ReposRepositoryImpl(this._restService); 9 | final ReposService _restService; 10 | 11 | @override 12 | Future> repository( 13 | GetRepositoryParams params) async { 14 | final result = await _restService.repository(params.fullname); 15 | if (result.isSuccessful) { 16 | return right(result.body ?? const Repository()); 17 | } else { 18 | return left(result.error.toServerFailure()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/features/repository/domain/repositories/repos_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | 5 | abstract class ReposRepository { 6 | Future> repository( 7 | GetRepositoryParams params, 8 | ); 9 | } 10 | 11 | class GetRepositoryParams { 12 | GetRepositoryParams(this.fullname); 13 | final String fullname; 14 | } 15 | -------------------------------------------------------------------------------- /lib/features/repository/domain/usecases/get_repository_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/repository/domain/repositories/repos_repository.dart'; 6 | 7 | class GetRepositoryUsecase extends UseCase { 8 | GetRepositoryUsecase(this._repository); 9 | final ReposRepository _repository; 10 | 11 | @override 12 | Future> call(GetRepositoryParams params) async { 13 | try { 14 | return _repository.repository(params); 15 | } catch (e) { 16 | return Left(ServerFailure.unknown()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/repository/presentation/cubit/repository_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutterhub/configs/constants.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/repository/domain/repositories/repos_repository.dart'; 6 | import 'package:flutterhub/features/repository/domain/usecases/get_repository_usecase.dart'; 7 | import 'package:freezed_annotation/freezed_annotation.dart'; 8 | 9 | part 'repository_state.dart'; 10 | part 'repository_cubit.freezed.dart'; 11 | part 'repository_cubit.g.dart'; 12 | 13 | class RepositoryCubit extends Cubit { 14 | RepositoryCubit( 15 | this.getRepositoryUsecase, 16 | ) : super(const RepositoryState.fetchInProgress()); 17 | 18 | final GetRepositoryUsecase getRepositoryUsecase; 19 | 20 | void fetchRepository({required String fullName}) async { 21 | emit(const RepositoryState.fetchInProgress()); 22 | try { 23 | final result = await getRepositoryUsecase(GetRepositoryParams(fullName)); 24 | result.fold( 25 | (l) => emit(RepositoryState.fetchError( 26 | message: l.messageText(), 27 | url: l.documentationUrlText(), 28 | )), 29 | (r) => emit(RepositoryState.fetchSuccess(item: r)), 30 | ); 31 | } catch (e) { 32 | debugPrint(e.toString()); 33 | emit(const RepositoryState.fetchError(message: kUnexpectedError)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/features/repository/presentation/cubit/repository_cubit.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'repository_cubit.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$FetchInProgressImpl _$$FetchInProgressImplFromJson( 10 | Map json) => 11 | _$FetchInProgressImpl( 12 | $type: json['runtimeType'] as String?, 13 | ); 14 | 15 | Map _$$FetchInProgressImplToJson( 16 | _$FetchInProgressImpl instance) => 17 | { 18 | 'runtimeType': instance.$type, 19 | }; 20 | 21 | _$FetchSuccessImpl _$$FetchSuccessImplFromJson(Map json) => 22 | _$FetchSuccessImpl( 23 | item: Repository.fromJson(json['item'] as Map), 24 | $type: json['runtimeType'] as String?, 25 | ); 26 | 27 | Map _$$FetchSuccessImplToJson(_$FetchSuccessImpl instance) => 28 | { 29 | 'item': instance.item.toJson(), 30 | 'runtimeType': instance.$type, 31 | }; 32 | 33 | _$FetchErrorImpl _$$FetchErrorImplFromJson(Map json) => 34 | _$FetchErrorImpl( 35 | message: json['message'] as String?, 36 | url: json['url'] as String?, 37 | $type: json['runtimeType'] as String?, 38 | ); 39 | 40 | Map _$$FetchErrorImplToJson(_$FetchErrorImpl instance) => 41 | { 42 | 'message': instance.message, 43 | 'url': instance.url, 44 | 'runtimeType': instance.$type, 45 | }; 46 | -------------------------------------------------------------------------------- /lib/features/repository/presentation/cubit/repository_state.dart: -------------------------------------------------------------------------------- 1 | part of 'repository_cubit.dart'; 2 | 3 | @freezed 4 | class RepositoryState with _$RepositoryState { 5 | const factory RepositoryState.fetchInProgress() = _FetchInProgress; 6 | 7 | const factory RepositoryState.fetchSuccess({ 8 | required Repository item, 9 | }) = _FetchSuccess; 10 | 11 | const factory RepositoryState.fetchError({ 12 | String? message, 13 | String? url, 14 | }) = _FetchError; 15 | 16 | factory RepositoryState.fromJson(Map json) => 17 | _$RepositoryStateFromJson(json); 18 | } 19 | -------------------------------------------------------------------------------- /lib/features/search/data/repositories/search_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/search/domain/repositories/search_repository.dart'; 6 | 7 | class SearchRepositoryImpl implements SearchRepository { 8 | SearchRepositoryImpl(this._restService); 9 | final SearchService _restService; 10 | 11 | @override 12 | Future> searchRepositories( 13 | SearchParams params) async { 14 | final result = await _restService.searchRepositories( 15 | params.query, 16 | params.order, 17 | params.sort, 18 | params.page, 19 | params.perPage, 20 | ); 21 | if (result.isSuccessful) { 22 | return right(result.body ?? const RepositorySearch()); 23 | } else { 24 | return left(result.error.toServerFailure()); 25 | } 26 | } 27 | 28 | @override 29 | Future> searchUsers(SearchParams params) async { 30 | final result = await _restService.searchUsers( 31 | params.query, 32 | params.order, 33 | params.sort, 34 | params.page, 35 | params.perPage, 36 | ); 37 | if (result.isSuccessful) { 38 | return right(result.body ?? const UserSearch()); 39 | } else { 40 | return left(result.error.toServerFailure()); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/features/search/domain/repositories/search_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | 5 | abstract class SearchRepository { 6 | Future> searchRepositories( 7 | SearchParams params, 8 | ); 9 | 10 | Future> searchUsers( 11 | SearchParams params, 12 | ); 13 | } 14 | 15 | class SearchParams { 16 | SearchParams(this.query, this.order, this.sort, this.page, this.perPage); 17 | final String query; 18 | final String order; 19 | final String sort; 20 | final int page; 21 | final int perPage; 22 | } 23 | -------------------------------------------------------------------------------- /lib/features/search/domain/usecases/search_repositories_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/search/domain/repositories/search_repository.dart'; 6 | 7 | class SearchRepositoriesUsecase 8 | extends UseCase { 9 | SearchRepositoriesUsecase(this._repository); 10 | final SearchRepository _repository; 11 | 12 | @override 13 | Future> call(SearchParams params) async { 14 | try { 15 | return _repository.searchRepositories(params); 16 | } catch (e) { 17 | return Left(ServerFailure.unknown()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/features/search/domain/usecases/search_users_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/search/domain/repositories/search_repository.dart'; 6 | 7 | class SearchUsersUsecase extends UseCase { 8 | SearchUsersUsecase(this._repository); 9 | final SearchRepository _repository; 10 | 11 | @override 12 | Future> call(SearchParams params) async { 13 | try { 14 | return _repository.searchUsers(params); 15 | } catch (e) { 16 | return Left(ServerFailure.unknown()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/search/presentation/cubit/search_state.dart: -------------------------------------------------------------------------------- 1 | part of 'search_cubit.dart'; 2 | 3 | @freezed 4 | class SearchState with _$SearchState { 5 | const factory SearchState.initial() = _Initial; 6 | 7 | const factory SearchState.reposFetchInProgress() = _ReposFetchInProgress; 8 | const factory SearchState.reposFetchEmpty() = _ReposFetchEmpty; 9 | const factory SearchState.reposFetchSuccess({ 10 | required List items, 11 | required bool hasNextPage, 12 | }) = _ReposFetchSuccess; 13 | const factory SearchState.reposFetchError({ 14 | String? message, 15 | String? url, 16 | }) = _ReposFetchError; 17 | 18 | const factory SearchState.usersFetchInProgress() = _UsersFetchInProgress; 19 | const factory SearchState.usersFetchEmpty() = _UsersFetchEmpty; 20 | const factory SearchState.usersFetchSuccess({ 21 | required List items, 22 | required bool hasNextPage, 23 | }) = _UsersFetchSuccess; 24 | const factory SearchState.usersFetchError({ 25 | String? message, 26 | String? url, 27 | }) = _UsersFetchError; 28 | 29 | factory SearchState.fromJson(Map json) => 30 | _$SearchStateFromJson(json); 31 | } 32 | -------------------------------------------------------------------------------- /lib/features/search/presentation/widgets/repository_tile.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/configs/constants.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | import 'package:flutterhub/features/core/presentation/widgets/common_widgets.dart'; 5 | import 'package:flutterhub/features/core/presentation/widgets/network_image.dart'; 6 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 7 | 8 | class RepositoryTile extends StatelessWidget { 9 | const RepositoryTile({super.key, required this.item, this.onTap}); 10 | 11 | final Repository item; 12 | final Function(Repository)? onTap; 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return ContainerX( 17 | child: Card( 18 | child: ListTile( 19 | leading: networkImage(context, item.owner?.avatarUrl), 20 | title: Text(item.name ?? ''), 21 | subtitle: Column( 22 | crossAxisAlignment: CrossAxisAlignment.start, 23 | children: [ 24 | const SizedBox(height: spaceMedium), 25 | if (item.description != null) Text(item.description ?? ''), 26 | const SizedBox(height: spaceMedium), 27 | Row( 28 | children: [ 29 | if (item.color != null) 30 | Container( 31 | width: 14, 32 | height: 14, 33 | decoration: BoxDecoration( 34 | color: Color(item.color ?? 0), 35 | shape: BoxShape.circle, 36 | ), 37 | ), 38 | const SizedBox(width: spaceSmall2), 39 | if (item.language != null) 40 | Text( 41 | item.language ?? '', 42 | style: Theme.of(context).textTheme.bodyMedium, 43 | ), 44 | const SizedBox(width: spaceDefault), 45 | const Icon(FontAwesomeIcons.star, size: 14), 46 | const SizedBox(width: spaceSmall2), 47 | Expanded( 48 | child: Text( 49 | '${item.stargazersCount ?? 0}', 50 | style: Theme.of(context).textTheme.bodyMedium, 51 | ), 52 | ), 53 | ], 54 | ), 55 | const SizedBox(height: spaceSmall2), 56 | ], 57 | ), 58 | onTap: () { 59 | onTap?.call(item); 60 | }, 61 | ), 62 | ), 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/features/search/presentation/widgets/user_tile.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | import 'package:flutterhub/features/core/presentation/widgets/grid_item.dart'; 4 | 5 | class UserTile extends StatelessWidget { 6 | const UserTile({super.key, required this.item, this.onTap}); 7 | 8 | final User item; 9 | final Function(User)? onTap; 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return GridItem( 14 | imageUrl: item.avatarUrl, 15 | title: item.login, 16 | subtitle: item.name, 17 | onTap: () { 18 | onTap?.call(item); 19 | }, 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/features/settings/presentation/pages/settings_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/configs/app_store.dart'; 3 | import 'package:flutterhub/configs/constants.dart'; 4 | import 'package:flutterhub/features/core/presentation/widgets/common_widgets.dart'; 5 | import 'package:flutterhub/generated/l10n.dart'; 6 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 7 | 8 | import '../widgets/language_widget.dart'; 9 | import '../widgets/setting_tile.dart'; 10 | import '../widgets/theme_mode_switch.dart'; 11 | import '../widgets/theme_selector.dart'; 12 | 13 | class SettingsPage extends StatefulWidget { 14 | const SettingsPage({super.key}); 15 | 16 | @override 17 | State createState() => _SettingsPageState(); 18 | } 19 | 20 | class _SettingsPageState extends State { 21 | @override 22 | Widget build(BuildContext context) { 23 | return Scaffold( 24 | appBar: AppBar( 25 | title: Text(S.current.settingsAppBarTitle), 26 | ), 27 | body: SingleChildScrollView( 28 | child: ContainerX( 29 | child: Column( 30 | children: [ 31 | const SizedBox(height: spaceDefault), 32 | const Padding( 33 | padding: EdgeInsets.symmetric(horizontal: spaceDefault), 34 | child: ThemeSelector(), 35 | ), 36 | SettingTile( 37 | context, 38 | leading: Icons.brightness_4, 39 | title: S.current.settingsThemeModeTitle, 40 | trailing: ThemeModeSwitch( 41 | themeMode: appStore.themeMode, 42 | onChanged: (mode) { 43 | appStore.setThemeMode(mode); 44 | setState(() {}); 45 | }, 46 | ), 47 | ), 48 | SettingTile( 49 | context, 50 | leading: FontAwesomeIcons.globe, 51 | title: S.current.settingsLanguageTitle, 52 | trailing: LanguageWidget( 53 | onChanged: (value) { 54 | setState(() {}); 55 | }, 56 | ), 57 | ), 58 | ], 59 | ), 60 | ), 61 | ), 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/features/settings/presentation/widgets/language_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/configs/app_store.dart'; 3 | import 'package:flutterhub/generated/l10n.dart'; 4 | import 'package:flutterhub/utils/extensions.dart'; 5 | 6 | class LanguageWidget extends StatelessWidget { 7 | const LanguageWidget({super.key, required this.onChanged}); 8 | 9 | final Function(Locale) onChanged; 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return DropdownButton( 14 | value: appStore.selectedLanguage.parseLocale(), 15 | isExpanded: false, 16 | isDense: false, 17 | underline: const SizedBox(), 18 | onChanged: (value) async { 19 | if (value != null) { 20 | await S.load(value); 21 | appStore.setLanguage(value.toString()); 22 | onChanged(value); 23 | } 24 | }, 25 | selectedItemBuilder: (context) { 26 | return S.delegate.supportedLocales 27 | .map((e) => DropdownMenuItem( 28 | value: e, 29 | child: SizedBox( 30 | width: 80, 31 | child: Text( 32 | e.countryCode?.toLangIcon() ?? '', 33 | style: Theme.of(context).textTheme.headlineSmall, 34 | textAlign: TextAlign.right, 35 | ), 36 | ), 37 | )) 38 | .toList(); 39 | }, 40 | items: S.delegate.supportedLocales 41 | .map((e) => DropdownMenuItem( 42 | value: e, 43 | child: Text(e.countryCode?.toLangName() ?? ''), 44 | )) 45 | .toList(), 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/features/settings/presentation/widgets/setting_tile.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SettingTile extends StatelessWidget { 4 | const SettingTile( 5 | this.context, { 6 | super.key, 7 | this.leading, 8 | this.title, 9 | this.trailing, 10 | this.onTap, 11 | }); 12 | 13 | final BuildContext context; 14 | final IconData? leading; 15 | final String? title; 16 | final Widget? trailing; 17 | final Function()? onTap; 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return Card( 22 | child: ListTile( 23 | leading: leading != null 24 | ? Icon( 25 | leading, 26 | color: Theme.of(context).colorScheme.secondary, 27 | ) 28 | : null, 29 | title: Text(title ?? ''), 30 | trailing: trailing, 31 | onTap: onTap, 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/features/settings/presentation/widgets/theme_mode_switch.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Widget using [ToggleButtons) that can be used to toggle the theme mode 4 | /// of an application. 5 | /// 6 | /// This is a simple Flutter "Universal" Widget that only depends on the SDK and 7 | /// can be dropped into any application. 8 | class ThemeModeSwitch extends StatelessWidget { 9 | const ThemeModeSwitch({ 10 | super.key, 11 | required this.themeMode, 12 | required this.onChanged, 13 | }); 14 | final ThemeMode themeMode; 15 | final ValueChanged onChanged; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | final List isSelected = [ 20 | themeMode == ThemeMode.light, 21 | themeMode == ThemeMode.system, 22 | themeMode == ThemeMode.dark, 23 | ]; 24 | return ToggleButtons( 25 | isSelected: isSelected, 26 | onPressed: (int newIndex) { 27 | if (newIndex == 0) { 28 | onChanged(ThemeMode.light); 29 | } else if (newIndex == 1) { 30 | onChanged(ThemeMode.system); 31 | } else { 32 | onChanged(ThemeMode.dark); 33 | } 34 | }, 35 | children: const [ 36 | Icon(Icons.wb_sunny), 37 | Icon(Icons.phone_iphone), 38 | Icon(Icons.bedtime), 39 | ], 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/features/trending/data/repositories/trend_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/trending/domain/repositories/trend_repository.dart'; 6 | 7 | class TrendRepositoryImpl implements TrendRepository { 8 | TrendRepositoryImpl(this._restService); 9 | final TrendingService _restService; 10 | 11 | @override 12 | Future>> trendingRepositories( 13 | TrendingParams params) async { 14 | final result = 15 | await _restService.trendingRepositories(params.language, params.since); 16 | if (result.isSuccessful) { 17 | return right(result.body ?? const []); 18 | } else { 19 | return left(result.error.toServerFailure()); 20 | } 21 | } 22 | 23 | @override 24 | Future>> trendingUsers( 25 | TrendingParams params) async { 26 | final result = 27 | await _restService.trendingDevelopers(params.language, params.since); 28 | if (result.isSuccessful) { 29 | return right(result.body ?? const []); 30 | } else { 31 | return left(result.error.toServerFailure()); 32 | } 33 | } 34 | 35 | @override 36 | Future>> languages() async { 37 | final result = await _restService.languages(); 38 | if (result.isSuccessful) { 39 | return right(result.body ?? const []); 40 | } else { 41 | return left(result.error.toServerFailure()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/features/trending/domain/repositories/trend_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | 5 | abstract class TrendRepository { 6 | Future>> trendingRepositories( 7 | TrendingParams params, 8 | ); 9 | 10 | Future>> trendingUsers( 11 | TrendingParams params, 12 | ); 13 | 14 | Future>> languages(); 15 | } 16 | 17 | class TrendingParams { 18 | TrendingParams(this.language, this.since); 19 | final String language; 20 | final String since; 21 | } 22 | -------------------------------------------------------------------------------- /lib/features/trending/domain/usecases/trending_repositories_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/trending/domain/repositories/trend_repository.dart'; 6 | 7 | class TrendingRepositoriesUsecase 8 | extends UseCase, TrendingParams> { 9 | TrendingRepositoriesUsecase(this._repository); 10 | final TrendRepository _repository; 11 | 12 | @override 13 | Future>> call( 14 | TrendingParams params) async { 15 | try { 16 | return _repository.trendingRepositories(params); 17 | } catch (e) { 18 | return Left(ServerFailure.unknown()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/features/trending/domain/usecases/trending_users_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 3 | import 'package:flutterhub/features/trending/domain/repositories/trend_repository.dart'; 4 | import 'package:flutterhub/features/core/data/models/failure.dart'; 5 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 6 | 7 | class TrendingUsersUsecase extends UseCase, TrendingParams> { 8 | TrendingUsersUsecase(this._repository); 9 | final TrendRepository _repository; 10 | 11 | @override 12 | Future>> call( 13 | TrendingParams params) async { 14 | try { 15 | return _repository.trendingUsers(params); 16 | } catch (e) { 17 | return Left(ServerFailure.unknown()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/features/trending/presentation/cubit/trending_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutterhub/configs/constants.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/trending/domain/repositories/trend_repository.dart'; 6 | import 'package:flutterhub/features/trending/domain/usecases/trending_repositories_usecase.dart'; 7 | import 'package:flutterhub/features/trending/domain/usecases/trending_users_usecase.dart'; 8 | import 'package:freezed_annotation/freezed_annotation.dart'; 9 | 10 | part 'trending_state.dart'; 11 | part 'trending_cubit.freezed.dart'; 12 | part 'trending_cubit.g.dart'; 13 | 14 | class TrendingCubit extends Cubit { 15 | TrendingCubit( 16 | this.trendingRepositoriesUsecase, 17 | this.trendingUsersUsecase, 18 | ) : super(const TrendingState.initial()); 19 | 20 | final TrendingRepositoriesUsecase trendingRepositoriesUsecase; 21 | final TrendingUsersUsecase trendingUsersUsecase; 22 | 23 | void fetchRepositories(TrendingParams params) async { 24 | emit(const TrendingState.reposFetchInProgress()); 25 | try { 26 | final result = await trendingRepositoriesUsecase(params); 27 | result.fold( 28 | (l) => emit(TrendingState.reposFetchError( 29 | message: l.messageText(), 30 | )), 31 | (r) { 32 | emit(r.isEmpty 33 | ? const TrendingState.reposFetchEmpty() 34 | : TrendingState.reposFetchSuccess(items: r)); 35 | }, 36 | ); 37 | } catch (e) { 38 | debugPrint(e.toString()); 39 | emit(const TrendingState.reposFetchError(message: kUnexpectedError)); 40 | } 41 | } 42 | 43 | void fetchUsers(TrendingParams params) async { 44 | emit(const TrendingState.usersFetchInProgress()); 45 | try { 46 | final result = await trendingUsersUsecase(params); 47 | result.fold( 48 | (l) => emit(TrendingState.usersFetchError( 49 | message: l.messageText(), 50 | )), 51 | (r) { 52 | emit(r.isEmpty 53 | ? const TrendingState.usersFetchEmpty() 54 | : TrendingState.usersFetchSuccess(items: r)); 55 | }, 56 | ); 57 | } catch (e) { 58 | debugPrint(e.toString()); 59 | emit(const TrendingState.usersFetchError(message: kUnexpectedError)); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/features/trending/presentation/cubit/trending_state.dart: -------------------------------------------------------------------------------- 1 | part of 'trending_cubit.dart'; 2 | 3 | @freezed 4 | class TrendingState with _$TrendingState { 5 | const factory TrendingState.initial() = _Initial; 6 | 7 | const factory TrendingState.reposFetchInProgress() = _ReposFetchInProgress; 8 | const factory TrendingState.reposFetchEmpty() = _ReposFetchEmpty; 9 | const factory TrendingState.reposFetchSuccess({ 10 | required List items, 11 | }) = _ReposFetchSuccess; 12 | const factory TrendingState.reposFetchError({ 13 | String? message, 14 | }) = _ReposFetchError; 15 | 16 | const factory TrendingState.usersFetchInProgress() = _UsersFetchInProgress; 17 | const factory TrendingState.usersFetchEmpty() = _UsersFetchEmpty; 18 | const factory TrendingState.usersFetchSuccess({ 19 | required List items, 20 | }) = _UsersFetchSuccess; 21 | const factory TrendingState.usersFetchError({ 22 | String? message, 23 | }) = _UsersFetchError; 24 | 25 | factory TrendingState.fromJson(Map json) => 26 | _$TrendingStateFromJson(json); 27 | } 28 | -------------------------------------------------------------------------------- /lib/features/trending/presentation/widgets/search_tab_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 3 | 4 | import '../../../../generated/l10n.dart'; 5 | 6 | enum SearchType { repository, user } 7 | 8 | extension SearchTypeExtension on SearchType { 9 | String get title { 10 | switch (this) { 11 | case SearchType.repository: 12 | return S.current.repositories; 13 | case SearchType.user: 14 | return S.current.users; 15 | } 16 | } 17 | 18 | IconData get icon { 19 | switch (this) { 20 | case SearchType.repository: 21 | return FontAwesomeIcons.bookBookmark; 22 | case SearchType.user: 23 | return FontAwesomeIcons.solidUser; 24 | } 25 | } 26 | } 27 | 28 | TabBar buildSearchTypeTabs(BuildContext context, TabController controller) { 29 | return TabBar( 30 | controller: controller, 31 | indicatorColor: Theme.of(context).colorScheme.secondary, 32 | indicatorWeight: 3, 33 | tabs: SearchType.values.map((model) { 34 | return Tab( 35 | text: model.title, 36 | icon: Icon(model.icon), 37 | ); 38 | }).toList(), 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /lib/features/trending/presentation/widgets/since_tab_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterhub/configs/constants.dart'; 3 | import 'package:flutterhub/features/core/presentation/widgets/common_widgets.dart'; 4 | import 'package:flutterhub/generated/l10n.dart'; 5 | 6 | enum SinceType { daily, weekly, monthly } 7 | 8 | extension SinceTypeExtension on SinceType { 9 | String get title { 10 | switch (this) { 11 | case SinceType.daily: 12 | return S.current.daily; 13 | case SinceType.weekly: 14 | return S.current.weekly; 15 | case SinceType.monthly: 16 | return S.current.monthly; 17 | } 18 | } 19 | 20 | String get value { 21 | switch (this) { 22 | case SinceType.daily: 23 | return 'daily'; 24 | case SinceType.weekly: 25 | return 'weekly'; 26 | case SinceType.monthly: 27 | return 'monthly'; 28 | } 29 | } 30 | } 31 | 32 | Widget buildSinceTabs(BuildContext context, TabController controller) { 33 | return ContainerX( 34 | child: Container( 35 | margin: paddingSmallMedium, 36 | height: 40, 37 | decoration: BoxDecoration( 38 | color: Theme.of(context).primaryColor.withOpacity(0.8), 39 | borderRadius: BorderRadius.circular(20.0), 40 | ), 41 | child: TabBar( 42 | controller: controller, 43 | indicator: BoxDecoration( 44 | color: Theme.of(context).colorScheme.primary, 45 | borderRadius: BorderRadius.circular(20.0), 46 | ), 47 | tabs: SinceType.values.map((model) { 48 | return Tab( 49 | text: model.title, 50 | ); 51 | }).toList(), 52 | ), 53 | ), 54 | ); 55 | } 56 | -------------------------------------------------------------------------------- /lib/features/user/data/repositories/users_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/user/domain/repositories/users_repository.dart'; 6 | 7 | class UsersRepositoryImpl implements UsersRepository { 8 | UsersRepositoryImpl(this._restService); 9 | final UsersService _restService; 10 | 11 | @override 12 | Future> user(UserParams params) async { 13 | final result = await _restService.user(params.owner); 14 | if (result.isSuccessful) { 15 | return right(result.body ?? const User()); 16 | } else { 17 | return left(result.error.toServerFailure()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/features/user/domain/repositories/users_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 4 | 5 | abstract class UsersRepository { 6 | Future> user( 7 | UserParams params, 8 | ); 9 | } 10 | 11 | class UserParams { 12 | UserParams(this.owner); 13 | final String owner; 14 | } 15 | -------------------------------------------------------------------------------- /lib/features/user/domain/usecases/get_user_usecase.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutterhub/features/core/data/models/failure.dart'; 3 | import 'package:flutterhub/features/core/domain/usecases/usecase.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/user/domain/repositories/users_repository.dart'; 6 | 7 | class GetUserUsecase extends UseCase { 8 | GetUserUsecase(this._repository); 9 | final UsersRepository _repository; 10 | 11 | @override 12 | Future> call(UserParams params) async { 13 | try { 14 | return _repository.user(params); 15 | } catch (e) { 16 | return Left(ServerFailure.unknown()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/features/user/presentation/cubit/user_cubit.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutterhub/configs/constants.dart'; 4 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 5 | import 'package:flutterhub/features/user/domain/repositories/users_repository.dart'; 6 | import 'package:flutterhub/features/user/domain/usecases/get_user_usecase.dart'; 7 | import 'package:freezed_annotation/freezed_annotation.dart'; 8 | 9 | part 'user_state.dart'; 10 | part 'user_cubit.freezed.dart'; 11 | part 'user_cubit.g.dart'; 12 | 13 | class UserCubit extends Cubit { 14 | UserCubit( 15 | this.getUserUsecase, 16 | ) : super(const UserState.fetchInProgress()); 17 | 18 | final GetUserUsecase getUserUsecase; 19 | 20 | void fetchUser({required String owner}) async { 21 | emit(const UserState.fetchInProgress()); 22 | try { 23 | final result = await getUserUsecase(UserParams(owner)); 24 | result.fold( 25 | (l) => emit(UserState.fetchError( 26 | message: l.messageText(), 27 | url: l.documentationUrlText(), 28 | )), 29 | (r) => emit(UserState.fetchSuccess(item: r)), 30 | ); 31 | } catch (e) { 32 | debugPrint(e.toString()); 33 | emit(const UserState.fetchError(message: kUnexpectedError)); 34 | } 35 | } 36 | 37 | void setUser(User user) { 38 | emit(UserState.fetchSuccess(item: user)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/features/user/presentation/cubit/user_cubit.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'user_cubit.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$FetchInProgressImpl _$$FetchInProgressImplFromJson( 10 | Map json) => 11 | _$FetchInProgressImpl( 12 | $type: json['runtimeType'] as String?, 13 | ); 14 | 15 | Map _$$FetchInProgressImplToJson( 16 | _$FetchInProgressImpl instance) => 17 | { 18 | 'runtimeType': instance.$type, 19 | }; 20 | 21 | _$FetchSuccessImpl _$$FetchSuccessImplFromJson(Map json) => 22 | _$FetchSuccessImpl( 23 | item: User.fromJson(json['item'] as Map), 24 | $type: json['runtimeType'] as String?, 25 | ); 26 | 27 | Map _$$FetchSuccessImplToJson(_$FetchSuccessImpl instance) => 28 | { 29 | 'item': instance.item.toJson(), 30 | 'runtimeType': instance.$type, 31 | }; 32 | 33 | _$fetchErrorImpl _$$fetchErrorImplFromJson(Map json) => 34 | _$fetchErrorImpl( 35 | message: json['message'] as String?, 36 | url: json['url'] as String?, 37 | $type: json['runtimeType'] as String?, 38 | ); 39 | 40 | Map _$$fetchErrorImplToJson(_$fetchErrorImpl instance) => 41 | { 42 | 'message': instance.message, 43 | 'url': instance.url, 44 | 'runtimeType': instance.$type, 45 | }; 46 | -------------------------------------------------------------------------------- /lib/features/user/presentation/cubit/user_state.dart: -------------------------------------------------------------------------------- 1 | part of 'user_cubit.dart'; 2 | 3 | @freezed 4 | class UserState with _$UserState { 5 | const factory UserState.fetchInProgress() = _FetchInProgress; 6 | 7 | const factory UserState.fetchSuccess({ 8 | required User item, 9 | }) = _FetchSuccess; 10 | 11 | const factory UserState.fetchError({ 12 | String? message, 13 | String? url, 14 | }) = _fetchError; 15 | 16 | factory UserState.fromJson(Map json) => 17 | _$UserStateFromJson(json); 18 | } 19 | -------------------------------------------------------------------------------- /lib/generated/intl/messages_all.dart: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This is code generated via package:intl/generate_localized.dart 2 | // This is a library that looks up messages for specific locales by 3 | // delegating to the appropriate library. 4 | 5 | // Ignore issues from commonly used lints in this file. 6 | // ignore_for_file:implementation_imports, file_names, unnecessary_new 7 | // ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering 8 | // ignore_for_file:argument_type_not_assignable, invalid_assignment 9 | // ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases 10 | // ignore_for_file:comment_references 11 | 12 | import 'dart:async'; 13 | 14 | import 'package:intl/intl.dart'; 15 | import 'package:intl/message_lookup_by_library.dart'; 16 | import 'package:intl/src/intl_helpers.dart'; 17 | 18 | import 'messages_en_US.dart' as messages_en_us; 19 | import 'messages_hy_AM.dart' as messages_hy_am; 20 | import 'messages_ru_RU.dart' as messages_ru_ru; 21 | 22 | typedef Future LibraryLoader(); 23 | Map _deferredLibraries = { 24 | 'en_US': () => new Future.value(null), 25 | 'hy_AM': () => new Future.value(null), 26 | 'ru_RU': () => new Future.value(null), 27 | }; 28 | 29 | MessageLookupByLibrary? _findExact(String localeName) { 30 | switch (localeName) { 31 | case 'en_US': 32 | return messages_en_us.messages; 33 | case 'hy_AM': 34 | return messages_hy_am.messages; 35 | case 'ru_RU': 36 | return messages_ru_ru.messages; 37 | default: 38 | return null; 39 | } 40 | } 41 | 42 | /// User programs should call this before using [localeName] for messages. 43 | Future initializeMessages(String localeName) async { 44 | var availableLocale = Intl.verifiedLocale( 45 | localeName, (locale) => _deferredLibraries[locale] != null, 46 | onFailure: (_) => null); 47 | if (availableLocale == null) { 48 | return new Future.value(false); 49 | } 50 | var lib = _deferredLibraries[availableLocale]; 51 | await (lib == null ? new Future.value(false) : lib()); 52 | initializeInternalMessageLookup(() => new CompositeMessageLookup()); 53 | messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); 54 | return new Future.value(true); 55 | } 56 | 57 | bool _messagesExistFor(String locale) { 58 | try { 59 | return _findExact(locale) != null; 60 | } catch (e) { 61 | return false; 62 | } 63 | } 64 | 65 | MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { 66 | var actualLocale = 67 | Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); 68 | if (actualLocale == null) return null; 69 | return _findExact(actualLocale); 70 | } 71 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutterhub/utils/shared_pref.dart'; 4 | import 'utils/di.dart'; 5 | import 'package:logging/logging.dart'; 6 | import 'package:timeago/timeago.dart' as timeago; 7 | 8 | import 'app.dart'; 9 | import 'l10n/localizations.dart'; 10 | import 'utils/bloc_observer.dart'; 11 | 12 | void main() async { 13 | WidgetsFlutterBinding.ensureInitialized(); 14 | _setupLogging(); 15 | _setupTimeago(); 16 | await initializePrefs(); 17 | await initDI(); 18 | Bloc.observer = FlutterHubBlocObserver(); 19 | runApp(const MyApp()); 20 | } 21 | 22 | void _setupTimeago() { 23 | timeago.setLocaleMessages('en_US', timeago.EnMessages()); 24 | timeago.setLocaleMessages('ru_RU', timeago.RuMessages()); 25 | timeago.setLocaleMessages('hy_AM', HyTimeMessages()); 26 | } 27 | 28 | _setupLogging() { 29 | Logger.root.level = Level.ALL; 30 | Logger.root.onRecord.listen((rec) { 31 | debugPrint('${rec.level.name}: ${rec.time}: ${rec.message}'); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /lib/utils/app_router.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutterhub/utils/di.dart'; 4 | import 'package:flutterhub/features/core/presentation/cubit/cubits.dart'; 5 | import 'package:flutterhub/features/home/presentation/pages/home_page.dart'; 6 | import 'package:flutterhub/features/languages/presentation/pages/languages_page.dart'; 7 | import 'package:flutterhub/features/login/presentation/pages/login_page.dart'; 8 | import 'package:flutterhub/features/repository/presentation/pages/repository_page.dart'; 9 | import 'package:flutterhub/features/settings/presentation/pages/settings_page.dart'; 10 | import 'package:flutterhub/features/trending/presentation/pages/trending_page.dart'; 11 | import 'package:flutterhub/features/user/presentation/pages/user_page.dart'; 12 | 13 | abstract class AppRoutes { 14 | static const home = '/'; 15 | static const languages = '/languages'; 16 | static const login = '/login'; 17 | static const repository = '/repository'; 18 | static const settings = '/settings'; 19 | static const trending = '/trending'; 20 | static const user = '/user'; 21 | } 22 | 23 | class AppRouter { 24 | Route onGenerateRoute(RouteSettings settings) { 25 | switch (settings.name) { 26 | case AppRoutes.home: 27 | return MaterialPageRoute( 28 | builder: (_) => const HomePage(), 29 | ); 30 | case AppRoutes.languages: 31 | return MaterialPageRoute( 32 | builder: (_) => const LanguagesPage(), 33 | ); 34 | case AppRoutes.login: 35 | return MaterialPageRoute( 36 | builder: (_) => const LoginPage(), 37 | ); 38 | case AppRoutes.repository: 39 | return MaterialPageRoute( 40 | builder: (_) => BlocProvider( 41 | create: (context) => di(), 42 | child: RepositoryPage(arguments: settings.arguments), 43 | ), 44 | ); 45 | case AppRoutes.settings: 46 | return MaterialPageRoute( 47 | builder: (_) => const SettingsPage(), 48 | ); 49 | case AppRoutes.trending: 50 | return MaterialPageRoute( 51 | builder: (_) => const TrendingPage(), 52 | ); 53 | case AppRoutes.user: 54 | return MaterialPageRoute( 55 | builder: (_) => BlocProvider( 56 | create: (context) => di(), 57 | child: UserPage(arguments: settings.arguments), 58 | ), 59 | ); 60 | default: 61 | return MaterialPageRoute( 62 | builder: (_) => Container(), 63 | ); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/utils/bloc_observer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | 4 | class FlutterHubBlocObserver extends BlocObserver { 5 | // @override 6 | // void onChange(BlocBase bloc, Change change) { 7 | // super.onChange(bloc, change); 8 | // debugPrint('${bloc.runtimeType} ${change.toString()}'); 9 | // } 10 | 11 | @override 12 | void onTransition(Bloc bloc, Transition transition) { 13 | super.onTransition(bloc, transition); 14 | debugPrint('$transition'); 15 | } 16 | 17 | @override 18 | void onError(BlocBase bloc, Object error, StackTrace stackTrace) { 19 | debugPrint('$error'); 20 | super.onError(bloc, error, stackTrace); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/utils/di.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterhub/features/core/data/datasources/restapi/rest_service.dart'; 2 | import 'package:flutterhub/features/core/data/repositories/repositories.dart'; 3 | import 'package:flutterhub/features/core/domain/repositories/repositories.dart'; 4 | import 'package:flutterhub/features/core/domain/usecases/usecases.dart'; 5 | import 'package:flutterhub/features/core/presentation/cubit/cubits.dart'; 6 | 7 | import 'package:get_it/get_it.dart'; 8 | 9 | final di = GetIt.instance; 10 | 11 | Future initDI() async { 12 | // Register Blocs and Cubits 13 | di.registerFactory(() => LoginCubit(di(), di())); 14 | di.registerFactory(() => TrendingCubit(di(), di())); 15 | di.registerFactory(() => LanguagesCubit(di())); 16 | di.registerFactory(() => SearchCubit(di(), di())); 17 | di.registerFactory(() => RepositoryCubit(di())); 18 | di.registerFactory(() => UserCubit(di())); 19 | 20 | // Register usecases 21 | di.registerLazySingleton(() => TrendingRepositoriesUsecase(di())); 22 | di.registerLazySingleton(() => TrendingUsersUsecase(di())); 23 | di.registerLazySingleton(() => LanguagesUsecase(di())); 24 | di.registerLazySingleton(() => CreateAccessTokenUsecase(di())); 25 | di.registerLazySingleton(() => SearchRepositoriesUsecase(di())); 26 | di.registerLazySingleton(() => SearchUsersUsecase(di())); 27 | di.registerLazySingleton(() => GetRepositoryUsecase(di())); 28 | di.registerLazySingleton(() => GetUserUsecase(di())); 29 | di.registerLazySingleton(() => GetAuthenticatedUserUsecase(di())); 30 | 31 | // Register repositories 32 | di.registerFactory(() => LoginRepositoryImpl(di())); 33 | di.registerFactory(() => TrendRepositoryImpl(di())); 34 | di.registerFactory(() => SearchRepositoryImpl(di())); 35 | di.registerFactory(() => ReposRepositoryImpl(di())); 36 | di.registerFactory(() => UserRepositoryImpl(di())); 37 | di.registerFactory(() => UsersRepositoryImpl(di())); 38 | 39 | // Register data sources 40 | di.registerLazySingleton(() => trendingClient.getService()); 41 | di.registerLazySingleton(() => githubClient.getService()); 42 | di.registerLazySingleton(() => githubClient.getService()); 43 | di.registerLazySingleton(() => githubClient.getService()); 44 | di.registerLazySingleton(() => githubClient.getService()); 45 | di.registerLazySingleton(() => githubClient.getService()); 46 | } 47 | -------------------------------------------------------------------------------- /lib/utils/extensions.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | import 'dart:ui'; 3 | 4 | import 'package:flutterhub/configs/app_store.dart'; 5 | import 'package:flutterhub/configs/constants.dart'; 6 | import 'package:intl/intl.dart'; 7 | import 'package:timeago/timeago.dart' as timeago; 8 | 9 | extension LocaleParsing on String { 10 | Locale parseLocale() { 11 | assert(contains('_') == true); 12 | var languageCode = split('_').first; 13 | var countryCode = split('_').last; 14 | return Locale.fromSubtags( 15 | languageCode: languageCode, countryCode: countryCode); 16 | } 17 | 18 | String toLangIcon() { 19 | assert(length == 2); 20 | switch (toLowerCase()) { 21 | case 'us': 22 | case 'en': 23 | return '🇺🇸'; 24 | case 'ru': 25 | return '🇷🇺'; 26 | case 'am': 27 | case 'hy': 28 | return '🇦🇲'; 29 | default: 30 | return '🇺🇸'; 31 | } 32 | } 33 | 34 | String toLangName() { 35 | assert(length == 2); 36 | switch (toLowerCase()) { 37 | case 'us': 38 | case 'en': 39 | return '${toLangIcon()} English'; 40 | case 'ru': 41 | return '${toLangIcon()} Русский'; 42 | case 'am': 43 | case 'hy': 44 | return '${toLangIcon()} Հայերեն'; 45 | default: 46 | return '${toLangIcon()} English'; 47 | } 48 | } 49 | 50 | String toLangCode() { 51 | assert(contains('_') == true); 52 | return split('_').first; 53 | } 54 | } 55 | 56 | extension FormattedDate on DateTime { 57 | String toDateString() => DateFormat.yMMMd().format(this); 58 | 59 | String toTimeAgoString() => timeago.format(this, 60 | allowFromNow: true, locale: appStore.selectedLanguage); 61 | } 62 | 63 | extension DoubleExtensions on double { 64 | int toGridItemsCount() => min(this, spaceMaxWidth) ~/ spaceMaxGridItemWidth; 65 | } 66 | -------------------------------------------------------------------------------- /lib/utils/helpers.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterhub/configs/constants.dart'; 2 | 3 | int pageForItems(bool isRefresh, List repositories) => 4 | isRefresh ? 1 : repositories.length ~/ kPerPage + 2; 5 | -------------------------------------------------------------------------------- /lib/utils/scroll_behavior.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class MyCustomScrollBehavior extends MaterialScrollBehavior { 5 | @override 6 | Set get dragDevices => { 7 | PointerDeviceKind.touch, 8 | PointerDeviceKind.mouse, 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /lib/utils/secure_storage.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 5 | import 'package:flutterhub/features/core/domain/entities/models.dart'; 6 | 7 | class SecureStorage { 8 | static final SecureStorage instance = 9 | SecureStorage._(const FlutterSecureStorage()); 10 | 11 | SecureStorage._(this._storage); 12 | 13 | final FlutterSecureStorage _storage; 14 | static const _tokenKey = 'TOKEN'; 15 | 16 | Future saveToken(Token token) async { 17 | try { 18 | await _storage.write(key: _tokenKey, value: token.toJsonString()); 19 | } catch (e) { 20 | debugPrint(e.toString()); 21 | return; 22 | } 23 | } 24 | 25 | Future hasToken() async { 26 | var value = await _storage.read(key: _tokenKey); 27 | return value != null; 28 | } 29 | 30 | Future deleteToken() async { 31 | return _storage.delete(key: _tokenKey); 32 | } 33 | 34 | Future getToken() async { 35 | try { 36 | var value = await _storage.read(key: _tokenKey); 37 | if (value == null) return null; 38 | return Token.fromJson(jsonDecode(value)); 39 | } catch (e) { 40 | debugPrint(e.toString()); 41 | return null; 42 | } 43 | } 44 | 45 | Future deleteAll() async { 46 | return _storage.deleteAll(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import flutter_secure_storage_macos 9 | import flutter_web_auth 10 | import path_provider_foundation 11 | import shared_preferences_foundation 12 | import sqflite 13 | import url_launcher_macos 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) 17 | FlutterWebAuthPlugin.register(with: registry.registrar(forPlugin: "FlutterWebAuthPlugin")) 18 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 19 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 20 | SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) 21 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.15' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - flutter_secure_storage_macos (3.3.1): 3 | - FlutterMacOS 4 | - flutter_web_auth (0.4.1): 5 | - FlutterMacOS 6 | - FlutterMacOS (1.0.0) 7 | - FMDB (2.7.5): 8 | - FMDB/standard (= 2.7.5) 9 | - FMDB/standard (2.7.5) 10 | - path_provider_macos (0.0.1): 11 | - FlutterMacOS 12 | - shared_preferences_macos (0.0.1): 13 | - FlutterMacOS 14 | - sqflite (0.0.2): 15 | - FlutterMacOS 16 | - FMDB (>= 2.7.5) 17 | - url_launcher_macos (0.0.1): 18 | - FlutterMacOS 19 | 20 | DEPENDENCIES: 21 | - flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`) 22 | - flutter_web_auth (from `Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos`) 23 | - FlutterMacOS (from `Flutter/ephemeral`) 24 | - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) 25 | - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) 26 | - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`) 27 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 28 | 29 | SPEC REPOS: 30 | trunk: 31 | - FMDB 32 | 33 | EXTERNAL SOURCES: 34 | flutter_secure_storage_macos: 35 | :path: Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos 36 | flutter_web_auth: 37 | :path: Flutter/ephemeral/.symlinks/plugins/flutter_web_auth/macos 38 | FlutterMacOS: 39 | :path: Flutter/ephemeral 40 | path_provider_macos: 41 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos 42 | shared_preferences_macos: 43 | :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos 44 | sqflite: 45 | :path: Flutter/ephemeral/.symlinks/plugins/sqflite/macos 46 | url_launcher_macos: 47 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 48 | 49 | SPEC CHECKSUMS: 50 | flutter_secure_storage_macos: 6ceee8fbc7f484553ad17f79361b556259df89aa 51 | flutter_web_auth: ae2c29ca9b98c00b4e0e8c0919bb4a05d44b76df 52 | FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 53 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a 54 | path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19 55 | shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727 56 | sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea 57 | url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3 58 | 59 | PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0 60 | 61 | COCOAPODS: 1.11.3 62 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = FlutterHub 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.markosyan.flutterhub 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.markosyan. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.client 10 | 11 | com.apple.security.network.server 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSApplicationCategoryType 24 | public.app-category.productivity 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | $(PRODUCT_COPYRIGHT) 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutterhub 2 | description: A new Flutter project. 3 | 4 | version: 1.0.0+9 5 | 6 | environment: 7 | sdk: ">=3.4.3 <4.0.0" 8 | 9 | dependencies: 10 | bloc: ^8.0.0 11 | cached_network_image: ^3.2.1 12 | chopper: ^8.0.0 13 | cupertino_icons: ^1.0.5 14 | dartz: ^0.10.1 15 | equatable: ^2.0.3 16 | filesize: ^2.0.1 17 | flex_color_scheme: ^7.0.0 18 | flutter: 19 | sdk: flutter 20 | flutter_bloc: ^8.0.0 21 | flutter_localizations: 22 | sdk: flutter 23 | flutter_mobx: ^2.0.6 24 | flutter_secure_storage: ^9.0.0 25 | flutter_web_auth: ^0.5.0 26 | font_awesome_flutter: ^10.0.0 27 | formz: ^0.7.0 28 | freezed_annotation: 29 | get_it: ^7.0.0 30 | google_fonts: ^6.0.0 31 | intl: any 32 | json_annotation: ^4.8.1 33 | logging: ^1.0.0 34 | mobx: ^2.0.0 35 | photo_view: ^0.15.0 36 | pull_to_refresh: ^2.0.0 37 | shared_preferences: ^2.0.0 38 | timeago: ^3.0.0 39 | url_launcher: ^6.0.0 40 | 41 | flutter_intl: 42 | main_locale: en_US 43 | enabled: true 44 | 45 | dev_dependencies: 46 | build_runner: ^2.4.0 # dart run build_runner build --delete-conflicting-outputs 47 | chopper_generator: any 48 | flutter_gen: ^5.0.0 49 | flutter_lints: ^4.0.0 50 | flutter_native_splash: ^2.3.0 # flutter pub run flutter_native_splash:create 51 | flutter_test: 52 | sdk: flutter 53 | freezed: ^2.0.0 54 | icons_launcher: ^2.0.0 # flutter pub run icons_launcher:create 55 | json_serializable: ^6.0.0 56 | mobx_codegen: 57 | 58 | flutter: 59 | generate: true 60 | uses-material-design: true 61 | assets: 62 | - assets/images/ 63 | 64 | flutter_native_splash: 65 | color: "#ffffff" 66 | color_dark: "#131d25" 67 | image: assets/images/app_logo.png 68 | 69 | flutter_icons: 70 | android: true 71 | ios: true 72 | macos: true 73 | windows: true 74 | web: true 75 | remove_alpha_ios: true 76 | image_path: "assets/images/app_icon_border.png" 77 | image_path_ios: 'assets/images/app_icon.png' 78 | adaptive_icon_background: '#01579B' 79 | adaptive_icon_foreground: 'assets/images/app_icon_adaptive.png' 80 | adaptive_icon_round: 'assets/images/app_icon_round.png' 81 | -------------------------------------------------------------------------------- /test/features/presentation/cubit/trending/trending_cubit_test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /test/features/repositories/data/datasources/restapi/repos_service_test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /test/features/repositories/data/datasources/restapi/search_service_test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /test/features/repositories/data/datasources/restapi/users_service_test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | void main() { 4 | test('test', () { 5 | expect(1, 1); 6 | }); 7 | } 8 | -------------------------------------------------------------------------------- /web/auth.html: -------------------------------------------------------------------------------- 1 | 2 | Authentication complete 3 |

Authentication is complete. If this does not happen automatically, please 4 | close the window. 5 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutterhub", 3 | "short_name": "flutterhub", 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 | -------------------------------------------------------------------------------- /web/splash/img/dark-1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/dark-1x.png -------------------------------------------------------------------------------- /web/splash/img/dark-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/dark-2x.png -------------------------------------------------------------------------------- /web/splash/img/dark-3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/dark-3x.png -------------------------------------------------------------------------------- /web/splash/img/dark-4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/dark-4x.png -------------------------------------------------------------------------------- /web/splash/img/light-1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/light-1x.png -------------------------------------------------------------------------------- /web/splash/img/light-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/light-2x.png -------------------------------------------------------------------------------- /web/splash/img/light-3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/light-3x.png -------------------------------------------------------------------------------- /web/splash/img/light-4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/web/splash/img/light-4x.png -------------------------------------------------------------------------------- /web/splash/splash.js: -------------------------------------------------------------------------------- 1 | function removeSplashFromWeb() { 2 | const elem = document.getElementById("splash"); 3 | if (elem) { 4 | elem.remove(); 5 | } 6 | document.body.style.background = "transparent"; 7 | } 8 | -------------------------------------------------------------------------------- /web/splash/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin:0; 3 | height:100%; 4 | background: #ffffff; 5 | 6 | background-size: 100% 100%; 7 | } 8 | 9 | .center { 10 | margin: 0; 11 | position: absolute; 12 | top: 50%; 13 | left: 50%; 14 | -ms-transform: translate(-50%, -50%); 15 | transform: translate(-50%, -50%); 16 | } 17 | 18 | .contain { 19 | display:block; 20 | width:100%; height:100%; 21 | object-fit: contain; 22 | } 23 | 24 | .stretch { 25 | display:block; 26 | width:100%; height:100%; 27 | } 28 | 29 | .cover { 30 | display:block; 31 | width:100%; height:100%; 32 | object-fit: cover; 33 | } 34 | 35 | @media (prefers-color-scheme: dark) { 36 | body { 37 | margin:0; 38 | height:100%; 39 | background: #131d25; 40 | 41 | background-size: 100% 100%; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | FlutterSecureStorageWindowsPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); 15 | UrlLauncherWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_secure_storage_windows 7 | url_launcher_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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"flutterhub", 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 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoren93/FlutterHub/ac3ce29e4075dffe09a74bd8fb1abad4692aaaba/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | --------------------------------------------------------------------------------