diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..308a9a8 --- /dev/null +++ b/.metadata @@ -0,0 +1,33 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: eb6d86ee27deecba4a83536aa20f366a6044895c + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + - platform: android + create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + - platform: ios + create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/README.md b/README.md new file mode 100644 index 0000000..d3f8d29 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# flutter_quiz_app + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..c772518 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,9 @@ + +include: package:flutter_lints/flutter.yaml + +analyzer: + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + errors: + invalid_annotation_target: ignore \ No newline at end of file diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..5e69879 --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,71 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.flutter_quiz_app" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..4b8e214 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9fd63af --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/example/flutter_quiz_app/MainActivity.kt b/android/app/src/main/kotlin/com/example/flutter_quiz_app/MainActivity.kt new file mode 100644 index 0000000..885eab2 --- /dev/null +++ b/android/app/src/main/kotlin/com/example/flutter_quiz_app/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.flutter_quiz_app + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..4b8e214 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..83ae220 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.6.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..94adc3a --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..cb24abd --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..44e62bc --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..9625e10 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..537888e --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,481 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterQuizApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterQuizApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterQuizApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..c87d15a --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..28c6bf0 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..f091b6b Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cde121 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..d0ef06e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..dcdc230 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..c8f9ed8 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..75b2d16 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..c4df70d Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..6a84f41 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..d0e1f58 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +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. \ No newline at end of file diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist new file mode 100644 index 0000000..1d8a841 --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Flutter Quiz App + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + flutter_quiz_app + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/lib/common/data/quiz_repository.dart b/lib/common/data/quiz_repository.dart new file mode 100644 index 0000000..1aef434 --- /dev/null +++ b/lib/common/data/quiz_repository.dart @@ -0,0 +1,35 @@ +import 'package:flutter_quiz_app/common/utils/enums.dart'; + +import 'package:flutter_quiz_app/common/services/quiz_service.dart'; +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; +import 'package:flutter_quiz_app/features/settings/models/quiz_category.dart'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +final quizRepositoryProvider = Provider((ref) { + QuizService quizService = ref.watch(quizServiceProvider); + return QuizRepository(quizService); +}); + +final quizQuestionsProvider = FutureProvider.autoDispose?>( + (ref) => ref.watch(quizRepositoryProvider).getQuestions()); + +final quizCategoriesProvider = FutureProvider.autoDispose?>( + (ref) => ref.watch(quizRepositoryProvider).getCategories()); + +class QuizRepository { + QuizRepository(this.quizService); + final QuizService quizService; + + Future?> getQuestions() async { + return await quizService.getQuestions( + numQuestions: 5, + categoryId: 9, + difficulty: Difficulty.any, + ); + } + + Future?> getCategories() async { + return await quizService.getCategories(); + } +} diff --git a/lib/common/navigation/router.dart b/lib/common/navigation/router.dart new file mode 100644 index 0000000..bb3b9b0 --- /dev/null +++ b/lib/common/navigation/router.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_quiz_app/common/navigation/routes.dart'; +import 'package:flutter_quiz_app/features/quiz/ui/quiz_page.dart'; +import 'package:flutter_quiz_app/features/settings/ui/settings_page.dart'; +import 'package:go_router/go_router.dart'; + +final router = GoRouter( + routes: [ + GoRoute( + path: '/', + name: AppRoute.home.name, + builder: (context, state) => const QuizPage()), + GoRoute( + path: '/settings', + name: AppRoute.settings.name, + builder: (context, state) => SettingsPage()), + ], + errorBuilder: (context, state) => Scaffold( + body: Center( + child: Text(state.error.toString()), + ), + ), +); diff --git a/lib/common/navigation/routes.dart b/lib/common/navigation/routes.dart new file mode 100644 index 0000000..e057a56 --- /dev/null +++ b/lib/common/navigation/routes.dart @@ -0,0 +1,4 @@ +enum AppRoute { + home, + settings, +} diff --git a/lib/common/services/quiz_service.dart b/lib/common/services/quiz_service.dart new file mode 100644 index 0000000..acf9fad --- /dev/null +++ b/lib/common/services/quiz_service.dart @@ -0,0 +1,84 @@ +import 'dart:convert'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter_quiz_app/common/utils/enums.dart'; +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; +import 'package:flutter_quiz_app/features/settings/controllers/settings_controller.dart'; +import 'package:flutter_quiz_app/features/settings/controllers/settings_state.dart'; +import 'package:flutter_quiz_app/features/settings/models/quiz_category.dart'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:http/http.dart' as http; + +final quizServiceProvider = Provider((ref) { + final service = QuizService(ref: ref); + return service; +}); + +class QuizService { + QuizService({ + required Ref ref, + }) : settingsState = ref.watch(settingsControllerProvider); + + final SettingsState settingsState; + + Future?> getQuestions({ + required int numQuestions, + required int categoryId, + required Difficulty difficulty, + }) async { + try { + final queryParameters = { + 'type': 'multiple', + 'amount': settingsState.numQuestions.toString(), + 'category': settingsState.category.id.toString(), + }; + + if (settingsState.difficulty != Difficulty.any) { + queryParameters.addAll( + { + 'difficulty': describeEnum(settingsState.difficulty), + }, + ); + } + + var url = Uri.https('opentdb.com', '/api.php', queryParameters); + + var response = await http.get(url); + + if (response.statusCode == 200) { + var decodedResponse = + jsonDecode(utf8.decode(response.bodyBytes)) as Map; + final results = + List>.from(decodedResponse['results'] ?? []); + if (results.isNotEmpty) { + return results.map((e) => QuizQuestion.fromMap(e)).toList(); + } + } + } catch (err) { + debugPrint(err.toString()); + } + return []; + } + + Future?> getCategories() async { + try { + var url = Uri.https('opentdb.com', '/api_category.php'); + var response = await http.get(url); + + if (response.statusCode == 200) { + var decodedResponse = + jsonDecode(utf8.decode(response.bodyBytes)) as Map; + + final results = List>.from( + decodedResponse['trivia_categories'] ?? []); + if (results.isNotEmpty) { + return results.map((e) => QuizCategory.fromJson(e)).toList(); + } + } + } catch (err) { + debugPrint(err.toString()); + } + return []; + } +} diff --git a/lib/common/ui/display_error.dart b/lib/common/ui/display_error.dart new file mode 100644 index 0000000..ca1c54f --- /dev/null +++ b/lib/common/ui/display_error.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_quiz_app/common/data/quiz_repository.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +class DisplayError extends ConsumerWidget { + const DisplayError({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'Error', + style: Theme.of(context).textTheme.titleMedium, + textAlign: TextAlign.center, + ), + ), + TextButton( + style: TextButton.styleFrom( + textStyle: const TextStyle(fontSize: 20), + ), + onPressed: () async { + ref.refresh(quizQuestionsProvider); + }, + child: const Text('Try again'), + ), + ], + ), + ); + } +} diff --git a/lib/common/ui/the_quiz_button.dart b/lib/common/ui/the_quiz_button.dart new file mode 100644 index 0000000..5149558 --- /dev/null +++ b/lib/common/ui/the_quiz_button.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; + +class TheQuizButton extends StatelessWidget { + const TheQuizButton({ + required this.title, + required this.onPressed, + Key? key, + }) : super(key: key); + + final String title; + final VoidCallback onPressed; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(30.0), + child: SizedBox( + height: 50.0, + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.amberAccent[700], + textStyle: const TextStyle(fontSize: 18), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(25))), + ), + onPressed: onPressed, + child: Text(title), + ), + ), + ); + } +} diff --git a/lib/common/utils/enums.dart b/lib/common/utils/enums.dart new file mode 100644 index 0000000..9324567 --- /dev/null +++ b/lib/common/utils/enums.dart @@ -0,0 +1,13 @@ +enum Difficulty { + any, + easy, + medium, + hard, +} + +enum QuizStatus { + initial, + correct, + incorrect, + complete, +} diff --git a/lib/features/quiz/controllers/quiz_controller.dart b/lib/features/quiz/controllers/quiz_controller.dart new file mode 100644 index 0000000..d4c15d1 --- /dev/null +++ b/lib/features/quiz/controllers/quiz_controller.dart @@ -0,0 +1,45 @@ +import 'package:flutter_quiz_app/common/utils/enums.dart'; + +import 'package:flutter_quiz_app/features/quiz/controllers/quiz_state.dart'; +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +final quizControllerProvider = + StateNotifierProvider.autoDispose((ref) { + return QuizController(); +}); + +class QuizController extends StateNotifier { + QuizController() : super(QuizState.initial()); + + void answer(QuizQuestion currentQuestion, String answer) { + if (state.answered) return; + + if (currentQuestion.correctAnswer == answer) { + state = state.copyWith( + selectedAnswer: answer, + correct: List.from(state.correct)..add(currentQuestion), + status: QuizStatus.correct, + ); + } else { + state = state.copyWith( + selectedAnswer: answer, + incorrect: List.from(state.incorrect)..add(currentQuestion), + status: QuizStatus.incorrect, + ); + } + } + + void next(List questions, int currentIndex) { + state = state.copyWith( + selectedAnswer: '', + status: currentIndex + 1 < questions.length + ? QuizStatus.initial + : QuizStatus.complete, + ); + } + + void reset() { + state = QuizState.initial(); + } +} diff --git a/lib/features/quiz/controllers/quiz_state.dart b/lib/features/quiz/controllers/quiz_state.dart new file mode 100644 index 0000000..8c9c226 --- /dev/null +++ b/lib/features/quiz/controllers/quiz_state.dart @@ -0,0 +1,45 @@ +import 'package:flutter_quiz_app/common/utils/enums.dart'; +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; + +import 'package:freezed_annotation/freezed_annotation.dart'; + +@immutable +class QuizState { + final String selectedAnswer; + final List correct; + final List incorrect; + final QuizStatus status; + + bool get answered => + status == QuizStatus.incorrect || status == QuizStatus.correct; + + const QuizState({ + required this.selectedAnswer, + required this.correct, + required this.incorrect, + required this.status, + }); + + factory QuizState.initial() { + return const QuizState( + selectedAnswer: '', + correct: [], + incorrect: [], + status: QuizStatus.initial, + ); + } + + QuizState copyWith({ + String? selectedAnswer, + List? correct, + List? incorrect, + QuizStatus? status, + }) { + return QuizState( + selectedAnswer: selectedAnswer ?? this.selectedAnswer, + correct: correct ?? this.correct, + incorrect: incorrect ?? this.incorrect, + status: status ?? this.status, + ); + } +} diff --git a/lib/features/quiz/models/quiz_question.dart b/lib/features/quiz/models/quiz_question.dart new file mode 100644 index 0000000..1efbb3b --- /dev/null +++ b/lib/features/quiz/models/quiz_question.dart @@ -0,0 +1,30 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'quiz_question.freezed.dart'; + +@Freezed() +class QuizQuestion with _$QuizQuestion { + const factory QuizQuestion({ + required String? category, + required String? difficulty, + required String? type, + required String? question, + @JsonKey(name: 'correct_answer') required String? correctAnswer, + @JsonKey(name: 'incorrect_answers') required List? incorrectAnswer, + required List? answers, + }) = _QuizQuestion; + + factory QuizQuestion.fromMap(Map map) { + return QuizQuestion( + category: map['category'] ?? '', + difficulty: map['difficulty'] ?? '', + question: map['question'] ?? '', + type: map['type'] ?? '', + correctAnswer: map['correct_answer'] ?? '', + incorrectAnswer: map['incorrect_answers'].cast() ?? [], + answers: List.from(map['incorrect_answers'].cast() ?? []) + ..add(map['correct_answer'] ?? '') + ..shuffle(), + ); + } +} diff --git a/lib/features/quiz/models/quiz_question.freezed.dart b/lib/features/quiz/models/quiz_question.freezed.dart new file mode 100644 index 0000000..3d30bc9 --- /dev/null +++ b/lib/features/quiz/models/quiz_question.freezed.dart @@ -0,0 +1,294 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'quiz_question.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$QuizQuestion { + String? get category => throw _privateConstructorUsedError; + String? get difficulty => throw _privateConstructorUsedError; + String? get type => throw _privateConstructorUsedError; + String? get question => throw _privateConstructorUsedError; + @JsonKey(name: 'correct_answer') + String? get correctAnswer => throw _privateConstructorUsedError; + @JsonKey(name: 'incorrect_answers') + List? get incorrectAnswer => throw _privateConstructorUsedError; + List? get answers => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $QuizQuestionCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $QuizQuestionCopyWith<$Res> { + factory $QuizQuestionCopyWith( + QuizQuestion value, $Res Function(QuizQuestion) then) = + _$QuizQuestionCopyWithImpl<$Res, QuizQuestion>; + @useResult + $Res call( + {String? category, + String? difficulty, + String? type, + String? question, + @JsonKey(name: 'correct_answer') String? correctAnswer, + @JsonKey(name: 'incorrect_answers') List? incorrectAnswer, + List? answers}); +} + +/// @nodoc +class _$QuizQuestionCopyWithImpl<$Res, $Val extends QuizQuestion> + implements $QuizQuestionCopyWith<$Res> { + _$QuizQuestionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? category = freezed, + Object? difficulty = freezed, + Object? type = freezed, + Object? question = freezed, + Object? correctAnswer = freezed, + Object? incorrectAnswer = freezed, + Object? answers = freezed, + }) { + return _then(_value.copyWith( + category: freezed == category + ? _value.category + : category // ignore: cast_nullable_to_non_nullable + as String?, + difficulty: freezed == difficulty + ? _value.difficulty + : difficulty // ignore: cast_nullable_to_non_nullable + as String?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + question: freezed == question + ? _value.question + : question // ignore: cast_nullable_to_non_nullable + as String?, + correctAnswer: freezed == correctAnswer + ? _value.correctAnswer + : correctAnswer // ignore: cast_nullable_to_non_nullable + as String?, + incorrectAnswer: freezed == incorrectAnswer + ? _value.incorrectAnswer + : incorrectAnswer // ignore: cast_nullable_to_non_nullable + as List?, + answers: freezed == answers + ? _value.answers + : answers // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_QuizQuestionCopyWith<$Res> + implements $QuizQuestionCopyWith<$Res> { + factory _$$_QuizQuestionCopyWith( + _$_QuizQuestion value, $Res Function(_$_QuizQuestion) then) = + __$$_QuizQuestionCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String? category, + String? difficulty, + String? type, + String? question, + @JsonKey(name: 'correct_answer') String? correctAnswer, + @JsonKey(name: 'incorrect_answers') List? incorrectAnswer, + List? answers}); +} + +/// @nodoc +class __$$_QuizQuestionCopyWithImpl<$Res> + extends _$QuizQuestionCopyWithImpl<$Res, _$_QuizQuestion> + implements _$$_QuizQuestionCopyWith<$Res> { + __$$_QuizQuestionCopyWithImpl( + _$_QuizQuestion _value, $Res Function(_$_QuizQuestion) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? category = freezed, + Object? difficulty = freezed, + Object? type = freezed, + Object? question = freezed, + Object? correctAnswer = freezed, + Object? incorrectAnswer = freezed, + Object? answers = freezed, + }) { + return _then(_$_QuizQuestion( + category: freezed == category + ? _value.category + : category // ignore: cast_nullable_to_non_nullable + as String?, + difficulty: freezed == difficulty + ? _value.difficulty + : difficulty // ignore: cast_nullable_to_non_nullable + as String?, + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, + question: freezed == question + ? _value.question + : question // ignore: cast_nullable_to_non_nullable + as String?, + correctAnswer: freezed == correctAnswer + ? _value.correctAnswer + : correctAnswer // ignore: cast_nullable_to_non_nullable + as String?, + incorrectAnswer: freezed == incorrectAnswer + ? _value._incorrectAnswer + : incorrectAnswer // ignore: cast_nullable_to_non_nullable + as List?, + answers: freezed == answers + ? _value._answers + : answers // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc + +class _$_QuizQuestion implements _QuizQuestion { + const _$_QuizQuestion( + {required this.category, + required this.difficulty, + required this.type, + required this.question, + @JsonKey(name: 'correct_answer') + required this.correctAnswer, + @JsonKey(name: 'incorrect_answers') + required final List? incorrectAnswer, + required final List? answers}) + : _incorrectAnswer = incorrectAnswer, + _answers = answers; + + @override + final String? category; + @override + final String? difficulty; + @override + final String? type; + @override + final String? question; + @override + @JsonKey(name: 'correct_answer') + final String? correctAnswer; + final List? _incorrectAnswer; + @override + @JsonKey(name: 'incorrect_answers') + List? get incorrectAnswer { + final value = _incorrectAnswer; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _answers; + @override + List? get answers { + final value = _answers; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'QuizQuestion(category: $category, difficulty: $difficulty, type: $type, question: $question, correctAnswer: $correctAnswer, incorrectAnswer: $incorrectAnswer, answers: $answers)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_QuizQuestion && + (identical(other.category, category) || + other.category == category) && + (identical(other.difficulty, difficulty) || + other.difficulty == difficulty) && + (identical(other.type, type) || other.type == type) && + (identical(other.question, question) || + other.question == question) && + (identical(other.correctAnswer, correctAnswer) || + other.correctAnswer == correctAnswer) && + const DeepCollectionEquality() + .equals(other._incorrectAnswer, _incorrectAnswer) && + const DeepCollectionEquality().equals(other._answers, _answers)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + category, + difficulty, + type, + question, + correctAnswer, + const DeepCollectionEquality().hash(_incorrectAnswer), + const DeepCollectionEquality().hash(_answers)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_QuizQuestionCopyWith<_$_QuizQuestion> get copyWith => + __$$_QuizQuestionCopyWithImpl<_$_QuizQuestion>(this, _$identity); +} + +abstract class _QuizQuestion implements QuizQuestion { + const factory _QuizQuestion( + {required final String? category, + required final String? difficulty, + required final String? type, + required final String? question, + @JsonKey(name: 'correct_answer') + required final String? correctAnswer, + @JsonKey(name: 'incorrect_answers') + required final List? incorrectAnswer, + required final List? answers}) = _$_QuizQuestion; + + @override + String? get category; + @override + String? get difficulty; + @override + String? get type; + @override + String? get question; + @override + @JsonKey(name: 'correct_answer') + String? get correctAnswer; + @override + @JsonKey(name: 'incorrect_answers') + List? get incorrectAnswer; + @override + List? get answers; + @override + @JsonKey(ignore: true) + _$$_QuizQuestionCopyWith<_$_QuizQuestion> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/quiz/ui/quiz_answer.dart b/lib/features/quiz/ui/quiz_answer.dart new file mode 100644 index 0000000..8b43685 --- /dev/null +++ b/lib/features/quiz/ui/quiz_answer.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; + +import 'package:flutter_quiz_app/features/quiz/controllers/quiz_controller.dart'; + +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:html_unescape/html_unescape.dart'; + +class QuizAnswer extends ConsumerWidget { + const QuizAnswer({ + required this.answer, + required this.isSelected, + required this.isCorrect, + required this.isDisplayingAnswer, + required this.question, + Key? key, + }) : super(key: key); + + final String answer; + final bool isSelected; + final bool isCorrect; + final bool isDisplayingAnswer; + final QuizQuestion question; + + @override + Widget build(BuildContext context, WidgetRef ref) { + return GestureDetector( + onTap: () => + ref.read(quizControllerProvider.notifier).answer(question, answer), + child: Container( + margin: const EdgeInsets.symmetric( + vertical: 12.0, + horizontal: 20.0, + ), + padding: const EdgeInsets.symmetric( + vertical: 12.0, + horizontal: 20.0, + ), + width: double.infinity, + decoration: BoxDecoration( + color: Colors.white, + boxShadow: const [ + BoxShadow( + color: Colors.black26, + offset: Offset(0, 2), + blurRadius: 4.0, + ), + ], + border: Border.all( + color: isDisplayingAnswer + ? isCorrect + ? Colors.green + : isSelected + ? Colors.red + : Colors.white + : Colors.white, + width: 4.0, + ), + borderRadius: BorderRadius.circular(100.0), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Text( + HtmlUnescape().convert(answer), + style: TextStyle( + color: Colors.black, + fontSize: 16.0, + fontWeight: isDisplayingAnswer && isCorrect + ? FontWeight.bold + : FontWeight.w400, + ), + ), + ), + if (isDisplayingAnswer) + isCorrect + ? const Icon(Icons.check, color: Colors.green) + : isSelected + ? const Icon( + Icons.close, + color: Colors.red, + ) + : const Icon( + Icons.close, + color: Colors.red, + ) + else + const Icon( + Icons.question_mark, + color: Colors.red, + ) + ], + ), + ), + ); + } +} diff --git a/lib/features/quiz/ui/quiz_page.dart b/lib/features/quiz/ui/quiz_page.dart new file mode 100644 index 0000000..3d81b0a --- /dev/null +++ b/lib/features/quiz/ui/quiz_page.dart @@ -0,0 +1,80 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_quiz_app/common/navigation/routes.dart'; +import 'package:flutter_quiz_app/common/utils/enums.dart'; +import 'package:flutter_quiz_app/features/quiz/controllers/quiz_controller.dart'; +import 'package:flutter_quiz_app/common/data/quiz_repository.dart'; +import 'package:flutter_quiz_app/common/ui/display_error.dart'; +import 'package:flutter_quiz_app/common/ui/the_quiz_button.dart'; +import 'package:flutter_quiz_app/features/quiz/ui/quiz_questions.dart'; +import 'package:flutter_quiz_app/features/quiz/ui/quiz_result.dart'; +import 'package:go_router/go_router.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +class QuizPage extends HookConsumerWidget { + const QuizPage({ + super.key, + }); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final questions = ref.watch(quizQuestionsProvider); + final pageController = usePageController(); + return Scaffold( + appBar: AppBar( + // backgroundColor: Colors.transparent, + title: const Text( + 'The Quiz App', + ), + + leading: IconButton( + onPressed: () { + context.goNamed( + AppRoute.settings.name, + ); + }, + icon: const Icon(Icons.settings), + ), + ), + body: questions.when( + data: (data) { + final quizState = ref.watch(quizControllerProvider); + return quizState.status == QuizStatus.complete + ? QuizResult(state: quizState, questions: data!) + : QuizQuestions( + pageController: pageController, + state: quizState, + questions: data!, + ); + }, + error: (e, st) => const DisplayError(), + loading: () => const Center(child: CircularProgressIndicator()), + ), + bottomSheet: questions.maybeWhen( + data: (data) { + final quizState = ref.watch(quizControllerProvider); + if (!quizState.answered) return const SizedBox.shrink(); + if (!pageController.hasClients) return const SizedBox.shrink(); + + return TheQuizButton( + title: pageController.page!.toInt() + 1 < data!.length + ? 'Next Question' + : 'See Results', + onPressed: () { + ref + .read(quizControllerProvider.notifier) + .next(data, pageController.page!.toInt()); + if (pageController.page!.toInt() + 1 < data.length) { + pageController.nextPage( + duration: const Duration(milliseconds: 250), + curve: Curves.linear, + ); + } + }, + ); + }, + orElse: () => const SizedBox.shrink(), + ), + ); + } +} diff --git a/lib/features/quiz/ui/quiz_questions.dart b/lib/features/quiz/ui/quiz_questions.dart new file mode 100644 index 0000000..82e38c2 --- /dev/null +++ b/lib/features/quiz/ui/quiz_questions.dart @@ -0,0 +1,76 @@ +import 'package:flutter/material.dart'; + +import 'package:flutter_quiz_app/features/quiz/controllers/quiz_state.dart'; +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; +import 'package:flutter_quiz_app/features/quiz/ui/quiz_answer.dart'; + +import 'package:html_unescape/html_unescape.dart'; + +class QuizQuestions extends StatelessWidget { + const QuizQuestions({ + required this.pageController, + required this.state, + required this.questions, + Key? key, + }) : super(key: key); + + final PageController pageController; + final QuizState state; + final List questions; + + @override + Widget build(BuildContext context) { + return PageView.builder( + controller: pageController, + itemCount: questions.length, + itemBuilder: (context, index) { + final question = questions[index]; + final answers = question.answers!; + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Question ${index + 1} of ${questions.length}', + style: const TextStyle( + color: Colors.white, + fontSize: 24.0, + fontWeight: FontWeight.bold, + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(20.0, 16.0, 20.0, 12.0), + child: Text( + HtmlUnescape().convert(question.question!), + style: const TextStyle( + color: Colors.white, + fontSize: 28.0, + fontWeight: FontWeight.w500, + ), + ), + ), + Divider( + color: Colors.grey[200], + height: 32.0, + thickness: 2.0, + indent: 20.0, + endIndent: 20.0, + ), + Column( + children: answers + .map( + (e) => QuizAnswer( + answer: e, + isSelected: e == state.selectedAnswer, + isCorrect: e == question.correctAnswer, + isDisplayingAnswer: state.answered, + question: question, + ), + ) + .toList(), + ), + ], + ); + }, + ); + } +} diff --git a/lib/features/quiz/ui/quiz_result.dart b/lib/features/quiz/ui/quiz_result.dart new file mode 100644 index 0000000..8ac9cd8 --- /dev/null +++ b/lib/features/quiz/ui/quiz_result.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_quiz_app/features/quiz/models/quiz_question.dart'; + +import 'package:flutter_quiz_app/features/quiz/controllers/quiz_controller.dart'; +import 'package:flutter_quiz_app/features/quiz/controllers/quiz_state.dart'; +import 'package:flutter_quiz_app/common/data/quiz_repository.dart'; +import 'package:flutter_quiz_app/common/ui/the_quiz_button.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +class QuizResult extends ConsumerWidget { + const QuizResult({ + required this.state, + required this.questions, + Key? key, + }) : super(key: key); + + final QuizState state; + final List questions; + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + '${state.correct.length} / ${questions.length}', + style: const TextStyle( + color: Colors.white, + fontSize: 60.0, + fontWeight: FontWeight.w600, + ), + textAlign: TextAlign.center, + ), + const Text( + 'CORRECT', + style: TextStyle( + color: Colors.white, + fontSize: 48.0, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 40.0), + TheQuizButton( + title: 'New Quiz', + onPressed: () { + ref.refresh(quizRepositoryProvider); + ref.read(quizControllerProvider.notifier).reset(); + }, + ), + ], + ); + } +} diff --git a/lib/features/settings/controllers/settings_controller.dart b/lib/features/settings/controllers/settings_controller.dart new file mode 100644 index 0000000..e5fc73a --- /dev/null +++ b/lib/features/settings/controllers/settings_controller.dart @@ -0,0 +1,23 @@ +import 'package:flutter_quiz_app/features/settings/controllers/settings_state.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +final settingsControllerProvider = + StateNotifierProvider((ref) { + return SettingsController(); +}); + +class SettingsController extends StateNotifier { + SettingsController() : super(SettingsState.initial()); + + void update(SettingsState settingsState) { + state = state.copyWith( + numQuestions: settingsState.numQuestions, + difficulty: settingsState.difficulty, + category: settingsState.category, + ); + } + + void reset() { + state = SettingsState.initial(); + } +} diff --git a/lib/features/settings/controllers/settings_state.dart b/lib/features/settings/controllers/settings_state.dart new file mode 100644 index 0000000..d5ee07b --- /dev/null +++ b/lib/features/settings/controllers/settings_state.dart @@ -0,0 +1,38 @@ +import 'package:flutter_quiz_app/common/utils/enums.dart'; +import 'package:flutter_quiz_app/features/settings/models/quiz_category.dart'; + +import 'package:freezed_annotation/freezed_annotation.dart'; + +@immutable +class SettingsState { + final int numQuestions; + final QuizCategory category; + final Difficulty difficulty; + + const SettingsState({ + required this.numQuestions, + required this.category, + required this.difficulty, + }); + + factory SettingsState.initial() { + return const SettingsState( + numQuestions: 5, + category: QuizCategory( + id: 9, name: 'General Knowledge'), // Random().nextInt(24) + 9, + difficulty: Difficulty.any, + ); + } + + SettingsState copyWith({ + int? numQuestions, + QuizCategory? category, + Difficulty? difficulty, + }) { + return SettingsState( + numQuestions: numQuestions ?? this.numQuestions, + category: category ?? this.category, + difficulty: difficulty ?? this.difficulty, + ); + } +} diff --git a/lib/features/settings/models/quiz_category.dart b/lib/features/settings/models/quiz_category.dart new file mode 100644 index 0000000..c1b5494 --- /dev/null +++ b/lib/features/settings/models/quiz_category.dart @@ -0,0 +1,15 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'quiz_category.freezed.dart'; +part 'quiz_category.g.dart'; + +@Freezed() +class QuizCategory with _$QuizCategory { + const factory QuizCategory({ + required int id, + required String name, + }) = _QuizCategory; + + factory QuizCategory.fromJson(Map json) => + _$QuizCategoryFromJson(json); +} diff --git a/lib/features/settings/models/quiz_category.freezed.dart b/lib/features/settings/models/quiz_category.freezed.dart new file mode 100644 index 0000000..d979351 --- /dev/null +++ b/lib/features/settings/models/quiz_category.freezed.dart @@ -0,0 +1,168 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'quiz_category.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +QuizCategory _$QuizCategoryFromJson(Map json) { + return _QuizCategory.fromJson(json); +} + +/// @nodoc +mixin _$QuizCategory { + int get id => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $QuizCategoryCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $QuizCategoryCopyWith<$Res> { + factory $QuizCategoryCopyWith( + QuizCategory value, $Res Function(QuizCategory) then) = + _$QuizCategoryCopyWithImpl<$Res, QuizCategory>; + @useResult + $Res call({int id, String name}); +} + +/// @nodoc +class _$QuizCategoryCopyWithImpl<$Res, $Val extends QuizCategory> + implements $QuizCategoryCopyWith<$Res> { + _$QuizCategoryCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_QuizCategoryCopyWith<$Res> + implements $QuizCategoryCopyWith<$Res> { + factory _$$_QuizCategoryCopyWith( + _$_QuizCategory value, $Res Function(_$_QuizCategory) then) = + __$$_QuizCategoryCopyWithImpl<$Res>; + @override + @useResult + $Res call({int id, String name}); +} + +/// @nodoc +class __$$_QuizCategoryCopyWithImpl<$Res> + extends _$QuizCategoryCopyWithImpl<$Res, _$_QuizCategory> + implements _$$_QuizCategoryCopyWith<$Res> { + __$$_QuizCategoryCopyWithImpl( + _$_QuizCategory _value, $Res Function(_$_QuizCategory) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + }) { + return _then(_$_QuizCategory( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_QuizCategory implements _QuizCategory { + const _$_QuizCategory({required this.id, required this.name}); + + factory _$_QuizCategory.fromJson(Map json) => + _$$_QuizCategoryFromJson(json); + + @override + final int id; + @override + final String name; + + @override + String toString() { + return 'QuizCategory(id: $id, name: $name)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_QuizCategory && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, id, name); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_QuizCategoryCopyWith<_$_QuizCategory> get copyWith => + __$$_QuizCategoryCopyWithImpl<_$_QuizCategory>(this, _$identity); + + @override + Map toJson() { + return _$$_QuizCategoryToJson( + this, + ); + } +} + +abstract class _QuizCategory implements QuizCategory { + const factory _QuizCategory( + {required final int id, required final String name}) = _$_QuizCategory; + + factory _QuizCategory.fromJson(Map json) = + _$_QuizCategory.fromJson; + + @override + int get id; + @override + String get name; + @override + @JsonKey(ignore: true) + _$$_QuizCategoryCopyWith<_$_QuizCategory> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/settings/models/quiz_category.g.dart b/lib/features/settings/models/quiz_category.g.dart new file mode 100644 index 0000000..fc7f01e --- /dev/null +++ b/lib/features/settings/models/quiz_category.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'quiz_category.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_QuizCategory _$$_QuizCategoryFromJson(Map json) => + _$_QuizCategory( + id: json['id'] as int, + name: json['name'] as String, + ); + +Map _$$_QuizCategoryToJson(_$_QuizCategory instance) => + { + 'id': instance.id, + 'name': instance.name, + }; diff --git a/lib/features/settings/ui/settings_page.dart b/lib/features/settings/ui/settings_page.dart new file mode 100644 index 0000000..a0260ce --- /dev/null +++ b/lib/features/settings/ui/settings_page.dart @@ -0,0 +1,166 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_quiz_app/common/navigation/routes.dart'; +import 'package:flutter_quiz_app/common/ui/the_quiz_button.dart'; +import 'package:flutter_quiz_app/common/utils/enums.dart'; +import 'package:flutter_quiz_app/common/data/quiz_repository.dart'; +import 'package:flutter_quiz_app/common/ui/display_error.dart'; +import 'package:flutter_quiz_app/features/settings/controllers/settings_controller.dart'; +import 'package:flutter_quiz_app/features/settings/models/quiz_category.dart'; +import 'package:go_router/go_router.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +class SettingsPage extends HookConsumerWidget { + SettingsPage({ + super.key, + }); + + final formGlobalKey = GlobalKey(); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final categories = ref.watch(quizCategoriesProvider); + + QuizCategory category; + Difficulty difficulty; + + return Scaffold( + appBar: AppBar( + elevation: 0, + backgroundColor: Colors.transparent, + title: Container( + margin: const EdgeInsets.only(left: 8), + child: const Text( + 'The Quiz App', + ), + ), + ), + body: categories.when( + data: (data) { + final settingsState = ref.watch(settingsControllerProvider); + category = settingsState.category; + final numQuestionsController = useTextEditingController( + text: settingsState.numQuestions.toString()); + difficulty = settingsState.difficulty; + + return SingleChildScrollView( + child: Form( + key: formGlobalKey, + child: Container( + padding: EdgeInsets.only( + top: 15, + left: 15, + right: 15, + bottom: MediaQuery.of(context).viewInsets.bottom + 15), + width: double.infinity, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 20, + ), + DropdownButtonFormField( + onChanged: (value) { + category = value!; + }, + value: category, + decoration: const InputDecoration( + labelText: 'Category', + ), + isExpanded: true, + items: [ + for (var category in data!) + DropdownMenuItem( + value: category, + child: Text( + category.name, + style: const TextStyle(fontSize: 18), + ), + ), + ], + ), + const SizedBox( + height: 20, + ), + DropdownButtonFormField( + style: const TextStyle(fontSize: 18), + onChanged: (value) { + difficulty = value!; + }, + value: difficulty, + decoration: const InputDecoration( + labelText: 'Difficulty', + ), + items: [ + for (var difficulty in Difficulty.values) + DropdownMenuItem( + value: difficulty, + child: Text(difficulty.name), + ), + ], + ), + const SizedBox( + height: 20, + ), + TextFormField( + style: const TextStyle(fontSize: 18), + controller: numQuestionsController, + keyboardType: TextInputType.number, + validator: (value) { + const validationError = 'Enter a valid number'; + if (value == null || + value.isEmpty || + int.tryParse(value) == null) { + return validationError; + } + + return null; + }, + autocorrect: false, + decoration: const InputDecoration( + hintText: 'Enter a number', + labelText: 'Number of questions', + ), + textInputAction: TextInputAction.next, + ), + const SizedBox( + height: 20, + ), + TheQuizButton( + title: 'Save', + onPressed: () async { + final currentState = formGlobalKey.currentState; + if (currentState == null) { + return; + } + if (currentState.validate()) { + final updatedSettings = settingsState.copyWith( + category: category, + difficulty: difficulty, + numQuestions: + int.parse(numQuestionsController.text), + ); + + ref + .read(settingsControllerProvider.notifier) + .update(updatedSettings); + + context.goNamed( + AppRoute.home.name, + ); + } + } //,, + ) + ], + ), + ), + ), + ); + }, + error: (e, st) => const DisplayError(), + loading: () => const Center(child: CircularProgressIndicator()), + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..1e6f822 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_quiz_app/the_quiz_app.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + + runApp( + const ProviderScope( + child: TheQuizApp(), + ), + ); +} diff --git a/lib/the_quiz_app.dart b/lib/the_quiz_app.dart new file mode 100644 index 0000000..3ad1115 --- /dev/null +++ b/lib/the_quiz_app.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_quiz_app/common/navigation/router.dart'; + +class TheQuizApp extends StatelessWidget { + const TheQuizApp({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialApp.router( + routerConfig: router, + title: 'The Quiz App', + theme: ThemeData.dark().copyWith( + // scaffoldBackgroundColor: constants.appBackground, + ), + // home: const QuizPage(), + debugShowCheckedModeBanner: false, + ); + } +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..60e5067 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,537 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "50.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.9.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.2" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "7.2.7" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.4.2" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "4.3.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.4" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_hooks: + dependency: "direct main" + description: + name: flutter_hooks + url: "https://pub.dartlang.org" + source: hosted + version: "0.18.5+1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + flutter_riverpod: + dependency: "direct main" + description: + name: flutter_riverpod + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + go_router: + dependency: "direct main" + description: + name: go_router + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.5" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + hooks_riverpod: + dependency: "direct main" + description: + name: hooks_riverpod + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + html_unescape: + dependency: "direct main" + description: + name: html_unescape + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + http: + dependency: "direct main" + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.5" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.4" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.7.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + url: "https://pub.dartlang.org" + source: hosted + version: "6.5.4" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + riverpod: + dependency: transitive + description: + name: riverpod + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.6" + source_helper: + dependency: transitive + description: + name: source_helper + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.3" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + state_notifier: + dependency: transitive + description: + name: state_notifier + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.2+1" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.12" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.18.2 <3.0.0" + flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..e7ce57a --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,65 @@ +name: flutter_quiz_app +description: A new Flutter project. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +version: 1.0.0+1 + +environment: + sdk: '>=2.18.2 <3.0.0' + +dependencies: + flutter: + sdk: flutter + flutter_riverpod: ^2.0.2 + freezed_annotation: ^2.1.0 + hooks_riverpod: ^2.0.2 + + cupertino_icons: ^1.0.2 + http: ^0.13.5 + json_annotation: ^4.7.0 + flutter_hooks: ^0.18.5+1 + html_unescape: ^2.0.0 + go_router: ^5.1.5 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + build_runner: ^2.3.2 + freezed: ^2.2.1 + json_serializable: ^6.5.4 + +flutter: + + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..ca566c7 --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,29 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_quiz_app/the_quiz_app.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const TheQuizApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +}