├── .gitignore ├── .metadata ├── .vscode └── settings.json ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── twitch_best_practices │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets └── img │ ├── img_women.png │ └── img_yogurtland.png ├── 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 │ │ └── 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 └── RunnerTests │ └── RunnerTests.swift ├── lib ├── core │ └── base │ │ ├── view │ │ ├── base_stateless.dart │ │ └── i_base_view.dart │ │ └── viewModel │ │ └── i_base_viewmodel.dart ├── feature │ ├── custom_dialog │ │ ├── ali_keles_view.dart │ │ ├── custom_dialog_view.dart │ │ ├── custom_radios_dialog.dart │ │ ├── text_field_dialog.dart │ │ └── text_field_rounded.dart │ ├── login │ │ ├── loading_state.dart │ │ ├── model │ │ │ ├── login_data_model.dart │ │ │ └── login_model.dart │ │ ├── project_general.dart │ │ ├── service │ │ │ └── login_service.dart │ │ ├── view │ │ │ └── login_view.dart │ │ └── viewModel │ │ │ └── login_viewmodel.dart │ ├── status │ │ ├── status_model.dart │ │ ├── status_operation.dart │ │ ├── status_view.dart │ │ ├── status_view_mixin.dart │ │ └── validator │ │ │ ├── online_validator.dart │ │ │ └── validator_status.dart │ └── text_field_bottom_sheet │ │ ├── text_bottom_mixin.dart │ │ ├── text_bottom_sheet.dart │ │ └── text_field_bottom_sheet_view.dart ├── main.dart └── speed_code │ ├── authentic │ ├── authentic_board.dart │ └── authentic_on_board.dart │ ├── chat_william │ ├── chat_bottom.dart │ ├── chat_william_view.dart │ ├── model │ │ ├── chat_user.dart │ │ └── list_chat.dart │ ├── user_appbar.dart │ └── utility │ │ ├── chat_page_size.dart │ │ └── space_box.dart │ ├── ice_cream │ ├── ice_cream_view.dart │ └── widget │ │ ├── ice_app_bar.dart │ │ └── ice_card.dart │ ├── lang_app │ ├── custom_decoration.dart │ ├── lang_app_view.dart │ ├── lang_dropdown.dart │ └── widget │ │ ├── course_grid.dart │ │ └── today_challange_card.dart │ ├── rent │ ├── rent_model.dart │ ├── rent_view.dart │ ├── rent_view_mixin.dart │ ├── view │ │ ├── project_padding.dart │ │ ├── project_radius.dart │ │ ├── rent_card.dart │ │ └── rent_view_items.dart │ └── widget │ │ └── outline_style.dart │ └── reset_password │ ├── reset_password_mixin.dart │ ├── reset_password_validator.dart │ ├── reset_password_view.dart │ ├── reset_password_widgets.dart │ └── visible_eye.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── app_icon_1024.png │ │ │ ├── app_icon_128.png │ │ │ ├── app_icon_16.png │ │ │ ├── app_icon_256.png │ │ │ ├── app_icon_32.png │ │ │ ├── app_icon_512.png │ │ │ └── app_icon_64.png │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Configs │ │ ├── AppInfo.xcconfig │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements └── RunnerTests │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── test └── widget_test.dart ├── theme.png ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "e1e47221e86272429674bec4f1bd36acc4fc7b77" 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: e1e47221e86272429674bec4f1bd36acc4fc7b77 17 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 18 | - platform: android 19 | create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 20 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 21 | - platform: ios 22 | create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 23 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 24 | - platform: linux 25 | create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 26 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 27 | - platform: macos 28 | create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 29 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 30 | - platform: web 31 | create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 32 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 33 | - platform: windows 34 | create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 35 | base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "docwriter.hotkey.mac": "⌥ + ." 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Flutter refactoring 3 | 4 | Sende kendi projende veya yazdığın bir kodun daha iyisi nasıl olurdu düşüncesi nasıl eklenirdi diye düşünüyorsan bir pr kadar yakınındayım 5 | 6 | ## Kurallar 7 | 8 | Amaç bir işi senin çözemediğin bir sorunu çözmek değil asla. Bir çözülmüş yazılmış öyle veya böyle çalışan kodun daha nasıl iyi olabileceğini tartışmak 9 | - PR atarken kendi kodunuzu bir klasör altına açmalısınız 10 | - Bu kod kesinlikle çalışıyor ve bir ekranda kendi sample_view.dart gibi dosyada çalışıyor olmalı. 11 | 12 | Çalışmayan kodlar, komple proje veya bir iş yaptırma çabası yani topluluğu değil kendini düşünenler önce yayında sövülüp üstüne vb den ban yiyecektir 13 | 14 | 15 | ## Features 16 | 17 | - Status model refactoring 18 |
[![b1](http://i3.ytimg.com/vi/D_9WeK8L6Rw/hqdefault.jpg)](https://youtu.be/D_9WeK8L6Rw) 19 | 20 | 21 | ## Badges 22 | 23 | [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) 24 | 25 | ## FAQ 26 | 27 | #### Nasıl ulaşabilirim 28 | 29 | Pr dışında kabül etmeyeceğim ama sorularını twitch yayınlarından gelip sorabilirsin. 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:very_good_analysis/analysis_options.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | public_member_api_docs: false 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /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 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "com.example.twitch_best_practices" 27 | compileSdkVersion flutter.compileSdkVersion 28 | ndkVersion flutter.ndkVersion 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | 39 | sourceSets { 40 | main.java.srcDirs += 'src/main/kotlin' 41 | } 42 | 43 | defaultConfig { 44 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 45 | applicationId "com.example.twitch_best_practices" 46 | // You can update the following values to match your application needs. 47 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 48 | minSdkVersion flutter.minSdkVersion 49 | targetSdkVersion flutter.targetSdkVersion 50 | versionCode flutterVersionCode.toInteger() 51 | versionName flutterVersionName 52 | } 53 | 54 | buildTypes { 55 | release { 56 | // TODO: Add your own signing config for the release build. 57 | // Signing with the debug keys for now, so `flutter run --release` works. 58 | signingConfig signingConfigs.debug 59 | } 60 | } 61 | } 62 | 63 | flutter { 64 | source '../..' 65 | } 66 | 67 | dependencies {} 68 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/twitch_best_practices/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.twitch_best_practices 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.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 | tasks.register("clean", 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 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | plugins { 14 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 15 | } 16 | } 17 | 18 | include ":app" 19 | 20 | apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" 21 | -------------------------------------------------------------------------------- /assets/img/img_women.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/assets/img/img_women.png -------------------------------------------------------------------------------- /assets/img/img_yogurtland.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/assets/img/img_yogurtland.png -------------------------------------------------------------------------------- /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 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - device_info_plus (0.0.1): 3 | - Flutter 4 | - Flutter (1.0.0) 5 | - package_info_plus (0.4.5): 6 | - Flutter 7 | - path_provider_foundation (0.0.1): 8 | - Flutter 9 | - FlutterMacOS 10 | - share_plus (0.0.1): 11 | - Flutter 12 | - url_launcher_ios (0.0.1): 13 | - Flutter 14 | 15 | DEPENDENCIES: 16 | - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) 17 | - Flutter (from `Flutter`) 18 | - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) 19 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) 20 | - share_plus (from `.symlinks/plugins/share_plus/ios`) 21 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 22 | 23 | EXTERNAL SOURCES: 24 | device_info_plus: 25 | :path: ".symlinks/plugins/device_info_plus/ios" 26 | Flutter: 27 | :path: Flutter 28 | package_info_plus: 29 | :path: ".symlinks/plugins/package_info_plus/ios" 30 | path_provider_foundation: 31 | :path: ".symlinks/plugins/path_provider_foundation/darwin" 32 | share_plus: 33 | :path: ".symlinks/plugins/share_plus/ios" 34 | url_launcher_ios: 35 | :path: ".symlinks/plugins/url_launcher_ios/ios" 36 | 37 | SPEC CHECKSUMS: 38 | device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea 39 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 40 | package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 41 | path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 42 | share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028 43 | url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 44 | 45 | PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 46 | 47 | COCOAPODS: 1.13.0 48 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Twitch Best Practices 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | twitch_best_practices 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/core/base/view/base_stateless.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/core/base/viewModel/i_base_viewmodel.dart'; 3 | 4 | mixin BaseState 5 | on State { 6 | @override 7 | Widget build(BuildContext context) => customBuild(context); 8 | 9 | /// set your view model 10 | T get viewModel; 11 | 12 | /// make your custom widget 13 | Widget customBuild(BuildContext context); 14 | 15 | /// call this method for your ui operation before drawing ui 16 | void onInitialize(); 17 | 18 | @override 19 | void initState() { 20 | super.initState(); 21 | onInitialize.call(); 22 | WidgetsBinding.instance.addPostFrameCallback((timeStamp) { 23 | viewModel.init(); 24 | }); 25 | } 26 | 27 | @override 28 | void dispose() { 29 | super.dispose(); 30 | viewModel.reset(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/core/base/view/i_base_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:stacked/stacked.dart'; 3 | 4 | import 'package:twitch_best_practices/core/base/viewModel/i_base_viewmodel.dart' 5 | show IBaseViewModel; 6 | 7 | class IBaseView extends StatelessWidget { 8 | const IBaseView({ 9 | required this.viewModel, 10 | required this.builder, 11 | super.key, 12 | this.loadingWidget, 13 | this.onModelReady, 14 | }); 15 | 16 | final Widget Function(T model) builder; 17 | 18 | final T viewModel; 19 | final Widget? loadingWidget; 20 | 21 | final dynamic Function(T? model)? onModelReady; 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return ViewModelBuilder.reactive( 26 | disposeViewModel: false, 27 | onDispose: (viewModel) => viewModel.reset(), 28 | viewModelBuilder: () => viewModel, 29 | builder: (_, T? model, __) => builder(model!), 30 | onViewModelReady: (T? viewModel) async { 31 | if (onModelReady == null) { 32 | await viewModel?.init(); 33 | } else { 34 | await onModelReady!(viewModel); 35 | } 36 | }, 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/core/base/viewModel/i_base_viewmodel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | abstract class IBaseViewModel extends ChangeNotifier { 4 | Future init(); 5 | 6 | void reset(); 7 | } 8 | -------------------------------------------------------------------------------- /lib/feature/custom_dialog/ali_keles_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/custom_dialog/custom_dialog_view.dart'; 3 | import 'package:twitch_best_practices/feature/custom_dialog/text_field_rounded.dart'; 4 | 5 | class AliKelesView extends StatefulWidget { 6 | const AliKelesView({super.key}); 7 | @override 8 | State createState() => _AliKelesViewState(); 9 | } 10 | 11 | class _AliKelesViewState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar(), 16 | floatingActionButton: FloatingActionButton( 17 | onPressed: () async { 18 | final response = await CustomDialog.showDialogRadios( 19 | context: context, 20 | ); 21 | 22 | if (response != null) { 23 | print(response); 24 | } 25 | }, 26 | ), 27 | body: TextFieldRounded( 28 | controller: TextEditingController(), 29 | onChanged: (value) {}, 30 | ), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/feature/custom_dialog/custom_dialog_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/custom_dialog/custom_radios_dialog.dart'; 3 | import 'package:twitch_best_practices/feature/custom_dialog/text_field_dialog.dart'; 4 | 5 | @immutable 6 | final class CustomDialog { 7 | const CustomDialog._(); 8 | 9 | static Future showMyDialog({ 10 | required BuildContext context, 11 | required String title, 12 | required String text, 13 | required Widget content, 14 | required List? actions, 15 | bool barrierDismissible = true, 16 | }) async { 17 | return showDialog( 18 | context: context, 19 | barrierDismissible: barrierDismissible, 20 | builder: (BuildContext context) { 21 | return AlertDialog( 22 | title: Text(title), 23 | content: content, 24 | actions: actions, 25 | ); 26 | }, 27 | ); 28 | } 29 | 30 | static Future showDialogTextField({ 31 | required BuildContext context, 32 | required String title, 33 | }) async { 34 | final response = await showDialog( 35 | context: context, 36 | builder: (BuildContext context) { 37 | return TextFieldDialog(title: title); 38 | }, 39 | ); 40 | 41 | return response ?? ''; 42 | } 43 | 44 | static Future showDialogRadios({ 45 | required BuildContext context, 46 | }) async { 47 | final response = await showDialog( 48 | context: context, 49 | builder: (BuildContext context) { 50 | return const CustomRadiosDialog(); 51 | }, 52 | ); 53 | 54 | return response; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/feature/custom_dialog/custom_radios_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/foundation.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | class CustomRadiosDialog extends StatefulWidget { 8 | const CustomRadiosDialog({super.key}); 9 | 10 | @override 11 | State createState() => _CustomRadiosDialogState(); 12 | } 13 | 14 | class _CustomRadiosDialogState extends State { 15 | final List> items = [ 16 | const MapEntry('Item 1', 5), 17 | const MapEntry('Item 2', 4), 18 | const MapEntry('Item 3', 2), 19 | const MapEntry('Item 4', 3), 20 | ]; 21 | @override 22 | Widget build(BuildContext context) { 23 | if (!Platform.isIOS) { 24 | return _DialogForIOS(items); 25 | } 26 | return _DialogForGeneral('Sample', items); 27 | } 28 | } 29 | 30 | class _DialogForGeneral extends StatefulWidget { 31 | const _DialogForGeneral(this.title, this.items); 32 | 33 | final String title; 34 | final List> items; 35 | 36 | @override 37 | State<_DialogForGeneral> createState() => _DialogForGeneralState(); 38 | } 39 | 40 | class _DialogForGeneralState extends State<_DialogForGeneral> { 41 | int? _groupValue; 42 | 43 | void _updateValue(int value) { 44 | setState(() { 45 | _groupValue = value; 46 | }); 47 | } 48 | 49 | @override 50 | Widget build(BuildContext context) { 51 | return AlertDialog( 52 | actions: [ 53 | TextButton( 54 | onPressed: () { 55 | if (_groupValue == null) return; 56 | Navigator.pop(context, _groupValue); 57 | }, 58 | child: const Text('OK'), 59 | ), 60 | ], 61 | title: Text(widget.title), 62 | content: SizedBox( 63 | height: MediaQuery.sizeOf(context).height * 0.5, 64 | width: MediaQuery.sizeOf(context).width * 0.5, 65 | child: Visibility( 66 | visible: kIsWeb, 67 | replacement: 68 | _RadioColumListView(widget.items, _updateValue, _groupValue), 69 | child: _RadioColumListView(widget.items, _updateValue, _groupValue), 70 | ), 71 | ), 72 | ); 73 | } 74 | } 75 | 76 | class _DialogForIOS extends StatefulWidget { 77 | const _DialogForIOS(this.items); 78 | 79 | final List> items; 80 | 81 | @override 82 | State<_DialogForIOS> createState() => _DialogForIOSState(); 83 | } 84 | 85 | class _DialogForIOSState extends State<_DialogForIOS> { 86 | int? _cupertinoSelected; 87 | @override 88 | Widget build(BuildContext context) { 89 | return Column( 90 | children: [ 91 | SizedBox(height: MediaQuery.sizeOf(context).height * 0.6), 92 | Container( 93 | color: Theme.of(context).colorScheme.background, 94 | width: double.maxFinite, 95 | alignment: Alignment.centerRight, 96 | child: TextButton( 97 | onPressed: () { 98 | if (_cupertinoSelected == null) return; 99 | Navigator.pop(context, _cupertinoSelected); 100 | }, 101 | child: const Text('OK'), 102 | ), 103 | ), 104 | Expanded( 105 | child: CupertinoPicker.builder( 106 | itemExtent: MediaQuery.sizeOf(context).height * 0.05, 107 | onSelectedItemChanged: (value) { 108 | _cupertinoSelected = value; 109 | }, 110 | childCount: widget.items.length, 111 | itemBuilder: (context, index) => Center( 112 | child: Text(widget.items[index].key), 113 | ), 114 | backgroundColor: Theme.of(context).colorScheme.background, 115 | ), 116 | ), 117 | ], 118 | ); 119 | } 120 | } 121 | 122 | class _RadioColumListView extends StatelessWidget { 123 | const _RadioColumListView(this.items, this.onChanged, this.groupValue); 124 | final List> items; 125 | final ValueChanged onChanged; 126 | final int? groupValue; 127 | @override 128 | Widget build(BuildContext context) { 129 | return Column( 130 | children: [ 131 | const Divider(), 132 | Expanded( 133 | child: ListView.builder( 134 | itemCount: items.length, 135 | itemBuilder: (context, index) { 136 | return ListTile( 137 | onTap: () { 138 | onChanged.call(items[index].value); 139 | }, 140 | title: Text(items[index].key), 141 | leading: Radio( 142 | value: items[index].value, 143 | groupValue: groupValue, 144 | onChanged: (value) { 145 | if (value == null) return; 146 | onChanged.call(value); 147 | }, 148 | ), 149 | ); 150 | }, 151 | ), 152 | ), 153 | const Divider(), 154 | ], 155 | ); 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /lib/feature/custom_dialog/text_field_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/custom_dialog/text_field_rounded.dart'; 3 | 4 | class TextFieldDialog extends StatefulWidget { 5 | const TextFieldDialog({required this.title, super.key}); 6 | final String title; 7 | 8 | @override 9 | State createState() => _TextFieldDialogState(); 10 | } 11 | 12 | class _TextFieldDialogState extends State { 13 | String _value = ''; 14 | @override 15 | Widget build(BuildContext context) { 16 | return AlertDialog( 17 | title: Text(widget.title), 18 | actions: [ 19 | IconButton( 20 | onPressed: () { 21 | Navigator.pop(context, _value); 22 | }, 23 | icon: const Icon(Icons.save), 24 | ), 25 | ], 26 | content: TextFieldRounded( 27 | hintText: 'Text here...', 28 | keyboardType: TextInputType.number, 29 | onChanged: (text) { 30 | _value = text; 31 | }, 32 | controller: TextEditingController(), 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/feature/custom_dialog/text_field_rounded.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// It will create rounded text field 4 | /// 5 | @immutable 6 | final class TextFieldRounded extends StatefulWidget { 7 | const TextFieldRounded({ 8 | required this.onChanged, 9 | this.controller, 10 | super.key, 11 | this.labelText, 12 | this.hintText, 13 | this.keyboardType = TextInputType.text, 14 | this.contentFieldEdge = TextFieldPaddings.small, 15 | this.boxDecoration, 16 | }); 17 | 18 | final String? labelText; 19 | final String? hintText; 20 | final TextInputType keyboardType; 21 | 22 | final TextEditingController? controller; 23 | final ValueChanged onChanged; 24 | final TextFieldPaddings contentFieldEdge; 25 | final BoxDecoration? boxDecoration; 26 | 27 | @override 28 | State createState() => _TextFieldRoundedState(); 29 | } 30 | 31 | class _TextFieldRoundedState extends State { 32 | late final TextEditingController? _controller; 33 | late final String _labelText; 34 | @override 35 | void initState() { 36 | super.initState(); 37 | _controller = widget.controller; 38 | _labelText = widget.labelText ?? ''; 39 | } 40 | 41 | @override 42 | void dispose() { 43 | super.dispose(); 44 | _controller?.dispose(); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) { 49 | if (_labelText.isEmpty) { 50 | return _textField(); 51 | } 52 | 53 | return Column( 54 | crossAxisAlignment: CrossAxisAlignment.start, 55 | children: [ 56 | Text(_labelText, style: Theme.of(context).textTheme.titleLarge), 57 | _textField(), 58 | ], 59 | ); 60 | } 61 | 62 | DecoratedBox _textField() { 63 | return DecoratedBox( 64 | decoration: widget.boxDecoration ?? const _Decoration(), 65 | child: TextFormField( 66 | onChanged: widget.onChanged, 67 | keyboardType: widget.keyboardType, 68 | controller: _controller, 69 | cursorColor: Colors.black, 70 | decoration: _decoration(), 71 | ), 72 | ); 73 | } 74 | 75 | InputDecoration _decoration() { 76 | return InputDecoration( 77 | border: InputBorder.none, 78 | focusedBorder: InputBorder.none, 79 | enabledBorder: InputBorder.none, 80 | errorBorder: InputBorder.none, 81 | disabledBorder: InputBorder.none, 82 | contentPadding: widget.contentFieldEdge.padding, 83 | hintText: widget.hintText, 84 | ); 85 | } 86 | } 87 | 88 | final class _Decoration extends BoxDecoration { 89 | const _Decoration() 90 | : super( 91 | color: Colors.grey, 92 | borderRadius: const BorderRadius.all( 93 | Radius.circular(20), 94 | ), 95 | ); 96 | } 97 | 98 | enum TextFieldPaddings { 99 | small(EdgeInsets.all(8)), 100 | medium(EdgeInsets.all(16)), 101 | large(EdgeInsets.all(24)); 102 | 103 | final EdgeInsets padding; 104 | const TextFieldPaddings(this.padding); 105 | } 106 | -------------------------------------------------------------------------------- /lib/feature/login/loading_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:twitch_best_practices/core/base/view/base_stateless.dart'; 4 | import 'package:twitch_best_practices/core/base/viewModel/i_base_viewmodel.dart'; 5 | 6 | mixin ViewState 7 | on BaseState { 8 | final ValueNotifier _isLoading = ValueNotifier(false); 9 | 10 | void changeLoading({required bool value}) { 11 | _isLoading.value = value; 12 | } 13 | 14 | Future showDialogCustom() async { 15 | changeLoading(value: true); 16 | await showDialog( 17 | context: context, 18 | builder: (context) => const Center( 19 | child: CircularProgressIndicator(), 20 | ), 21 | ); 22 | changeLoading(value: false); 23 | } 24 | 25 | @override 26 | Widget customBuild(BuildContext context); 27 | @override 28 | Widget build(BuildContext context) { 29 | return Material( 30 | child: Stack( 31 | children: [ 32 | customBuild(context), 33 | ValueListenableBuilder( 34 | valueListenable: _isLoading, 35 | builder: (context, value, child) { 36 | if (value) { 37 | return ColoredBox( 38 | color: Colors.grey.withOpacity(0.2), 39 | child: const Center( 40 | child: CircularProgressIndicator( 41 | color: Colors.red, 42 | ), 43 | ), 44 | ); 45 | } 46 | return const SizedBox.shrink(); 47 | }, 48 | ), 49 | ], 50 | ), 51 | ); 52 | } 53 | 54 | Widget loadingWithBase() { 55 | return Material( 56 | child: Stack( 57 | children: [ 58 | ValueListenableBuilder( 59 | valueListenable: _isLoading, 60 | builder: (context, value, child) { 61 | if (value) { 62 | return const CircularProgressIndicator(); 63 | } 64 | return const SizedBox.shrink(); 65 | }, 66 | ), 67 | super.build(context), 68 | ], 69 | ), 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/feature/login/model/login_data_model.dart: -------------------------------------------------------------------------------- 1 | final class LoginDataModel { 2 | LoginDataModel({ 3 | required this.email, 4 | required this.password, 5 | }); 6 | 7 | final String email; 8 | final String password; 9 | 10 | // JSON SERIALIZABLE 11 | Map toJson() { 12 | return { 13 | 'email': email, 14 | 'password': password, 15 | }; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/feature/login/model/login_model.dart: -------------------------------------------------------------------------------- 1 | final class LoginModel { 2 | LoginModel({ 3 | this.token, 4 | }); 5 | 6 | factory LoginModel.fromJson(Map json) { 7 | return LoginModel( 8 | token: json['token'] as String?, 9 | ); 10 | } 11 | 12 | final String? token; 13 | } 14 | -------------------------------------------------------------------------------- /lib/feature/login/project_general.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | final class ProjectGeneral { 4 | ProjectGeneral._(); 5 | 6 | static const loginTitle = 'Giriş'; 7 | } 8 | 9 | enum ProjectLoginPadding { 10 | /// value is 8 11 | low(8), 12 | 13 | /// value is 16 14 | normal(16), 15 | 16 | /// value is 20 17 | high(20); 18 | 19 | final double value; 20 | const ProjectLoginPadding(this.value); 21 | 22 | EdgeInsets get symmetricVertical => EdgeInsets.symmetric(vertical: value); 23 | EdgeInsets get symmetricHorizontal => EdgeInsets.symmetric(horizontal: value); 24 | EdgeInsets get symmetric => 25 | EdgeInsets.symmetric(horizontal: value, vertical: value); 26 | EdgeInsets get onlyTop => EdgeInsets.only(top: value); 27 | EdgeInsets get onlyBottom => EdgeInsets.only(bottom: value); 28 | EdgeInsets get onlyLeft => EdgeInsets.only(left: value); 29 | EdgeInsets get onlyRight => EdgeInsets.only(right: value); 30 | EdgeInsets get all => EdgeInsets.all(value); 31 | } 32 | -------------------------------------------------------------------------------- /lib/feature/login/service/login_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dio/dio.dart'; 4 | import 'package:twitch_best_practices/feature/login/model/login_data_model.dart'; 5 | 6 | import 'package:twitch_best_practices/feature/login/model/login_model.dart'; 7 | 8 | class LoginService with _NetworkMixin { 9 | LoginService({required this.dio}); 10 | 11 | final Dio dio; 12 | 13 | Future<(LoginModel?, CustomError?)> login( 14 | LoginDataModel loginDataModel, 15 | ) async { 16 | final response = await dio.post( 17 | _NetworkMixin.loginUrl, 18 | data: loginDataModel.toJson(), 19 | ); 20 | 21 | if (response.statusCode != HttpStatus.ok) return (null, CustomError.server); 22 | final data = response.data; 23 | if (data is Map) return (LoginModel.fromJson(data), null); 24 | 25 | return (null, CustomError.unknown); 26 | } 27 | } 28 | 29 | mixin _NetworkMixin { 30 | static const String loginUrl = 'https://reqres.in/api/login'; 31 | } 32 | 33 | enum CustomError { 34 | network, 35 | server, 36 | unknown; 37 | 38 | String get message { 39 | switch (this) { 40 | case CustomError.network: 41 | return 'Network Error'; 42 | case CustomError.server: 43 | return 'Server Error'; 44 | case CustomError.unknown: 45 | return 'Unknown Error'; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/feature/login/view/login_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/core/base/view/base_stateless.dart'; 3 | import 'package:twitch_best_practices/feature/login/loading_state.dart'; 4 | import 'package:twitch_best_practices/feature/login/project_general.dart'; 5 | import 'package:twitch_best_practices/feature/login/viewModel/login_viewmodel.dart'; 6 | 7 | extension MediaQueryExtension on BuildContext { 8 | Size get sizeOf => MediaQuery.sizeOf(this); 9 | } 10 | 11 | class LoginView extends StatefulWidget { 12 | const LoginView({super.key}); 13 | 14 | @override 15 | State createState() => _LoginViewState(); 16 | } 17 | 18 | class _LoginViewState extends State 19 | with BaseState, ViewState { 20 | @override 21 | final LoginViewModel viewModel = LoginViewModel(); 22 | 23 | @override 24 | void onInitialize() {} 25 | 26 | @override 27 | Widget customBuild(BuildContext context) { 28 | return Scaffold( 29 | floatingActionButton: FloatingActionButton( 30 | onPressed: () async {}, 31 | ), 32 | body: SingleChildScrollView( 33 | child: Center( 34 | child: Column( 35 | children: [ 36 | SizedBox(height: context.sizeOf.height * .2), 37 | Padding( 38 | padding: ProjectLoginPadding.high.symmetricVertical, 39 | child: TextField(onChanged: viewModel.changeEmail), 40 | ), 41 | Padding( 42 | padding: ProjectLoginPadding.high.symmetricVertical, 43 | child: TextField(onChanged: viewModel.changePassword), 44 | ), 45 | ElevatedButton( 46 | onPressed: viewModel.login, 47 | child: const Text(ProjectGeneral.loginTitle), 48 | ), 49 | ], 50 | ), 51 | ), 52 | ), 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/feature/login/viewModel/login_viewmodel.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:twitch_best_practices/core/base/viewModel/i_base_viewmodel.dart'; 4 | import 'package:twitch_best_practices/feature/login/model/login_data_model.dart'; 5 | import 'package:twitch_best_practices/feature/login/service/login_service.dart'; 6 | 7 | final class LoginViewModel extends IBaseViewModel with _LoginViewModelMixin { 8 | final LoginService _loginService = LoginService( 9 | dio: Dio(), 10 | ); 11 | 12 | @override 13 | Future init() async {} 14 | 15 | @override 16 | void reset() {} 17 | 18 | Future login() async { 19 | if (!validate) return; 20 | final (response, status) = await _loginService.login( 21 | LoginDataModel(email: _email, password: _password), 22 | ); 23 | 24 | if (status != null) { 25 | if (kDebugMode) print(status.message); 26 | return; 27 | } 28 | 29 | if (response == null) return; 30 | if (response.token?.isEmpty ?? true) return; 31 | } 32 | } 33 | 34 | mixin _LoginViewModelMixin { 35 | String _email = ''; 36 | String _password = ''; 37 | 38 | void changeEmail(String email) { 39 | _email = email; 40 | } 41 | 42 | void changePassword(String password) { 43 | _password = password; 44 | } 45 | 46 | bool get validate => _password.isNotEmpty && _email.isNotEmpty; 47 | } 48 | -------------------------------------------------------------------------------- /lib/feature/status/status_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | @immutable 4 | final class StatusModel { 5 | final bool? isOnline; 6 | final bool? isDelivery; 7 | final bool? isActive; 8 | final bool? isReturn; 9 | final String? name; 10 | 11 | const StatusModel( 12 | {this.isOnline, 13 | this.isDelivery, 14 | this.isActive, 15 | this.isReturn, 16 | this.name}); 17 | 18 | static const StatusModel sample1 = 19 | StatusModel(isActive: true, isOnline: true, name: 'vb'); 20 | static const StatusModel sample2 = 21 | StatusModel(isReturn: true, isOnline: true, isDelivery: true); 22 | } 23 | 24 | enum StatusType { 25 | online, 26 | delivery, 27 | active, 28 | canReturn, 29 | } 30 | -------------------------------------------------------------------------------- /lib/feature/status/status_operation.dart: -------------------------------------------------------------------------------- 1 | import 'package:twitch_best_practices/feature/status/status_model.dart'; 2 | import 'package:twitch_best_practices/feature/status/validator/online_validator.dart'; 3 | import 'package:twitch_best_practices/feature/status/validator/validator_status.dart'; 4 | 5 | final class StatusOperation { 6 | final StatusModel model; 7 | 8 | StatusOperation({required this.model}); 9 | 10 | List makeStatusTypeItems() { 11 | final List items = []; 12 | final List validators = [ 13 | OnlineValidator(model: model), 14 | ActiveValidator(model: model), 15 | ]; 16 | 17 | final newItems = validators.map((e) => e.make()).toList(); 18 | items.add(isOnlineType); 19 | items.add(isDeliveryType); 20 | items.add(isActiveType); 21 | items.add(isReturnType); 22 | 23 | return items 24 | .where((element) => element != null) 25 | .cast() 26 | .toList(); 27 | } 28 | 29 | StatusType? get isOnlineType => 30 | model.isOnline == true ? StatusType.online : null; 31 | 32 | StatusType? get isDeliveryType => 33 | model.isDelivery == true ? StatusType.delivery : null; 34 | 35 | StatusType? get isActiveType => 36 | model.isActive == true ? StatusType.active : null; 37 | 38 | StatusType? get isReturnType => 39 | model.isReturn == true ? StatusType.canReturn : null; 40 | } 41 | -------------------------------------------------------------------------------- /lib/feature/status/status_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/status/status_model.dart'; 3 | import 'package:twitch_best_practices/feature/status/status_operation.dart'; 4 | import 'package:twitch_best_practices/feature/status/status_view_mixin.dart'; 5 | 6 | class StatusView extends StatefulWidget { 7 | const StatusView({Key? key}) : super(key: key); 8 | @override 9 | State createState() => _StatusViewState(); 10 | } 11 | 12 | // 00:21 13 | class _StatusViewState extends State with StatusViewMixin { 14 | @override 15 | Widget build(BuildContext context) { 16 | return Scaffold( 17 | appBar: AppBar(), 18 | body: ValueListenableBuilder( 19 | valueListenable: statusModelNotifier, 20 | builder: (BuildContext context, StatusModel? value, Widget? child) { 21 | if (value == null) { 22 | return const Center(child: CircularProgressIndicator()); 23 | } 24 | return _StatusColumn(statusModel: value); 25 | }, 26 | )); 27 | } 28 | } 29 | 30 | class _StatusColumn extends StatelessWidget { 31 | _StatusColumn({ 32 | required this.statusModel, 33 | }) { 34 | _items = StatusOperation(model: statusModel).makeStatusTypeItems(); 35 | } 36 | 37 | late final List _items; 38 | final StatusModel statusModel; 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return ListView.builder( 43 | itemCount: _items.length, 44 | itemBuilder: (BuildContext context, int index) { 45 | return _StatusCard(name: statusModel.name, type: _items[index]); 46 | }, 47 | ); 48 | } 49 | } 50 | 51 | class _StatusCard extends StatelessWidget { 52 | const _StatusCard({required this.name, required this.type}); 53 | 54 | final String? name; 55 | final StatusType type; 56 | 57 | @override 58 | Widget build(BuildContext context) { 59 | return Column( 60 | children: [ 61 | Text(name ?? ''), 62 | Text(type.name), 63 | ], 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/feature/status/status_view_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/status/status_model.dart'; 3 | import 'package:twitch_best_practices/feature/status/status_view.dart'; 4 | 5 | mixin StatusViewMixin on State { 6 | final ValueNotifier _statusModelNotifier = ValueNotifier(null); 7 | ValueNotifier get statusModelNotifier => _statusModelNotifier; 8 | @override 9 | void initState() { 10 | super.initState(); 11 | _fetchSingleData(); 12 | } 13 | 14 | Future _fetchSingleData() async { 15 | await Future.delayed(const Duration(seconds: 2)); 16 | _statusModelNotifier.value = StatusModel.sample2; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/feature/status/validator/online_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:twitch_best_practices/feature/status/status_model.dart'; 2 | import 'package:twitch_best_practices/feature/status/validator/validator_status.dart'; 3 | 4 | final class OnlineValidator extends ValidatorStatus { 5 | OnlineValidator({required super.model}); 6 | 7 | @override 8 | StatusType? make() { 9 | if (model.isOnline == true) { 10 | return StatusType.online; 11 | } 12 | 13 | return null; 14 | } 15 | } 16 | 17 | final class ActiveValidator extends ValidatorStatus { 18 | ActiveValidator({required super.model}); 19 | 20 | @override 21 | StatusType? make() { 22 | if (model.isActive == true) { 23 | return StatusType.active; 24 | } 25 | 26 | return null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/feature/status/validator/validator_status.dart: -------------------------------------------------------------------------------- 1 | import 'package:twitch_best_practices/feature/status/status_model.dart'; 2 | 3 | abstract class ValidatorStatus { 4 | final StatusModel model; 5 | 6 | ValidatorStatus({required this.model}); 7 | StatusType? make(); 8 | } 9 | -------------------------------------------------------------------------------- /lib/feature/text_field_bottom_sheet/text_bottom_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/text_field_bottom_sheet/text_bottom_sheet.dart'; 3 | import 'package:twitch_best_practices/feature/text_field_bottom_sheet/text_field_bottom_sheet_view.dart'; 4 | 5 | mixin TextBottomMixin on State { 6 | final ValueNotifier titleNotifier = ValueNotifier(""); 7 | 8 | Future showTextFieldSheet() async { 9 | final response = await TextBottomSheet.show(context); 10 | if (response == null) return; 11 | titleNotifier.value = response.value; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/feature/text_field_bottom_sheet/text_bottom_sheet.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | final class TextBottomModel { 4 | TextBottomModel({required this.value, required this.isCheck}); 5 | final String value; 6 | final bool isCheck; 7 | } 8 | 9 | class TextBottomSheet extends StatefulWidget { 10 | const TextBottomSheet({super.key}); 11 | 12 | static Future show(BuildContext context) { 13 | return showModalBottomSheet( 14 | context: context, 15 | builder: (context) { 16 | return const TextBottomSheet(); 17 | }, 18 | ); 19 | } 20 | 21 | @override 22 | State createState() => _TextBottomSheetState(); 23 | } 24 | 25 | class _TextBottomSheetState extends State with _TextMixin { 26 | static const String _buttonTitle = 'Save'; 27 | @override 28 | Widget build(BuildContext context) { 29 | return Column( 30 | children: [ 31 | TextField( 32 | onChanged: _updateText, 33 | ), 34 | Checkbox( 35 | value: _isCheck, 36 | onChanged: _updateCheckBox, 37 | ), 38 | IgnorePointer( 39 | ignoring: !_isValid, 40 | child: AnimatedOpacity( 41 | duration: const Duration(seconds: 1), 42 | opacity: _isValid ? 1 : 0.2, 43 | child: ElevatedButton( 44 | onPressed: _onButtonPressed, 45 | child: const Text(_buttonTitle), 46 | ), 47 | ), 48 | ), 49 | ], 50 | ); 51 | } 52 | } 53 | 54 | mixin _TextMixin on State { 55 | bool _isCheck = false; 56 | String _textValue = ''; 57 | bool get _isValid => _isCheck && _textValue.isNotEmpty; 58 | void _updateCheckBox(bool? value) { 59 | if (value == null) return; 60 | setState(() { 61 | _isCheck = value; 62 | }); 63 | } 64 | 65 | void _updateText(String value) { 66 | setState(() { 67 | _textValue = value; 68 | }); 69 | } 70 | 71 | void _onButtonPressed() { 72 | if (!_isValid) return; 73 | Navigator.pop( 74 | context, 75 | TextBottomModel(value: _textValue, isCheck: _isCheck), 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/feature/text_field_bottom_sheet/text_field_bottom_sheet_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/text_field_bottom_sheet/text_bottom_mixin.dart'; 3 | 4 | class TextBottomSheetView extends StatefulWidget { 5 | const TextBottomSheetView({Key? key}) : super(key: key); 6 | @override 7 | State createState() => _TextBottomSheetViewState(); 8 | } 9 | 10 | class _TextBottomSheetViewState extends State 11 | with TextBottomMixin { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar( 16 | title: ValueListenableBuilder( 17 | valueListenable: titleNotifier, 18 | builder: (BuildContext context, String value, Widget? child) { 19 | return Text(value); 20 | }, 21 | ), 22 | ), 23 | floatingActionButton: FloatingActionButton( 24 | onPressed: showTextFieldSheet, 25 | child: const Icon(Icons.add), 26 | ), 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/feature/login/view/login_view.dart'; 3 | 4 | void main() => runApp(const MyApp()); 5 | 6 | class MyApp extends StatelessWidget { 7 | const MyApp({super.key}); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return MaterialApp( 12 | title: 'Material App', 13 | home: LoginView(), 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/speed_code/authentic/authentic_board.dart: -------------------------------------------------------------------------------- 1 | final class AuthenticBoard { 2 | const AuthenticBoard({ 3 | required this.title, 4 | required this.description, 5 | }); 6 | final String title; 7 | final String description; 8 | } 9 | -------------------------------------------------------------------------------- /lib/speed_code/authentic/authentic_on_board.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/authentic/authentic_board.dart'; 3 | 4 | class AuthenticView extends StatefulWidget { 5 | const AuthenticView({super.key}); 6 | @override 7 | State createState() => _AuthenticViewState(); 8 | } 9 | 10 | class _AuthenticViewState extends State { 11 | @override 12 | Widget build(BuildContext context) { 13 | return const Scaffold( 14 | body: Column( 15 | children: [ 16 | Expanded(flex: 4, child: _BodyHeader()), 17 | Expanded( 18 | flex: 3, 19 | child: _BodySubView( 20 | AuthenticBoard( 21 | title: 'Best Quality For Your Qutfit', 22 | description: 23 | "Explore the 2021's best clothes from over 20k brands", 24 | ), 25 | ), 26 | ), 27 | ], 28 | ), 29 | ); 30 | } 31 | } 32 | 33 | class _BodyHeader extends StatelessWidget { 34 | const _BodyHeader(); 35 | 36 | @override 37 | Widget build(BuildContext context) { 38 | // wee ned to change image to svg etc. 39 | return Image.asset( 40 | _ImagePath.women.png, 41 | fit: BoxFit.cover, 42 | ); 43 | } 44 | } 45 | 46 | class _BodySubView extends StatelessWidget { 47 | const _BodySubView(this.model); 48 | final AuthenticBoard model; 49 | 50 | @override 51 | Widget build(BuildContext context) { 52 | return Column( 53 | children: [ 54 | const _EmptyHeight(), 55 | Text( 56 | model.title, 57 | textAlign: TextAlign.center, 58 | style: Theme.of(context).textTheme.bodyLarge?.copyWith( 59 | fontWeight: FontWeight.bold, 60 | fontSize: Theme.of(context).textTheme.headlineLarge?.fontSize, 61 | ), 62 | ), 63 | const _EmptyHeight(), 64 | Text( 65 | model.description, 66 | textAlign: TextAlign.center, 67 | style: Theme.of(context).textTheme.headlineSmall?.copyWith( 68 | fontWeight: FontWeight.w300, 69 | ), 70 | ), 71 | const _EmptyHeight(), 72 | const _GetStarted(), 73 | ], 74 | ); 75 | } 76 | } 77 | 78 | class _GetStarted extends StatelessWidget { 79 | const _GetStarted(); 80 | 81 | @override 82 | Widget build(BuildContext context) { 83 | return ElevatedButton( 84 | onPressed: () {}, 85 | style: ElevatedButton.styleFrom( 86 | shape: RoundedRectangleBorder( 87 | borderRadius: BorderRadius.circular(8), 88 | ), 89 | backgroundColor: Theme.of(context).colorScheme.error.withOpacity(0.8), 90 | ), 91 | child: Padding( 92 | padding: const EdgeInsets.all(24), 93 | child: SizedBox( 94 | width: MediaQuery.sizeOf(context).width * 0.5, 95 | child: const Center(child: Text('Get Started')), 96 | ), 97 | ), 98 | ); 99 | } 100 | } 101 | 102 | class _EmptyHeight extends StatelessWidget { 103 | const _EmptyHeight(); 104 | 105 | @override 106 | Widget build(BuildContext context) { 107 | return const SizedBox(height: 24); 108 | } 109 | } 110 | 111 | class _ImagePath { 112 | static const women = 'img_women'; 113 | } 114 | 115 | extension on String { 116 | String get png => 'assets/img/$this.png'; 117 | } 118 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/chat_bottom.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:twitch_best_practices/speed_code/chat_william/utility/chat_page_size.dart'; 4 | import 'package:twitch_best_practices/speed_code/chat_william/utility/space_box.dart'; 5 | 6 | class ChatBottom extends StatefulWidget { 7 | const ChatBottom({required this.onSendPressed, super.key}); 8 | final Future Function(String value) onSendPressed; 9 | 10 | @override 11 | State createState() => _ChatBottomState(); 12 | } 13 | 14 | class _ChatBottomState extends State with _ChatBottomMixin { 15 | static const _buttonTitle = 'Write a message'; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return BottomAppBar( 20 | child: Padding( 21 | padding: const EdgeInsets.symmetric(horizontal: ChatPageSize.normal), 22 | child: Row( 23 | children: [ 24 | Expanded( 25 | child: TextField( 26 | controller: _textEditingController, 27 | onChanged: _updateMessageText, 28 | onTap: () { 29 | _updateOnTappedField(value: true); 30 | }, 31 | onTapOutside: (event) { 32 | _updateOnTappedField(value: false); 33 | }, 34 | decoration: InputDecoration( 35 | hintText: _buttonTitle, 36 | suffix: _SuffixLoading( 37 | isSendingMessageNotifier: _isSendingMessageNotifier, 38 | ), 39 | border: OutlineInputBorder( 40 | borderSide: BorderSide.none, 41 | borderRadius: BorderRadius.circular(ChatPageSize.small), 42 | ), 43 | ), 44 | ), 45 | ), 46 | _BottomAttachmentRow(onTextFieldTapped: _onTextFieldTappedNotifier), 47 | const SpaceBox.widthNormal(), 48 | ValueListenableBuilder( 49 | valueListenable: _messageTextNotifier, 50 | builder: (BuildContext context, String value, Widget? child) { 51 | return IconButton( 52 | onPressed: value.isEmpty ? null : _onSendPressed, 53 | icon: const Icon(Icons.send), 54 | ); 55 | }, 56 | ), 57 | const SpaceBox.widthNormal(), 58 | ], 59 | ), 60 | ), 61 | ); 62 | } 63 | } 64 | 65 | mixin _ChatBottomMixin on State { 66 | final ValueNotifier _messageTextNotifier = ValueNotifier(''); 67 | final ValueNotifier _onTextFieldTappedNotifier = 68 | ValueNotifier(false); 69 | final ValueNotifier _isSendingMessageNotifier = 70 | ValueNotifier(false); 71 | 72 | final TextEditingController _textEditingController = TextEditingController(); 73 | 74 | Future _onSendPressed() async { 75 | if (_messageTextNotifier.value.isEmpty) return; 76 | _updateLoading(value: true); 77 | final response = await widget.onSendPressed(_messageTextNotifier.value); 78 | if (!response) return; 79 | _clear(); 80 | } 81 | 82 | @override 83 | void dispose() { 84 | super.dispose(); 85 | _messageTextNotifier.dispose(); 86 | } 87 | 88 | void _updateLoading({required bool value}) { 89 | _isSendingMessageNotifier.value = value; 90 | } 91 | 92 | void _clear() { 93 | _textEditingController.clear(); 94 | _messageTextNotifier.value = ''; 95 | _onTextFieldTappedNotifier.value = false; 96 | _isSendingMessageNotifier.value = false; 97 | } 98 | 99 | void _updateMessageText(String text) { 100 | _messageTextNotifier.value = text; 101 | } 102 | 103 | void _updateOnTappedField({required bool value}) { 104 | _onTextFieldTappedNotifier.value = value; 105 | } 106 | } 107 | 108 | /// Export part of 109 | class _BottomAttachmentRow extends StatelessWidget { 110 | const _BottomAttachmentRow({ 111 | required ValueNotifier onTextFieldTapped, 112 | }) : _onTextFieldTapped = onTextFieldTapped; 113 | 114 | final ValueNotifier _onTextFieldTapped; 115 | static const _duration = Duration(milliseconds: 300); 116 | @override 117 | Widget build(BuildContext context) { 118 | return ValueListenableBuilder( 119 | valueListenable: _onTextFieldTapped, 120 | builder: (context, value, child) { 121 | return AnimatedCrossFade( 122 | firstChild: Row( 123 | children: [ 124 | IconButton( 125 | onPressed: () {}, 126 | icon: const Icon(Icons.mic), 127 | ), 128 | IconButton( 129 | onPressed: () {}, 130 | icon: const Icon(Icons.person), 131 | ), 132 | ], 133 | ), 134 | secondChild: const SizedBox(), 135 | crossFadeState: 136 | value ? CrossFadeState.showSecond : CrossFadeState.showFirst, 137 | duration: _duration, 138 | ); 139 | }, 140 | ); 141 | } 142 | } 143 | 144 | class _SuffixLoading extends StatelessWidget { 145 | const _SuffixLoading({ 146 | required ValueNotifier isSendingMessageNotifier, 147 | }) : _isSendingMessageNotifier = isSendingMessageNotifier; 148 | 149 | final ValueNotifier _isSendingMessageNotifier; 150 | 151 | @override 152 | Widget build(BuildContext context) { 153 | return ValueListenableBuilder( 154 | valueListenable: _isSendingMessageNotifier, 155 | builder: (context, value, child) { 156 | if (!value) return const SizedBox(); 157 | return const SizedBox.square( 158 | dimension: ChatPageSize.large, 159 | child: CircularProgressIndicator(), 160 | ); 161 | }, 162 | ); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/chat_william_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/chat_william/chat_bottom.dart'; 3 | import 'package:twitch_best_practices/speed_code/chat_william/model/chat_user.dart'; 4 | import 'package:twitch_best_practices/speed_code/chat_william/model/list_chat.dart'; 5 | import 'package:twitch_best_practices/speed_code/chat_william/user_appbar.dart'; 6 | 7 | class ChatWilliamView extends StatefulWidget { 8 | const ChatWilliamView({super.key}); 9 | @override 10 | State createState() => _ChatWilliamViewState(); 11 | } 12 | 13 | class _ChatWilliamViewState extends State { 14 | final users = ListChat.users; 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | appBar: UserAppBar(user: ChatUserDummyMixin.dummyLegoUser), 19 | bottomNavigationBar: ChatBottom( 20 | onSendPressed: (value) async { 21 | await Future.delayed(const Duration(milliseconds: 500)); 22 | return true; 23 | }, 24 | ), 25 | body: ListView.separated( 26 | itemCount: users.length, 27 | separatorBuilder: (context, index) { 28 | if (index.isOdd) return const SizedBox(); 29 | return const Center(child: Text('10:56 AM')); 30 | }, 31 | padding: const EdgeInsets.symmetric(horizontal: 16), 32 | itemBuilder: (BuildContext context, int index) { 33 | return _UserChatCard(users[index]); 34 | }, 35 | ), 36 | ); 37 | } 38 | } 39 | 40 | class _UserChatCard extends StatelessWidget { 41 | const _UserChatCard(this.modal); 42 | final ListChat modal; 43 | @override 44 | Widget build(BuildContext context) { 45 | return Align( 46 | alignment: modal.isSenderOtherUser 47 | ? Alignment.centerRight 48 | : Alignment.centerLeft, 49 | child: ConstrainedBox( 50 | constraints: BoxConstraints( 51 | maxWidth: MediaQuery.sizeOf(context).width * 0.8, 52 | ), 53 | child: Card( 54 | shape: RoundedRectangleBorder( 55 | borderRadius: BorderRadius.circular(8), 56 | ), 57 | color: modal.isSenderOtherUser ? Colors.red : Colors.white, 58 | child: Padding( 59 | padding: const EdgeInsets.all(8), 60 | child: Text( 61 | modal.text, 62 | style: Theme.of(context).textTheme.bodyMedium?.copyWith( 63 | color: 64 | modal.isSenderOtherUser ? Colors.white : Colors.black, 65 | ), 66 | ), 67 | ), 68 | ), 69 | ), 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/model/chat_user.dart: -------------------------------------------------------------------------------- 1 | final class ChatUser { 2 | ChatUser({ 3 | required this.fullName, 4 | required this.position, 5 | required this.profileImageUrl, 6 | }); 7 | final String fullName; 8 | final String position; 9 | final String profileImageUrl; 10 | } 11 | 12 | mixin ChatUserDummyMixin { 13 | static ChatUser dummyLegoUser = ChatUser( 14 | fullName: 'William Watson', 15 | position: 'House Agent', 16 | profileImageUrl: 'https://randomuser.me/api/portraits/lego/2.jpg', 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/model/list_chat.dart: -------------------------------------------------------------------------------- 1 | final class ListChat { 2 | ListChat({required this.text, required this.isSenderOtherUser}); 3 | 4 | final String text; 5 | final bool isSenderOtherUser; 6 | 7 | static final List users = List.generate(20, (index) { 8 | ///create random message items 9 | return ListChat( 10 | text: '$index message ', 11 | isSenderOtherUser: index.isOdd, 12 | ); 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/user_appbar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:twitch_best_practices/speed_code/chat_william/model/chat_user.dart'; 4 | 5 | class UserAppBar extends StatelessWidget implements PreferredSizeWidget { 6 | const UserAppBar({ 7 | required this.user, 8 | super.key, 9 | }); 10 | final ChatUser user; 11 | @override 12 | Widget build(BuildContext context) { 13 | return AppBar( 14 | systemOverlayStyle: SystemUiOverlayStyle.dark, 15 | backgroundColor: Colors.transparent, 16 | leading: const Icon(Icons.arrow_back_sharp), 17 | elevation: 0, 18 | centerTitle: false, 19 | leadingWidth: 16, 20 | iconTheme: const IconThemeData(color: Colors.black), 21 | title: Row( 22 | children: [ 23 | CircleAvatar( 24 | backgroundImage: NetworkImage(user.profileImageUrl), 25 | ), 26 | Padding( 27 | padding: const EdgeInsets.only(left: 8), 28 | child: Column( 29 | crossAxisAlignment: CrossAxisAlignment.start, 30 | children: [ 31 | Text( 32 | user.fullName, 33 | style: Theme.of(context).textTheme.titleLarge, 34 | ), 35 | Text( 36 | user.position, 37 | style: Theme.of(context).textTheme.titleSmall, 38 | ), 39 | ], 40 | ), 41 | ), 42 | ], 43 | ), 44 | ); 45 | } 46 | 47 | @override 48 | Size get preferredSize => const Size.fromHeight(kToolbarHeight); 49 | } 50 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/utility/chat_page_size.dart: -------------------------------------------------------------------------------- 1 | final class ChatPageSize { 2 | ChatPageSize._(); 3 | 4 | static const double cardHeight = 60; 5 | 6 | /// value 16 7 | static const double normal = 16; 8 | 9 | /// value 8 10 | static const double small = 8; 11 | 12 | /// value 24 13 | static const double large = 24; 14 | } 15 | -------------------------------------------------------------------------------- /lib/speed_code/chat_william/utility/space_box.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SpaceBox extends SizedBox { 4 | const SpaceBox({super.key}); 5 | 6 | /// value is 16 7 | const SpaceBox.widthNormal({super.key}) : super(width: 16); 8 | } 9 | -------------------------------------------------------------------------------- /lib/speed_code/ice_cream/ice_cream_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | part './widget/ice_app_bar.dart'; 4 | part './widget/ice_card.dart'; 5 | 6 | extension on BuildContext { 7 | // or use kartal 8 | Size get sizeOf => MediaQuery.sizeOf(this); 9 | ThemeData get themeOf => Theme.of(this); 10 | } 11 | 12 | final class IceCreamConstants { 13 | const IceCreamConstants._(); 14 | static const paddingAll = 16.0; 15 | 16 | static const radius = 16.0; 17 | 18 | static const paddingNormal = 8.0; 19 | 20 | static const cardTitle = 'Yogurt Land'; 21 | 22 | static const favoriteColor = Colors.pink; 23 | static const cardImageAsset = 'assets/img/img_yogurtland.png'; 24 | static const cardBottomText = 'To Cart'; 25 | static const stockTitle = 'In Stock'; 26 | static const stockMoney = 8.5; 27 | static const titleHome = 'What would you like to eat?'; 28 | } 29 | 30 | class IceCreamView extends StatefulWidget { 31 | const IceCreamView({super.key}); 32 | @override 33 | State createState() => _IceCreamViewState(); 34 | } 35 | 36 | class _IceCreamViewState extends State { 37 | @override 38 | Widget build(BuildContext context) { 39 | return Scaffold( 40 | appBar: _AppBar(), 41 | body: ListView( 42 | padding: EdgeInsets.zero, 43 | children: [ 44 | Padding( 45 | padding: const EdgeInsets.all(IceCreamConstants.paddingAll), 46 | child: Column( 47 | crossAxisAlignment: CrossAxisAlignment.start, 48 | children: [ 49 | Text( 50 | IceCreamConstants.titleHome, 51 | style: context.themeOf.textTheme.titleMedium, 52 | ), 53 | const Padding( 54 | padding: EdgeInsets.symmetric( 55 | vertical: IceCreamConstants.paddingAll, 56 | ), 57 | child: _SearchField(), 58 | ), 59 | ], 60 | ), 61 | ), 62 | const _PageBody(), 63 | ], 64 | ), 65 | ); 66 | } 67 | } 68 | 69 | class _SearchField extends StatelessWidget { 70 | const _SearchField(); 71 | 72 | @override 73 | Widget build(BuildContext context) { 74 | return Row( 75 | children: [ 76 | Expanded( 77 | child: TextField( 78 | decoration: InputDecoration( 79 | hintText: 'Search', 80 | suffixIcon: const Icon(Icons.search), 81 | fillColor: Colors.grey[200], 82 | filled: true, 83 | border: const OutlineInputBorder( 84 | borderSide: BorderSide.none, 85 | borderRadius: 86 | BorderRadius.all(Radius.circular(IceCreamConstants.radius)), 87 | ), 88 | ), 89 | ), 90 | ), 91 | IconButton( 92 | onPressed: () {}, 93 | icon: const Icon(Icons.filter_list_outlined), 94 | ), 95 | ], 96 | ); 97 | } 98 | } 99 | 100 | class _PageBody extends StatelessWidget { 101 | const _PageBody(); 102 | 103 | @override 104 | Widget build(BuildContext context) { 105 | return SizedBox( 106 | height: context.sizeOf.height * 0.6, 107 | child: ListView.builder( 108 | physics: const ClampingScrollPhysics(), 109 | itemCount: 5, 110 | padding: const EdgeInsets.all(IceCreamConstants.paddingAll), 111 | scrollDirection: Axis.horizontal, 112 | itemBuilder: (context, index) { 113 | return SizedBox( 114 | width: context.sizeOf.width * 0.7, 115 | height: context.sizeOf.height * 0.6, 116 | child: const Padding( 117 | padding: EdgeInsets.only(left: IceCreamConstants.paddingAll), 118 | child: _IceCard(), 119 | ), 120 | ); 121 | }, 122 | ), 123 | ); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /lib/speed_code/ice_cream/widget/ice_app_bar.dart: -------------------------------------------------------------------------------- 1 | part of '../ice_cream_view.dart'; 2 | 3 | class _AppBar extends StatelessWidget implements PreferredSizeWidget { 4 | static const _randomUserUrl = 5 | 'https://randomuser.me/api/portraits/lego/1.jpg'; 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return AppBar( 10 | elevation: 0, 11 | iconTheme: const IconThemeData.fallback().copyWith( 12 | color: Colors.black, 13 | ), 14 | backgroundColor: Colors.transparent, 15 | title: Row( 16 | children: [ 17 | _Avatar(), 18 | _Title(), 19 | ], 20 | ), 21 | actions: [ 22 | _Menu( 23 | onPressed: () {}, 24 | ), 25 | ], 26 | ); 27 | } 28 | 29 | @override 30 | Size get preferredSize => const Size.fromHeight(kToolbarHeight); 31 | } 32 | 33 | class _Menu extends StatelessWidget { 34 | const _Menu({required this.onPressed}); 35 | 36 | final VoidCallback onPressed; 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return IconButton( 41 | onPressed: () {}, 42 | icon: const Icon(Icons.menu_outlined), 43 | ); 44 | } 45 | } 46 | 47 | class _Title extends StatelessWidget { 48 | @override 49 | Widget build(BuildContext context) { 50 | return Text( 51 | 'Hi, Train', 52 | style: Theme.of(context).textTheme.headlineSmall?.copyWith( 53 | fontWeight: FontWeight.w700, 54 | ), 55 | ); 56 | } 57 | } 58 | 59 | class _Avatar extends StatelessWidget { 60 | @override 61 | Widget build(BuildContext context) { 62 | return const CircleAvatar( 63 | backgroundImage: NetworkImage( 64 | _AppBar._randomUserUrl, 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/speed_code/ice_cream/widget/ice_card.dart: -------------------------------------------------------------------------------- 1 | part of '../ice_cream_view.dart'; 2 | 3 | class _IceCard extends StatelessWidget { 4 | const _IceCard(); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Card( 9 | child: Padding( 10 | padding: const EdgeInsets.all(IceCreamConstants.paddingAll), 11 | child: Column( 12 | children: [ 13 | _Header( 14 | title: IceCreamConstants.cardTitle, 15 | onPressed: () {}, 16 | ), 17 | Expanded( 18 | child: _BodyImage(), 19 | ), 20 | const _BottomField( 21 | IceCreamConstants.stockMoney, 22 | IceCreamConstants.stockTitle, 23 | ), 24 | ], 25 | ), 26 | ), 27 | ); 28 | } 29 | } 30 | 31 | class _Header extends StatelessWidget { 32 | const _Header({required this.title, required this.onPressed}); 33 | 34 | final String title; 35 | final VoidCallback onPressed; 36 | @override 37 | Widget build(BuildContext context) { 38 | return Row( 39 | children: [ 40 | Text(title), 41 | const Spacer(), 42 | Card( 43 | child: IconButton.filled( 44 | onPressed: onPressed, 45 | icon: const Icon( 46 | Icons.favorite, 47 | color: IceCreamConstants.favoriteColor, 48 | ), 49 | ), 50 | ), 51 | ], 52 | ); 53 | } 54 | } 55 | 56 | class _BodyImage extends StatelessWidget { 57 | @override 58 | Widget build(BuildContext context) { 59 | return Image.asset(IceCreamConstants.cardImageAsset); 60 | } 61 | } 62 | 63 | class _BottomField extends StatelessWidget { 64 | const _BottomField(this.money, this.storeName); 65 | final double money; 66 | final String storeName; 67 | @override 68 | Widget build(BuildContext context) { 69 | return Row( 70 | children: [ 71 | Column( 72 | children: [ 73 | Text(storeName), 74 | Text.rich( 75 | TextSpan( 76 | children: [ 77 | const TextSpan(text: r'$'), 78 | TextSpan( 79 | text: '$money', 80 | style: Theme.of(context).textTheme.titleLarge?.copyWith( 81 | fontWeight: FontWeight.bold, 82 | ), 83 | ), 84 | ], 85 | ), 86 | ), 87 | ], 88 | ), 89 | const Spacer(), 90 | ElevatedButton( 91 | onPressed: () {}, 92 | style: ElevatedButton.styleFrom(backgroundColor: Colors.red[300]), 93 | child: const Padding( 94 | padding: EdgeInsets.all(IceCreamConstants.paddingNormal), 95 | child: Row( 96 | children: [ 97 | Text(IceCreamConstants.cardBottomText), 98 | Padding( 99 | padding: 100 | EdgeInsets.only(left: IceCreamConstants.paddingNormal), 101 | child: Icon(Icons.shopping_basket_outlined), 102 | ), 103 | ], 104 | ), 105 | ), 106 | ), 107 | ], 108 | ); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /lib/speed_code/lang_app/custom_decoration.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | @immutable 4 | final class CustomDecoration extends BoxDecoration { 5 | CustomDecoration() 6 | : super( 7 | borderRadius: const BorderRadius.all(Radius.circular(16)), 8 | gradient: LinearGradient( 9 | colors: [ 10 | Colors.lightGreenAccent.shade700, 11 | Colors.green.shade900, 12 | ], 13 | stops: const [ 14 | 0.2, 15 | 1.9, 16 | ], 17 | ), 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /lib/speed_code/lang_app/lang_app_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/lang_app/custom_decoration.dart'; 3 | import 'package:twitch_best_practices/speed_code/lang_app/lang_dropdown.dart'; 4 | import 'package:twitch_best_practices/speed_code/lang_app/widget/course_grid.dart'; 5 | 6 | ///======================================================================== 7 | /// KONUSMAK YOK :) 8 | ///===================================================================== 9 | 10 | part './widget/today_challange_card.dart'; 11 | 12 | class LangAppView extends StatefulWidget { 13 | const LangAppView({super.key}); 14 | @override 15 | State createState() => _LangAppViewState(); 16 | } 17 | 18 | class _LangAppViewState extends State { 19 | static const _imageUrl = 'https://randomuser.me/api/portraits/lego/7.jpg'; 20 | @override 21 | Widget build(BuildContext context) { 22 | return Scaffold( 23 | appBar: const _AppBar(), 24 | body: ListView( 25 | padding: const EdgeInsets.symmetric(horizontal: 16), 26 | children: const [ 27 | _Header(), 28 | _WelcomeBackCard(), 29 | _TodaysChallenge(), 30 | _YourCourseCard(), 31 | CourseGrid(), 32 | ], 33 | ), 34 | ); 35 | } 36 | } 37 | 38 | class _YourCourseCard extends StatelessWidget { 39 | const _YourCourseCard(); 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return Padding( 44 | padding: _PagePadding.verticalNormal, 45 | child: Row( 46 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 47 | children: [ 48 | Text( 49 | 'Your Courses', 50 | style: Theme.of(context).textTheme.headlineMedium?.copyWith( 51 | fontWeight: FontWeight.bold, 52 | ), 53 | ), 54 | TextButton( 55 | onPressed: () {}, 56 | child: const Text( 57 | 'View all', 58 | // it need to use theme 59 | style: TextStyle(color: _AppColors.primary), 60 | ), 61 | ), 62 | ], 63 | ), 64 | ); 65 | } 66 | } 67 | 68 | class _WelcomeBackCard extends StatelessWidget { 69 | const _WelcomeBackCard(); 70 | 71 | @override 72 | Widget build(BuildContext context) { 73 | return Padding( 74 | padding: _PagePadding.verticalNormal, 75 | child: Text( 76 | 'Welcome back!', 77 | style: Theme.of(context).textTheme.titleLarge?.copyWith( 78 | fontSize: Theme.of(context).textTheme.headlineMedium?.fontSize, 79 | ), 80 | ), 81 | ); 82 | } 83 | } 84 | 85 | class _Header extends StatelessWidget { 86 | const _Header(); 87 | @override 88 | Widget build(BuildContext context) { 89 | return ListTile( 90 | leading: const CircleAvatar( 91 | backgroundImage: NetworkImage(_LangAppViewState._imageUrl), 92 | ), 93 | title: Text( 94 | 'Alias Jordan', 95 | style: Theme.of(context).textTheme.titleLarge, 96 | ), 97 | subtitle: const Padding( 98 | padding: EdgeInsets.only(top: 8), 99 | child: Row( 100 | children: [ 101 | Icon(Icons.pin_drop_outlined, color: Colors.red), 102 | SizedBox(width: 5), 103 | Text('United kingdom'), 104 | ], 105 | ), 106 | ), 107 | ); 108 | } 109 | } 110 | 111 | class _AppBar extends StatelessWidget implements PreferredSizeWidget { 112 | const _AppBar(); 113 | 114 | @override 115 | Widget build(BuildContext context) { 116 | return AppBar( 117 | elevation: 0, 118 | backgroundColor: Colors.transparent, 119 | iconTheme: const IconThemeData( 120 | color: Colors.black, 121 | ), 122 | leading: const Icon(Icons.menu_outlined), 123 | actions: const [ 124 | LangDropDown(), 125 | ], 126 | ); 127 | } 128 | 129 | @override 130 | Size get preferredSize => const Size.fromHeight(kToolbarHeight); 131 | } 132 | 133 | //MARK: Helpful 134 | 135 | @immutable 136 | final class _PagePadding { 137 | const _PagePadding._(); 138 | static const onlyLeft = EdgeInsets.only(left: 16); 139 | 140 | static const EdgeInsets allNormal = EdgeInsets.all(16); 141 | 142 | static const EdgeInsets horizontalNormal = 143 | EdgeInsets.symmetric(horizontal: 16); 144 | 145 | static const EdgeInsets verticalNormal = EdgeInsets.symmetric(vertical: 16); 146 | static const EdgeInsets verticalLow = EdgeInsets.symmetric(vertical: 8); 147 | } 148 | 149 | @immutable 150 | class _AppColors { 151 | const _AppColors._(); 152 | 153 | static const Color primary = Colors.green; 154 | } 155 | -------------------------------------------------------------------------------- /lib/speed_code/lang_app/lang_dropdown.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class LangDropDown extends StatefulWidget { 5 | const LangDropDown({super.key}); 6 | 7 | @override 8 | State createState() => _LangDropDownState(); 9 | } 10 | 11 | class _LangDropDownState extends State { 12 | final ValueNotifier _itemNotifier = ValueNotifier(null); 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return ValueListenableBuilder( 17 | valueListenable: _itemNotifier, 18 | builder: (context, value, child) { 19 | return DropdownButton( 20 | value: _itemNotifier.value, 21 | items: LangAppItem.samples.map((e) { 22 | return DropdownMenuItem( 23 | value: e, 24 | child: _DropdownCardItem(e), 25 | ); 26 | }).toList(), 27 | onChanged: (value) { 28 | _itemNotifier.value = value; 29 | }, 30 | ); 31 | }, 32 | ); 33 | } 34 | } 35 | 36 | class _DropdownCardItem extends StatelessWidget { 37 | const _DropdownCardItem(this.item); 38 | final LangAppItem item; 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return Card( 43 | child: Row( 44 | children: [ 45 | Icon(item.icon), 46 | const SizedBox( 47 | width: 10, 48 | ), 49 | Text(item.title), 50 | ], 51 | ), 52 | ); 53 | } 54 | } 55 | 56 | final class LangAppItem extends Equatable { 57 | const LangAppItem({required this.icon, required this.title}); 58 | 59 | final IconData icon; 60 | final String title; 61 | 62 | static final List samples = [ 63 | const LangAppItem(icon: Icons.flag, title: 'French'), 64 | const LangAppItem(icon: Icons.face, title: 'Turkish'), 65 | ]; 66 | 67 | @override 68 | List get props => [icon, title]; 69 | } 70 | -------------------------------------------------------------------------------- /lib/speed_code/lang_app/widget/course_grid.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CourseGrid extends StatelessWidget { 4 | const CourseGrid({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return GridView.count( 9 | physics: const ClampingScrollPhysics(), 10 | shrinkWrap: true, 11 | crossAxisCount: 2, 12 | children: _GridItem.examples.map(_GridCard.new).toList(), 13 | ); 14 | } 15 | } 16 | 17 | class _GridCard extends StatelessWidget { 18 | const _GridCard(this.item); 19 | final _GridItem item; 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return Card( 24 | shape: RoundedRectangleBorder( 25 | borderRadius: BorderRadius.circular(16), 26 | ), 27 | color: item.color.withOpacity(0.1), 28 | elevation: 0, 29 | child: Padding( 30 | padding: const EdgeInsets.all(16), 31 | child: Center( 32 | child: Column( 33 | mainAxisAlignment: MainAxisAlignment.center, 34 | crossAxisAlignment: CrossAxisAlignment.start, 35 | children: [ 36 | const Spacer(flex: 2), 37 | Icon(item.icon, color: item.color), 38 | const Spacer(), 39 | Text(item.title, style: Theme.of(context).textTheme.titleLarge), 40 | const Spacer(), 41 | Text(item.subTitle), 42 | const Spacer(), 43 | LinearProgressIndicator( 44 | value: item.progress, 45 | color: item.color, 46 | ), 47 | const Spacer(flex: 2), 48 | ], 49 | ), 50 | ), 51 | ), 52 | ); 53 | } 54 | } 55 | 56 | class _GridItem { 57 | _GridItem({ 58 | required this.color, 59 | required this.icon, 60 | required this.title, 61 | required this.subTitle, 62 | required this.progress, 63 | }); 64 | 65 | final Color color; 66 | final IconData icon; 67 | final String title; 68 | final String subTitle; 69 | final double progress; 70 | 71 | static final List<_GridItem> examples = [ 72 | _GridItem( 73 | color: Colors.purple, 74 | icon: Icons.book_outlined, 75 | title: 'Reading', 76 | subTitle: 'Your Progress 41%', 77 | progress: 0.41, 78 | ), 79 | _GridItem( 80 | color: Colors.blue, 81 | icon: Icons.outbound_outlined, 82 | title: 'Reading', 83 | subTitle: 'Your Progress 2%', 84 | progress: 0.2, 85 | ), 86 | _GridItem( 87 | color: Colors.green, 88 | icon: Icons.outlined_flag, 89 | title: 'Reading', 90 | subTitle: 'Your Progress 50%', 91 | progress: 0.5, 92 | ), 93 | _GridItem( 94 | color: Colors.orange, 95 | icon: Icons.outlet_outlined, 96 | title: 'Reading', 97 | subTitle: 'Your Progress 60%', 98 | progress: 0.6, 99 | ), 100 | ]; 101 | } 102 | -------------------------------------------------------------------------------- /lib/speed_code/lang_app/widget/today_challange_card.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: unused_element 2 | 3 | part of '../lang_app_view.dart'; 4 | 5 | final class TodayItemCard { 6 | const TodayItemCard({ 7 | required this.title, 8 | required this.description, 9 | required this.hint, 10 | }); 11 | 12 | final String title; 13 | final String description; 14 | final String hint; 15 | 16 | static const example = TodayItemCard( 17 | title: "Today's Challenge", 18 | description: 'Take this lesson to earn new milestone', 19 | hint: 'Tap to Start', 20 | ); 21 | } 22 | 23 | class _TodaysChallenge extends StatelessWidget { 24 | const _TodaysChallenge({super.key, this.item = TodayItemCard.example}); 25 | 26 | final TodayItemCard item; 27 | @override 28 | Widget build(BuildContext context) { 29 | return DecoratedBox( 30 | decoration: CustomDecoration(), 31 | child: Padding( 32 | padding: _PagePadding.allNormal, 33 | child: Column( 34 | crossAxisAlignment: CrossAxisAlignment.start, 35 | children: [ 36 | Opacity( 37 | opacity: 0.5, 38 | child: Chip( 39 | label: Text( 40 | item.hint, 41 | style: Theme.of(context).textTheme.bodySmall?.copyWith( 42 | color: Theme.of(context).colorScheme.surface, 43 | fontWeight: FontWeight.bold, 44 | ), 45 | ), 46 | ), 47 | ), 48 | Padding( 49 | padding: _PagePadding.verticalLow, 50 | child: Text( 51 | item.title, 52 | style: Theme.of(context).textTheme.headlineSmall?.copyWith( 53 | color: Theme.of(context).colorScheme.surface, 54 | fontWeight: FontWeight.bold, 55 | ), 56 | ), 57 | ), 58 | Row( 59 | children: [ 60 | const Icon(Icons.money_outlined, color: Colors.yellow), 61 | Expanded( 62 | child: Padding( 63 | padding: _PagePadding.onlyLeft, 64 | child: Text( 65 | item.description, 66 | style: Theme.of(context).textTheme.titleMedium?.copyWith( 67 | color: Theme.of(context).colorScheme.surface, 68 | ), 69 | ), 70 | ), 71 | ), 72 | ], 73 | ), 74 | Padding( 75 | padding: _PagePadding.verticalLow, 76 | child: ElevatedButton( 77 | style: ElevatedButton.styleFrom( 78 | foregroundColor: Colors.green, 79 | shape: const RoundedRectangleBorder( 80 | borderRadius: BorderRadius.all(Radius.circular(8)), 81 | ), 82 | backgroundColor: Theme.of(context).colorScheme.surface, 83 | ), 84 | onPressed: () {}, 85 | child: const Text('Tap to Start'), 86 | ), 87 | ), 88 | ], 89 | ), 90 | ), 91 | ); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /lib/speed_code/rent/rent_model.dart: -------------------------------------------------------------------------------- 1 | final class RentModel { 2 | final String title; 3 | final String subTitle; 4 | final double price; 5 | final String imageUrl; 6 | 7 | RentModel( 8 | {required this.title, 9 | required this.subTitle, 10 | required this.price, 11 | required this.imageUrl}); 12 | } 13 | -------------------------------------------------------------------------------- /lib/speed_code/rent/rent_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/rent/rent_model.dart'; 3 | import 'package:twitch_best_practices/speed_code/rent/rent_view_mixin.dart'; 4 | import 'package:twitch_best_practices/speed_code/rent/view/project_padding.dart'; 5 | import 'package:twitch_best_practices/speed_code/rent/view/rent_card.dart'; 6 | import 'package:twitch_best_practices/speed_code/rent/widget/outline_style.dart'; 7 | 8 | part './view/rent_view_items.dart'; 9 | 10 | class RentView extends StatefulWidget { 11 | const RentView({Key? key}) : super(key: key); 12 | @override 13 | State createState() => _RentViewState(); 14 | } 15 | 16 | class _RentViewState extends State with RentViewMixin { 17 | @override 18 | Widget build(BuildContext context) { 19 | return DefaultTabController( 20 | length: StatusTabItems.values.length, 21 | child: Scaffold( 22 | appBar: const _AppBar(), 23 | bottomNavigationBar: const _BottomBar(), 24 | body: ListView.separated( 25 | padding: ProjectPadding.padding20, 26 | separatorBuilder: (context, index) => const _CustomDivider(), 27 | itemCount: rentItems.length, 28 | itemBuilder: (BuildContext context, int index) { 29 | return SizedBox( 30 | height: MediaQuery.sizeOf(context).height * 0.1, 31 | child: RentCard(model: rentItems[index]), 32 | ); 33 | }, 34 | ), 35 | ), 36 | ); 37 | } 38 | } 39 | 40 | class _CustomDivider extends StatelessWidget { 41 | const _CustomDivider(); 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | return Padding( 46 | padding: EdgeInsets.symmetric(vertical: ProjectPadding.padding20.bottom), 47 | child: const Divider( 48 | height: 2, 49 | thickness: 2, 50 | ), 51 | ); 52 | } 53 | } 54 | 55 | class _BottomBar extends StatelessWidget { 56 | const _BottomBar(); 57 | 58 | @override 59 | Widget build(BuildContext context) { 60 | return const SafeArea( 61 | child: TabBar( 62 | indicatorColor: Colors.transparent, 63 | labelColor: Colors.black, 64 | unselectedLabelColor: Colors.black26, 65 | tabs: [ 66 | Tab(icon: Icon(Icons.home)), 67 | Tab(icon: Icon(Icons.filter_alt)), 68 | Tab(icon: Icon(Icons.favorite)), 69 | Tab(icon: Icon(Icons.shopping_cart)), 70 | ]), 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/speed_code/rent/rent_view_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/rent/rent_model.dart'; 3 | import 'package:twitch_best_practices/speed_code/rent/rent_view.dart'; 4 | 5 | enum StatusTabItems { home, filter, favroite, shop } 6 | 7 | mixin RentViewMixin on State { 8 | late final List _rentItemsDummy; 9 | 10 | List get rentItems => _rentItemsDummy; 11 | @override 12 | void initState() { 13 | // TODO: implement initState 14 | super.initState(); 15 | _rentItemsDummy = List.generate(20, (index) { 16 | return RentModel( 17 | title: 'Title $index', 18 | subTitle: 'SubTitle $index', 19 | price: 1000, 20 | imageUrl: 'https://picsum.photos/200/300'); 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/speed_code/rent/view/project_padding.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | mixin ProjectPadding { 4 | /// value is 20 5 | static EdgeInsets padding20 = const EdgeInsets.all(20); 6 | 7 | /// value is 12 8 | static EdgeInsets padding12 = const EdgeInsets.all(12); 9 | 10 | // value is 8 11 | static EdgeInsets padding8 = const EdgeInsets.all(8); 12 | } 13 | -------------------------------------------------------------------------------- /lib/speed_code/rent/view/project_radius.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | mixin ProjectRadius { 4 | // BorderRadius.circular(20) 5 | static BorderRadius borderRadius20 = BorderRadius.circular(20); 6 | } 7 | -------------------------------------------------------------------------------- /lib/speed_code/rent/view/rent_card.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/rent/rent_model.dart'; 3 | import 'package:twitch_best_practices/speed_code/rent/view/project_padding.dart'; 4 | import 'package:twitch_best_practices/speed_code/rent/view/project_radius.dart'; 5 | 6 | class RentCard extends StatelessWidget { 7 | const RentCard({super.key, required this.model}); 8 | final RentModel model; 9 | @override 10 | Widget build(BuildContext context) { 11 | return Row( 12 | children: [ 13 | Expanded( 14 | child: ClipRRect( 15 | borderRadius: ProjectRadius.borderRadius20, 16 | child: Image.network( 17 | model.imageUrl, 18 | fit: BoxFit.cover, 19 | ), 20 | )), 21 | Expanded( 22 | child: Padding( 23 | padding: EdgeInsets.only(left: ProjectPadding.padding8.left), 24 | child: Column( 25 | crossAxisAlignment: CrossAxisAlignment.start, 26 | children: [ 27 | Text( 28 | model.title, 29 | style: Theme.of(context).textTheme.titleMedium, 30 | ), 31 | const Spacer(), 32 | Text(model.subTitle), 33 | const Spacer(), 34 | Row( 35 | children: [ 36 | const Icon(Icons.attach_money), 37 | Text(model.price.toString()), 38 | const Spacer(), 39 | const Text('Random') 40 | ], 41 | ), 42 | ], 43 | ), 44 | )) 45 | ], 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/speed_code/rent/view/rent_view_items.dart: -------------------------------------------------------------------------------- 1 | part of '../rent_view.dart'; 2 | 3 | class _AppBar extends StatelessWidget implements PreferredSizeWidget { 4 | const _AppBar(); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return AppBar( 9 | foregroundColor: Colors.black, 10 | backgroundColor: Colors.transparent, 11 | elevation: 0, 12 | centerTitle: false, 13 | automaticallyImplyLeading: false, 14 | titleSpacing: 0, 15 | title: Row( 16 | children: [ 17 | Padding( 18 | padding: const EdgeInsets.symmetric(horizontal: 2), 19 | child: ElevatedButton( 20 | style: OutlineStyle.circleStyle, 21 | onPressed: () {}, 22 | child: const Icon( 23 | Icons.chevron_left, 24 | color: Colors.black, 25 | )), 26 | ), 27 | const Expanded(child: const _SearchField()), 28 | ], 29 | ), 30 | actions: [IconButton(onPressed: () {}, icon: const Icon(Icons.menu))], 31 | ); 32 | } 33 | 34 | @override 35 | Size get preferredSize => const Size.fromHeight(kToolbarHeight); 36 | } 37 | 38 | class _SearchField extends StatelessWidget { 39 | const _SearchField(); 40 | static const title = 'Search'; 41 | @override 42 | Widget build(BuildContext context) { 43 | return TextField( 44 | onTap: () { 45 | showSearch(context: context, delegate: SearchDelegateCustom()); 46 | }, 47 | decoration: const InputDecoration( 48 | hintText: title, 49 | contentPadding: EdgeInsets.zero, 50 | enabledBorder: OutlineInputBorder( 51 | borderRadius: BorderRadius.all(Radius.circular(20)), 52 | borderSide: BorderSide(color: Colors.black12, width: 1), 53 | ), 54 | prefixIcon: Icon(Icons.search), 55 | ), 56 | ); 57 | } 58 | } 59 | 60 | class SearchDelegateCustom extends SearchDelegate { 61 | @override 62 | List? buildActions(BuildContext context) { 63 | return [ 64 | IconButton( 65 | onPressed: () { 66 | this.close(context, false); 67 | }, 68 | icon: Icon(Icons.close)) 69 | ]; 70 | } 71 | 72 | @override 73 | Widget? buildLeading(BuildContext context) { 74 | return null; 75 | } 76 | 77 | @override 78 | Widget buildResults(BuildContext context) { 79 | return ListView.builder( 80 | itemCount: 10, 81 | itemBuilder: (BuildContext context, int index) { 82 | return Text('dummy'); 83 | }, 84 | ); 85 | } 86 | 87 | @override 88 | Widget buildSuggestions(BuildContext context) { 89 | return ListView.builder( 90 | itemCount: 10, 91 | itemBuilder: (BuildContext context, int index) { 92 | return Text('dummy'); 93 | }, 94 | ); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /lib/speed_code/rent/widget/outline_style.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | mixin OutlineStyle { 4 | static final circleStyle = OutlinedButton.styleFrom( 5 | shape: const CircleBorder(), 6 | backgroundColor: Colors.transparent, 7 | elevation: 0, 8 | side: const BorderSide(color: Colors.black, width: 2), 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /lib/speed_code/reset_password/reset_password_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:twitch_best_practices/speed_code/reset_password/reset_password_validator.dart'; 3 | import 'package:twitch_best_practices/speed_code/reset_password/reset_password_view.dart'; 4 | 5 | mixin ResetPasswordMixin on State { 6 | final TextEditingController _controller = TextEditingController(); 7 | 8 | TextEditingController get controller => _controller; 9 | 10 | @override 11 | void dispose() { 12 | super.dispose(); 13 | _controller.dispose(); 14 | } 15 | 16 | void onSubmitPressed() { 17 | if (!ResetPasswordValidator(_controller.text).control()) return; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/speed_code/reset_password/reset_password_validator.dart: -------------------------------------------------------------------------------- 1 | final class ResetPasswordValidator { 2 | final String? text; 3 | static const String _emptyError = 'This field cannot be empty'; 4 | ResetPasswordValidator(this.text); 5 | 6 | String? controlAndMessage() { 7 | if (control()) { 8 | return null; 9 | } 10 | 11 | return _emptyError; 12 | } 13 | 14 | bool control() { 15 | if (text == null || text!.isEmpty) return false; 16 | if (text!.length < 8) return false; 17 | 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/speed_code/reset_password/reset_password_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:twitch_best_practices/speed_code/reset_password/reset_password_mixin.dart'; 4 | import 'package:twitch_best_practices/speed_code/reset_password/reset_password_validator.dart'; 5 | import 'package:twitch_best_practices/speed_code/reset_password/visible_eye.dart'; 6 | 7 | part './reset_password_widgets.dart'; 8 | 9 | class ResetPasswordView extends StatefulWidget { 10 | const ResetPasswordView({Key? key}) : super(key: key); 11 | @override 12 | State createState() => _ResetPasswordViewState(); 13 | } 14 | 15 | class _ResetPasswordViewState extends State 16 | with ResetPasswordMixin { 17 | @override 18 | Widget build(BuildContext context) { 19 | return Scaffold( 20 | appBar: AppBar( 21 | systemOverlayStyle: SystemUiOverlayStyle.dark, 22 | backgroundColor: Colors.transparent, 23 | elevation: 0, 24 | iconTheme: const IconThemeData(color: Colors.black), 25 | leading: const Icon(Icons.chevron_left_outlined), 26 | ), 27 | bottomNavigationBar: Padding( 28 | padding: 29 | EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom) + 30 | const EdgeInsets.symmetric(horizontal: 16), 31 | child: SafeArea( 32 | child: _SubmitButton( 33 | onSubmitPressed, 34 | ), 35 | ), 36 | ), 37 | body: Padding( 38 | padding: const EdgeInsets.all(16.0), 39 | child: Column( 40 | crossAxisAlignment: CrossAxisAlignment.start, 41 | children: [ 42 | Text( 43 | _ResetPasswordResources.title, 44 | style: Theme.of(context) 45 | .textTheme 46 | .titleLarge 47 | ?.copyWith(fontWeight: FontWeight.bold), 48 | ), 49 | const Padding( 50 | padding: EdgeInsets.symmetric(vertical: 16), 51 | child: Text(_ResetPasswordResources.subTitle), 52 | ), 53 | _NewPassword(controller), 54 | ], 55 | ), 56 | ), 57 | ); 58 | } 59 | } 60 | 61 | class _SubmitButton extends StatelessWidget { 62 | const _SubmitButton(this.onPressed); 63 | final VoidCallback onPressed; 64 | // it will add in generic layer 65 | static const double _buttonHeight = 56; 66 | @override 67 | Widget build(BuildContext context) { 68 | return SizedBox( 69 | height: _buttonHeight, 70 | child: ElevatedButton( 71 | style: ElevatedButton.styleFrom(backgroundColor: Colors.purple[700]), 72 | onPressed: () {}, 73 | child: const Center(child: Text(_ResetPasswordResources.submit)), 74 | ), 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/speed_code/reset_password/reset_password_widgets.dart: -------------------------------------------------------------------------------- 1 | part of './reset_password_view.dart'; 2 | 3 | final class _ResetPasswordResources { 4 | _ResetPasswordResources._(); 5 | static const title = 'Reset your password'; 6 | static const subTitle = 'Lets reset your password'; 7 | static const newPassword = 'New password'; 8 | static const submit = 'Submit'; 9 | } 10 | 11 | class _NewPassword extends StatefulWidget { 12 | const _NewPassword(this.controller); 13 | final TextEditingController controller; 14 | 15 | @override 16 | State<_NewPassword> createState() => _NewPasswordState(); 17 | } 18 | 19 | class _NewPasswordState extends State<_NewPassword> { 20 | bool _isSecured = false; 21 | @override 22 | Widget build(BuildContext context) { 23 | return Form( 24 | autovalidateMode: AutovalidateMode.onUserInteraction, 25 | child: TextFormField( 26 | validator: (value) { 27 | return ResetPasswordValidator(value).controlAndMessage(); 28 | }, 29 | obscureText: !_isSecured, 30 | decoration: InputDecoration( 31 | labelText: _ResetPasswordResources.newPassword, 32 | labelStyle: Theme.of(context).textTheme.bodyLarge?.copyWith( 33 | color: Colors.black, 34 | ), 35 | contentPadding: const EdgeInsets.only(left: 16), 36 | border: _inputBorder(), 37 | enabledBorder: _inputBorder(), 38 | focusedBorder: _inputBorder(), 39 | suffixIcon: VisibleEyeButton( 40 | onChanged: (value) { 41 | setState(() { 42 | _isSecured = value; 43 | }); 44 | }, 45 | )), 46 | ), 47 | ); 48 | } 49 | 50 | OutlineInputBorder _inputBorder() { 51 | return const OutlineInputBorder( 52 | borderRadius: BorderRadius.all( 53 | Radius.circular(12), 54 | ), 55 | borderSide: BorderSide(color: Colors.black12, width: 1), 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/speed_code/reset_password/visible_eye.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class VisibleEyeButton extends StatefulWidget { 4 | const VisibleEyeButton( 5 | {super.key, this.isVisible = false, required this.onChanged}); 6 | final bool isVisible; 7 | final ValueChanged onChanged; 8 | @override 9 | State createState() => _VisibleEyeButtonState(); 10 | } 11 | 12 | class _VisibleEyeButtonState extends State { 13 | bool _isVisible = false; 14 | @override 15 | void initState() { 16 | super.initState(); 17 | _isVisible = widget.isVisible; 18 | } 19 | 20 | void _changeVisible() { 21 | setState(() { 22 | _isVisible = !_isVisible; 23 | }); 24 | widget.onChanged(_isVisible); 25 | } 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return IconButton( 30 | onPressed: _changeVisible, 31 | icon: Icon(_isVisible ? Icons.visibility : Icons.visibility_off_outlined, 32 | color: Colors.grey[700]), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "twitch_best_practices") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.twitch_best_practices") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | 90 | # Generated plugin build rules, which manage building the plugins and adding 91 | # them to the application. 92 | include(flutter/generated_plugins.cmake) 93 | 94 | 95 | # === Installation === 96 | # By default, "installing" just makes a relocatable bundle in the build 97 | # directory. 98 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 99 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 100 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 101 | endif() 102 | 103 | # Start with a clean build bundle directory every time. 104 | install(CODE " 105 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 106 | " COMPONENT Runtime) 107 | 108 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 109 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 110 | 111 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 112 | COMPONENT Runtime) 113 | 114 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 115 | COMPONENT Runtime) 116 | 117 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 118 | COMPONENT Runtime) 119 | 120 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 121 | install(FILES "${bundled_library}" 122 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 123 | COMPONENT Runtime) 124 | endforeach(bundled_library) 125 | 126 | # Fully re-copy the assets directory on each build to avoid having stale files 127 | # from a previous install. 128 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 129 | install(CODE " 130 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 131 | " COMPONENT Runtime) 132 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 133 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 134 | 135 | # Install the AOT library on non-Debug builds only. 136 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 137 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 138 | COMPONENT Runtime) 139 | endif() 140 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "twitch_best_practices"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "twitch_best_practices"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.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 device_info_plus 9 | import package_info_plus 10 | import path_provider_foundation 11 | import share_plus 12 | import url_launcher_macos 13 | 14 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 15 | DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) 16 | FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) 17 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 18 | SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) 19 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 20 | } 21 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 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 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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 = twitch_best_practices 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.twitchBestPractices 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: twitch_best_practices 2 | description: A new Flutter project. 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: "none" # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: ">=3.0.5 <4.0.0" 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | cupertino_icons: ^1.0.2 37 | equatable: ^2.0.5 38 | kartal: ^3.4.4 39 | 40 | # Network 41 | dio: ^5.3.2 42 | # State Management 43 | stacked: ^3.4.1 44 | 45 | dev_dependencies: 46 | flutter_test: 47 | sdk: flutter 48 | 49 | # The "flutter_lints" package below contains a set of recommended lints to 50 | # encourage good coding practices. The lint set provided by the package is 51 | # activated in the `analysis_options.yaml` file located at the root of your 52 | # package. See that file for information about deactivating specific lint 53 | # rules and activating additional ones. 54 | very_good_analysis: ^5.1.0 55 | 56 | # For information on the generic Dart part of this file, see the 57 | # following page: https://dart.dev/tools/pub/pubspec 58 | 59 | # The following section is specific to Flutter packages. 60 | flutter: 61 | # The following line ensures that the Material Icons font is 62 | # included with your application, so that you can use the icons in 63 | # the material Icons class. 64 | uses-material-design: true 65 | 66 | assets: 67 | - assets/img/ 68 | 69 | # An image asset can refer to one or more resolution-specific "variants", see 70 | # https://flutter.dev/assets-and-images/#resolution-aware 71 | 72 | # For details regarding adding assets from package dependencies, see 73 | # https://flutter.dev/assets-and-images/#from-packages 74 | 75 | # To add custom fonts to your application, add a fonts section here, 76 | # in this "flutter" section. Each entry in this list should have a 77 | # "family" key with the font family name, and a "fonts" key with a 78 | # list giving the asset and other descriptors for the font. For 79 | # example: 80 | # fonts: 81 | # - family: Schyler 82 | # fonts: 83 | # - asset: fonts/Schyler-Regular.ttf 84 | # - asset: fonts/Schyler-Italic.ttf 85 | # style: italic 86 | # - family: Trajan Pro 87 | # fonts: 88 | # - asset: fonts/TrajanPro.ttf 89 | # - asset: fonts/TrajanPro_Bold.ttf 90 | # weight: 700 91 | # 92 | # For details regarding fonts from package dependencies, 93 | # see https://flutter.dev/custom-fonts/#from-packages 94 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:twitch_best_practices/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/theme.png -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | twitch_best_practices 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "twitch_best_practices", 3 | "short_name": "twitch_best_practices", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(twitch_best_practices LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "twitch_best_practices") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Fully re-copy the assets directory on each build to avoid having stale files 91 | # from a previous install. 92 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 93 | install(CODE " 94 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 95 | " COMPONENT Runtime) 96 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 97 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 98 | 99 | # Install the AOT library on non-Debug builds only. 100 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 101 | CONFIGURATIONS Profile;Release 102 | COMPONENT Runtime) 103 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /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 | SharePlusWindowsPluginCApiRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); 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 | share_plus 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 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "twitch_best_practices" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "twitch_best_practices" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "twitch_best_practices.exe" "\0" 98 | VALUE "ProductName", "twitch_best_practices" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(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 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /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.Create(L"twitch_best_practices", 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/VB10/twitch_best_practices/bca79f6a66b2ef02bf5b90c99d8bcff3c1d56e62/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 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | --------------------------------------------------------------------------------