commit cabf2025cdc756c0345b3cead0906b7b902c3952 Author: Lucas Saburido <240425@MacBook-Pro-13.local> Date: Wed May 13 16:26:45 2026 +0100 first commit diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5d9ecf5 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +SUPABASE_URL=https://YOUR_PROJECT_ID.supabase.co +SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e151ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,51 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +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-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# 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 + +# Signing / release secrets +android/key.properties +android/*.jks +android/*.keystore +ios/Runner/GoogleService-Info.plist diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..79dc3aa --- /dev/null +++ b/.metadata @@ -0,0 +1,45 @@ +# 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 and should not be manually edited. + +version: + revision: "00b0c91f06209d9e4a41f71b7a512d6eb3b9c694" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + - platform: android + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + - platform: ios + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + - platform: linux + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + - platform: macos + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + - platform: web + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + - platform: windows + create_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + base_revision: 00b0c91f06209d9e4a41f71b7a512d6eb3b9c694 + + # 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/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000..5782487 --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,87 @@ +# RIOTZ Deployment Guide (Android + iOS) + +This guide prepares RIOTZ for production releases with Flutter + Supabase. + +## 1) Environment setup + +Use `--dart-define` in release builds: + +```bash +--dart-define=SUPABASE_URL=https://YOUR_PROJECT_ID.supabase.co +--dart-define=SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY +--dart-define=ADMIN_USER_IDS=uuid-1,uuid-2 +``` + +Optional: use `--dart-define-from-file=env.production.json`. + +Example `env.production.json`: + +```json +{ + "SUPABASE_URL": "https://YOUR_PROJECT_ID.supabase.co", + "SUPABASE_ANON_KEY": "YOUR_SUPABASE_ANON_KEY", + "ADMIN_USER_IDS": "uuid-1,uuid-2" +} +``` + +## 2) Supabase production checklist + +- Apply migration in `supabase/migrations/20260506170000_riotz_production_schema.sql`. +- Confirm buckets exist: `avatars`, `post-images`, `tracks`. +- Confirm RLS policies are enabled and tested. +- Add at least one admin user in `admin_users`. + +## 3) Android release + +### 3.1 Create upload keystore + +```bash +keytool -genkey -v -keystore ~/riotz-upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload +``` + +### 3.2 Configure `android/key.properties` + +Copy `android/key.properties.example` to `android/key.properties` and fill values. + +### 3.3 Build artifacts + +```bash +flutter pub get +flutter build appbundle --release --dart-define-from-file=env.production.json +flutter build apk --release --dart-define-from-file=env.production.json +``` + +Output: +- AAB: `build/app/outputs/bundle/release/app-release.aab` +- APK: `build/app/outputs/flutter-apk/app-release.apk` + +## 4) iOS release + +### 4.1 Xcode signing + +- Open `ios/Runner.xcworkspace` +- Target `Runner` -> Signing & Capabilities +- Set Team, Bundle Identifier (`com.riotz.app`), and provisioning profiles + +### 4.2 Build and archive + +```bash +flutter pub get +flutter build ipa --release --dart-define-from-file=env.production.json +``` + +Or archive from Xcode and upload via Organizer / Transporter. + +## 5) Pre-release quality gate + +- `flutter analyze` +- `flutter test` +- Smoke test auth/profile/feed/music/discover/admin on physical devices +- Verify upload, playback, logout/login, banned-user behavior +- Verify crash-free startup with production Supabase keys + +## 6) Security reminders + +- Never commit `android/key.properties`, keystores, or private keys +- Do not expose service-role Supabase keys in Flutter app +- Rotate anon keys only through Supabase config if leaked diff --git a/README.md b/README.md new file mode 100644 index 0000000..63a2749 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# RIOTZ + +Underground social/music app starter built with Flutter, Supabase, Riverpod, and `go_router`. + +## Run + +```bash +flutter pub get +flutter run \ + --dart-define=SUPABASE_URL=https://YOUR_PROJECT_ID.supabase.co \ + --dart-define=SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY +``` + +## Architecture + +```text +lib/ + app/ + app.dart # MaterialApp wiring and global shell + core/ + config/supabase_config.dart # Supabase bootstrap + router/ # Route constants + go_router config + supabase/supabase_providers.dart # Base Supabase Riverpod providers + theme/ # RIOTZ dark palette and theme + features/ + auth/presentation/providers/ # Auth state providers + splash/presentation/pages/ # Entry page + home/presentation/pages/ # Main starter page + shared/widgets/riotz_shell.dart # Reusable branded page container +``` + +## Notes + +- `SupabaseConfig` reads credentials from `--dart-define` values. +- Use `.env.example` as a template for local values. +- Use `env.production.json.example` as a template for release `--dart-define-from-file`. +- This scaffold is clean-architecture ready and feature-module friendly. +- For production Android/iOS release setup, see `DEPLOYMENT.md`. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..be3943c --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..af3fe9d --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,68 @@ +import java.util.Properties + +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.riotz.app" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + applicationId = "com.riotz.app" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + val keystoreProperties = Properties() + val keystorePropertiesFile = rootProject.file("key.properties") + if (keystorePropertiesFile.exists()) { + keystoreProperties.load(keystorePropertiesFile.inputStream()) + } + + signingConfigs { + create("release") { + if (keystorePropertiesFile.exists()) { + keyAlias = keystoreProperties["keyAlias"] as String? + keyPassword = keystoreProperties["keyPassword"] as String? + storeFile = file(keystoreProperties["storeFile"] as String) + storePassword = keystoreProperties["storePassword"] as String? + } + } + } + + buildTypes { + release { + signingConfig = if (keystorePropertiesFile.exists()) { + signingConfigs.getByName("release") + } else { + signingConfigs.getByName("debug") + } + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro", + ) + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..bc5b4aa --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,10 @@ +# Keep Flutter and plugin registrant classes +-keep class io.flutter.** { *; } +-keep class io.flutter.plugins.** { *; } + +# Keep Supabase model reflection paths (safe default) +-keep class com.supabase.** { *; } +-dontwarn com.supabase.** + +# Keep Kotlin metadata +-keep class kotlin.Metadata { *; } diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8685e2a --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/com/riotz/app/MainActivity.java b/android/app/src/main/java/com/riotz/app/MainActivity.java new file mode 100644 index 0000000..7734b61 --- /dev/null +++ b/android/app/src/main/java/com/riotz/app/MainActivity.java @@ -0,0 +1,6 @@ +package com.riotz.app; + +import io.flutter.embedding.android.FlutterActivity; + +public class MainActivity extends 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..399f698 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..dbee657 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..fbee1d8 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e4ef43f --- /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-8.14-all.zip diff --git a/android/key.properties.example b/android/key.properties.example new file mode 100644 index 0000000..b8a053e --- /dev/null +++ b/android/key.properties.example @@ -0,0 +1,4 @@ +storeFile=/absolute/path/to/riotz-upload-keystore.jks +storePassword=CHANGE_ME +keyAlias=upload +keyPassword=CHANGE_ME diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..ca7fe06 --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/backend/riotz-api/.env.example b/backend/riotz-api/.env.example new file mode 100644 index 0000000..a543055 --- /dev/null +++ b/backend/riotz-api/.env.example @@ -0,0 +1,9 @@ +DB_URL=jdbc:postgresql://localhost:5432/riotz +DB_USERNAME=postgres +DB_PASSWORD=postgres +JWT_ACCESS_SECRET=change-me-access +JWT_REFRESH_SECRET=change-me-refresh +JWT_ACCESS_EXPIRATION_MS=900000 +JWT_REFRESH_EXPIRATION_MS=604800000 +MEDIA_PROVIDER=s3 +MEDIA_BUCKET_NAME=riotz-media diff --git a/backend/riotz-api/pom.xml b/backend/riotz-api/pom.xml new file mode 100644 index 0000000..3a7ed7a --- /dev/null +++ b/backend/riotz-api/pom.xml @@ -0,0 +1,69 @@ + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.3.5 + + + + com.riotz + riotz-api + 0.0.1-SNAPSHOT + riotz-api + RIOTZ backend API + + + 21 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-websocket + + + org.postgresql + postgresql + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/backend/riotz-api/src/main/java/com/riotz/api/RiotzApiApplication.java b/backend/riotz-api/src/main/java/com/riotz/api/RiotzApiApplication.java new file mode 100644 index 0000000..f09ab40 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/RiotzApiApplication.java @@ -0,0 +1,12 @@ +package com.riotz.api; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RiotzApiApplication { + + public static void main(String[] args) { + SpringApplication.run(RiotzApiApplication.class, args); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/admin/controller/AdminController.java b/backend/riotz-api/src/main/java/com/riotz/api/admin/controller/AdminController.java new file mode 100644 index 0000000..90e0162 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/admin/controller/AdminController.java @@ -0,0 +1,31 @@ +package com.riotz.api.admin.controller; + +import com.riotz.api.admin.service.AdminService; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/admin") +public class AdminController { + + private final AdminService adminService; + + @PatchMapping("/users/{userId}/ban") + public ResponseEntity banUser(@PathVariable UUID userId) { + adminService.banUser(userId); + return ResponseEntity.noContent().build(); + } + + @DeleteMapping("/posts/{postId}") + public ResponseEntity deletePost(@PathVariable UUID postId) { + adminService.deletePost(postId); + return ResponseEntity.noContent().build(); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/admin/service/AdminService.java b/backend/riotz-api/src/main/java/com/riotz/api/admin/service/AdminService.java new file mode 100644 index 0000000..24f7b74 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/admin/service/AdminService.java @@ -0,0 +1,8 @@ +package com.riotz.api.admin.service; + +import java.util.UUID; + +public interface AdminService { + void banUser(UUID userId); + void deletePost(UUID postId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/admin/service/AdminServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/admin/service/AdminServiceImpl.java new file mode 100644 index 0000000..a6f5ec5 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/admin/service/AdminServiceImpl.java @@ -0,0 +1,33 @@ +package com.riotz.api.admin.service; + +import com.riotz.api.common.exception.ResourceNotFoundException; +import com.riotz.api.post.repository.PostRepository; +import com.riotz.api.user.repository.UserRepository; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class AdminServiceImpl implements AdminService { + + private final UserRepository userRepository; + private final PostRepository postRepository; + + @Override + @Transactional + public void banUser(UUID userId) { + final var user = userRepository.findById(userId) + .orElseThrow(() -> new ResourceNotFoundException("User not found")); + user.setBanned(true); + } + + @Override + public void deletePost(UUID postId) { + if (!postRepository.existsById(postId)) { + throw new ResourceNotFoundException("Post not found"); + } + postRepository.deleteById(postId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/auth/controller/AuthController.java b/backend/riotz-api/src/main/java/com/riotz/api/auth/controller/AuthController.java new file mode 100644 index 0000000..38f3555 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/auth/controller/AuthController.java @@ -0,0 +1,21 @@ +package com.riotz.api.auth.controller; + +import com.riotz.api.auth.service.AuthService; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/auth") +public class AuthController { + + private final AuthService authService; + + @GetMapping("/health") + public Map health() { + return Map.of("status", authService.health()); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/auth/service/AuthService.java b/backend/riotz-api/src/main/java/com/riotz/api/auth/service/AuthService.java new file mode 100644 index 0000000..aeead6f --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/auth/service/AuthService.java @@ -0,0 +1,5 @@ +package com.riotz.api.auth.service; + +public interface AuthService { + String health(); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/auth/service/AuthServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/auth/service/AuthServiceImpl.java new file mode 100644 index 0000000..90d40cf --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/auth/service/AuthServiceImpl.java @@ -0,0 +1,12 @@ +package com.riotz.api.auth.service; + +import org.springframework.stereotype.Service; + +@Service +public class AuthServiceImpl implements AuthService { + + @Override + public String health() { + return "auth-module-ready"; + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/chat/controller/ChatController.java b/backend/riotz-api/src/main/java/com/riotz/api/chat/controller/ChatController.java new file mode 100644 index 0000000..d933575 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/chat/controller/ChatController.java @@ -0,0 +1,22 @@ +package com.riotz.api.chat.controller; + +import com.riotz.api.chat.model.Chat; +import com.riotz.api.chat.service.ChatService; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/chats") +public class ChatController { + + private final ChatService chatService; + + @GetMapping + public List listChats() { + return chatService.listChats(); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/chat/model/Chat.java b/backend/riotz-api/src/main/java/com/riotz/api/chat/model/Chat.java new file mode 100644 index 0000000..029fc79 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/chat/model/Chat.java @@ -0,0 +1,26 @@ +package com.riotz.api.chat.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "chats") +public class Chat extends BaseEntity { + + @Id + private UUID id; + + @Column(nullable = false, length = 120) + private String name; + + @Column(nullable = false) + private boolean groupChat = true; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/chat/repository/ChatRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/chat/repository/ChatRepository.java new file mode 100644 index 0000000..e2f8009 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/chat/repository/ChatRepository.java @@ -0,0 +1,8 @@ +package com.riotz.api.chat.repository; + +import com.riotz.api.chat.model.Chat; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ChatRepository extends JpaRepository { +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/chat/service/ChatService.java b/backend/riotz-api/src/main/java/com/riotz/api/chat/service/ChatService.java new file mode 100644 index 0000000..b8f94d8 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/chat/service/ChatService.java @@ -0,0 +1,8 @@ +package com.riotz.api.chat.service; + +import com.riotz.api.chat.model.Chat; +import java.util.List; + +public interface ChatService { + List listChats(); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/chat/service/ChatServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/chat/service/ChatServiceImpl.java new file mode 100644 index 0000000..6ff78de --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/chat/service/ChatServiceImpl.java @@ -0,0 +1,19 @@ +package com.riotz.api.chat.service; + +import com.riotz.api.chat.model.Chat; +import com.riotz.api.chat.repository.ChatRepository; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ChatServiceImpl implements ChatService { + + private final ChatRepository chatRepository; + + @Override + public List listChats() { + return chatRepository.findAll(); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/comment/controller/CommentController.java b/backend/riotz-api/src/main/java/com/riotz/api/comment/controller/CommentController.java new file mode 100644 index 0000000..1f81582 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/comment/controller/CommentController.java @@ -0,0 +1,24 @@ +package com.riotz.api.comment.controller; + +import com.riotz.api.comment.model.Comment; +import com.riotz.api.comment.service.CommentService; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/comments") +public class CommentController { + + private final CommentService commentService; + + @GetMapping("/post/{postId}") + public List listPostComments(@PathVariable UUID postId) { + return commentService.listByPost(postId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/comment/model/Comment.java b/backend/riotz-api/src/main/java/com/riotz/api/comment/model/Comment.java new file mode 100644 index 0000000..a0fa8fc --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/comment/model/Comment.java @@ -0,0 +1,29 @@ +package com.riotz.api.comment.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "comments") +public class Comment extends BaseEntity { + + @Id + private UUID id; + + @Column(nullable = false) + private UUID postId; + + @Column(nullable = false) + private UUID userId; + + @Column(nullable = false, length = 1200) + private String content; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/comment/repository/CommentRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/comment/repository/CommentRepository.java new file mode 100644 index 0000000..c6fb1d0 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/comment/repository/CommentRepository.java @@ -0,0 +1,10 @@ +package com.riotz.api.comment.repository; + +import com.riotz.api.comment.model.Comment; +import java.util.List; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CommentRepository extends JpaRepository { + List findByPostIdOrderByCreatedAtAsc(UUID postId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/comment/service/CommentService.java b/backend/riotz-api/src/main/java/com/riotz/api/comment/service/CommentService.java new file mode 100644 index 0000000..cc78cc6 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/comment/service/CommentService.java @@ -0,0 +1,9 @@ +package com.riotz.api.comment.service; + +import com.riotz.api.comment.model.Comment; +import java.util.List; +import java.util.UUID; + +public interface CommentService { + List listByPost(UUID postId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/comment/service/CommentServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/comment/service/CommentServiceImpl.java new file mode 100644 index 0000000..5e9e835 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/comment/service/CommentServiceImpl.java @@ -0,0 +1,20 @@ +package com.riotz.api.comment.service; + +import com.riotz.api.comment.model.Comment; +import com.riotz.api.comment.repository.CommentRepository; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class CommentServiceImpl implements CommentService { + + private final CommentRepository commentRepository; + + @Override + public List listByPost(UUID postId) { + return commentRepository.findByPostIdOrderByCreatedAtAsc(postId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/common/config/JpaConfig.java b/backend/riotz-api/src/main/java/com/riotz/api/common/config/JpaConfig.java new file mode 100644 index 0000000..ca7f3a3 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/common/config/JpaConfig.java @@ -0,0 +1,9 @@ +package com.riotz.api.common.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@Configuration +@EnableJpaAuditing +public class JpaConfig { +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/common/exception/GlobalExceptionHandler.java b/backend/riotz-api/src/main/java/com/riotz/api/common/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..a0f8ff7 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/common/exception/GlobalExceptionHandler.java @@ -0,0 +1,31 @@ +package com.riotz.api.common.exception; + +import java.time.OffsetDateTime; +import java.util.Map; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class GlobalExceptionHandler { + + @ExceptionHandler(ResourceNotFoundException.class) + public ResponseEntity> handleNotFound(ResourceNotFoundException ex) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Map.of( + "timestamp", OffsetDateTime.now(), + "error", "NOT_FOUND", + "message", ex.getMessage() + )); + } + + @ExceptionHandler(MethodArgumentNotValidException.class) + public ResponseEntity> handleValidation(MethodArgumentNotValidException ex) { + return ResponseEntity.badRequest().body(Map.of( + "timestamp", OffsetDateTime.now(), + "error", "VALIDATION_ERROR", + "message", "Invalid request payload" + )); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/common/exception/ResourceNotFoundException.java b/backend/riotz-api/src/main/java/com/riotz/api/common/exception/ResourceNotFoundException.java new file mode 100644 index 0000000..178461d --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/common/exception/ResourceNotFoundException.java @@ -0,0 +1,7 @@ +package com.riotz.api.common.exception; + +public class ResourceNotFoundException extends RuntimeException { + public ResourceNotFoundException(String message) { + super(message); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/common/model/BaseEntity.java b/backend/riotz-api/src/main/java/com/riotz/api/common/model/BaseEntity.java new file mode 100644 index 0000000..26cc378 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/common/model/BaseEntity.java @@ -0,0 +1,26 @@ +package com.riotz.api.common.model; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import java.time.OffsetDateTime; +import lombok.Getter; +import lombok.Setter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Getter +@Setter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseEntity { + + @CreatedDate + @Column(nullable = false, updatable = false) + private OffsetDateTime createdAt; + + @LastModifiedDate + @Column(nullable = false) + private OffsetDateTime updatedAt; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/message/controller/MessageController.java b/backend/riotz-api/src/main/java/com/riotz/api/message/controller/MessageController.java new file mode 100644 index 0000000..491f506 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/message/controller/MessageController.java @@ -0,0 +1,24 @@ +package com.riotz.api.message.controller; + +import com.riotz.api.message.model.Message; +import com.riotz.api.message.service.MessageService; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/messages") +public class MessageController { + + private final MessageService messageService; + + @GetMapping("/chat/{chatId}") + public List listByChat(@PathVariable UUID chatId) { + return messageService.listByChat(chatId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/message/model/Message.java b/backend/riotz-api/src/main/java/com/riotz/api/message/model/Message.java new file mode 100644 index 0000000..4a28c64 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/message/model/Message.java @@ -0,0 +1,29 @@ +package com.riotz.api.message.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "messages") +public class Message extends BaseEntity { + + @Id + private UUID id; + + @Column(nullable = false) + private UUID chatId; + + @Column(nullable = false) + private UUID senderId; + + @Column(nullable = false, length = 1200) + private String content; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/message/repository/MessageRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/message/repository/MessageRepository.java new file mode 100644 index 0000000..7cd7ab1 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/message/repository/MessageRepository.java @@ -0,0 +1,10 @@ +package com.riotz.api.message.repository; + +import com.riotz.api.message.model.Message; +import java.util.List; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MessageRepository extends JpaRepository { + List findByChatIdOrderByCreatedAtAsc(UUID chatId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/message/service/MessageService.java b/backend/riotz-api/src/main/java/com/riotz/api/message/service/MessageService.java new file mode 100644 index 0000000..27d3df1 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/message/service/MessageService.java @@ -0,0 +1,9 @@ +package com.riotz.api.message.service; + +import com.riotz.api.message.model.Message; +import java.util.List; +import java.util.UUID; + +public interface MessageService { + List listByChat(UUID chatId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/message/service/MessageServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/message/service/MessageServiceImpl.java new file mode 100644 index 0000000..957395c --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/message/service/MessageServiceImpl.java @@ -0,0 +1,20 @@ +package com.riotz.api.message.service; + +import com.riotz.api.message.model.Message; +import com.riotz.api.message.repository.MessageRepository; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class MessageServiceImpl implements MessageService { + + private final MessageRepository messageRepository; + + @Override + public List listByChat(UUID chatId) { + return messageRepository.findByChatIdOrderByCreatedAtAsc(chatId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/post/controller/PostController.java b/backend/riotz-api/src/main/java/com/riotz/api/post/controller/PostController.java new file mode 100644 index 0000000..5a66fcb --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/post/controller/PostController.java @@ -0,0 +1,22 @@ +package com.riotz.api.post.controller; + +import com.riotz.api.post.dto.PostResponse; +import com.riotz.api.post.service.PostService; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/posts") +public class PostController { + + private final PostService postService; + + @GetMapping("/feed") + public List getFeed() { + return postService.getFeed(); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/post/dto/PostResponse.java b/backend/riotz-api/src/main/java/com/riotz/api/post/dto/PostResponse.java new file mode 100644 index 0000000..3363cbe --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/post/dto/PostResponse.java @@ -0,0 +1,14 @@ +package com.riotz.api.post.dto; + +import java.time.OffsetDateTime; +import java.util.UUID; + +public record PostResponse( + UUID id, + UUID userId, + String caption, + String mediaUrl, + int likesCount, + OffsetDateTime createdAt +) { +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/post/model/Post.java b/backend/riotz-api/src/main/java/com/riotz/api/post/model/Post.java new file mode 100644 index 0000000..352f362 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/post/model/Post.java @@ -0,0 +1,32 @@ +package com.riotz.api.post.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "posts") +public class Post extends BaseEntity { + + @Id + private UUID id; + + @Column(nullable = false) + private UUID userId; + + @Column(length = 2800) + private String caption; + + @Column(nullable = false, length = 1024) + private String mediaUrl; + + @Column(nullable = false) + private int likesCount = 0; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/post/repository/PostRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/post/repository/PostRepository.java new file mode 100644 index 0000000..6f731a2 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/post/repository/PostRepository.java @@ -0,0 +1,11 @@ +package com.riotz.api.post.repository; + +import com.riotz.api.post.model.Post; +import java.util.List; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PostRepository extends JpaRepository { + List findAllByOrderByCreatedAtDesc(); + List findByUserIdOrderByCreatedAtDesc(UUID userId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/post/service/PostService.java b/backend/riotz-api/src/main/java/com/riotz/api/post/service/PostService.java new file mode 100644 index 0000000..be58aff --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/post/service/PostService.java @@ -0,0 +1,8 @@ +package com.riotz.api.post.service; + +import com.riotz.api.post.dto.PostResponse; +import java.util.List; + +public interface PostService { + List getFeed(); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/post/service/PostServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/post/service/PostServiceImpl.java new file mode 100644 index 0000000..1d6f47b --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/post/service/PostServiceImpl.java @@ -0,0 +1,31 @@ +package com.riotz.api.post.service; + +import com.riotz.api.post.dto.PostResponse; +import com.riotz.api.post.model.Post; +import com.riotz.api.post.repository.PostRepository; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class PostServiceImpl implements PostService { + + private final PostRepository postRepository; + + @Override + public List getFeed() { + return postRepository.findAllByOrderByCreatedAtDesc().stream().map(this::toResponse).toList(); + } + + private PostResponse toResponse(Post post) { + return new PostResponse( + post.getId(), + post.getUserId(), + post.getCaption(), + post.getMediaUrl(), + post.getLikesCount(), + post.getCreatedAt() + ); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/profile/controller/ProfileController.java b/backend/riotz-api/src/main/java/com/riotz/api/profile/controller/ProfileController.java new file mode 100644 index 0000000..42b1d82 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/profile/controller/ProfileController.java @@ -0,0 +1,23 @@ +package com.riotz.api.profile.controller; + +import com.riotz.api.profile.dto.ProfileResponse; +import com.riotz.api.profile.service.ProfileService; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/profiles") +public class ProfileController { + + private final ProfileService profileService; + + @GetMapping("/{userId}") + public ProfileResponse getProfile(@PathVariable UUID userId) { + return profileService.findByUserId(userId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/profile/dto/ProfileResponse.java b/backend/riotz-api/src/main/java/com/riotz/api/profile/dto/ProfileResponse.java new file mode 100644 index 0000000..8f7b2ba --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/profile/dto/ProfileResponse.java @@ -0,0 +1,10 @@ +package com.riotz.api.profile.dto; + +import java.util.UUID; + +public record ProfileResponse( + UUID userId, + String avatarUrl, + String bio +) { +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/profile/model/Profile.java b/backend/riotz-api/src/main/java/com/riotz/api/profile/model/Profile.java new file mode 100644 index 0000000..ecffc59 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/profile/model/Profile.java @@ -0,0 +1,26 @@ +package com.riotz.api.profile.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "profiles") +public class Profile extends BaseEntity { + + @Id + private UUID userId; + + @Column(length = 1024) + private String avatarUrl; + + @Column(length = 280) + private String bio; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/profile/repository/ProfileRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/profile/repository/ProfileRepository.java new file mode 100644 index 0000000..f8f31f8 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/profile/repository/ProfileRepository.java @@ -0,0 +1,8 @@ +package com.riotz.api.profile.repository; + +import com.riotz.api.profile.model.Profile; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ProfileRepository extends JpaRepository { +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/profile/service/ProfileService.java b/backend/riotz-api/src/main/java/com/riotz/api/profile/service/ProfileService.java new file mode 100644 index 0000000..0487cdf --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/profile/service/ProfileService.java @@ -0,0 +1,8 @@ +package com.riotz.api.profile.service; + +import com.riotz.api.profile.dto.ProfileResponse; +import java.util.UUID; + +public interface ProfileService { + ProfileResponse findByUserId(UUID userId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/profile/service/ProfileServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/profile/service/ProfileServiceImpl.java new file mode 100644 index 0000000..8615d08 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/profile/service/ProfileServiceImpl.java @@ -0,0 +1,27 @@ +package com.riotz.api.profile.service; + +import com.riotz.api.common.exception.ResourceNotFoundException; +import com.riotz.api.profile.dto.ProfileResponse; +import com.riotz.api.profile.model.Profile; +import com.riotz.api.profile.repository.ProfileRepository; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ProfileServiceImpl implements ProfileService { + + private final ProfileRepository profileRepository; + + @Override + public ProfileResponse findByUserId(UUID userId) { + return profileRepository.findById(userId) + .map(this::toResponse) + .orElseThrow(() -> new ResourceNotFoundException("Profile not found")); + } + + private ProfileResponse toResponse(Profile profile) { + return new ProfileResponse(profile.getUserId(), profile.getAvatarUrl(), profile.getBio()); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/security/config/SecurityConfig.java b/backend/riotz-api/src/main/java/com/riotz/api/security/config/SecurityConfig.java new file mode 100644 index 0000000..2553149 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/security/config/SecurityConfig.java @@ -0,0 +1,22 @@ +package com.riotz.api.security.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +public class SecurityConfig { + + @Bean + SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + return http + .csrf(csrf -> csrf.disable()) + .cors(Customizer.withDefaults()) + .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests(auth -> auth.anyRequest().permitAll()) + .build(); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/track/controller/TrackController.java b/backend/riotz-api/src/main/java/com/riotz/api/track/controller/TrackController.java new file mode 100644 index 0000000..ee3bfe9 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/track/controller/TrackController.java @@ -0,0 +1,24 @@ +package com.riotz.api.track.controller; + +import com.riotz.api.track.model.Track; +import com.riotz.api.track.service.TrackService; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/tracks") +public class TrackController { + + private final TrackService trackService; + + @GetMapping("/user/{userId}") + public List listByUser(@PathVariable UUID userId) { + return trackService.listByUser(userId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/track/model/Track.java b/backend/riotz-api/src/main/java/com/riotz/api/track/model/Track.java new file mode 100644 index 0000000..956e2a1 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/track/model/Track.java @@ -0,0 +1,32 @@ +package com.riotz.api.track.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "tracks") +public class Track extends BaseEntity { + + @Id + private UUID id; + + @Column(nullable = false) + private UUID userId; + + @Column(nullable = false, length = 120) + private String title; + + @Column(nullable = false, length = 1024) + private String audioUrl; + + @Column(nullable = false, length = 256) + private String tags; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/track/repository/TrackRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/track/repository/TrackRepository.java new file mode 100644 index 0000000..de64eac --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/track/repository/TrackRepository.java @@ -0,0 +1,10 @@ +package com.riotz.api.track.repository; + +import com.riotz.api.track.model.Track; +import java.util.List; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TrackRepository extends JpaRepository { + List findByUserIdOrderByCreatedAtDesc(UUID userId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/track/service/TrackService.java b/backend/riotz-api/src/main/java/com/riotz/api/track/service/TrackService.java new file mode 100644 index 0000000..76a9117 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/track/service/TrackService.java @@ -0,0 +1,9 @@ +package com.riotz.api.track.service; + +import com.riotz.api.track.model.Track; +import java.util.List; +import java.util.UUID; + +public interface TrackService { + List listByUser(UUID userId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/track/service/TrackServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/track/service/TrackServiceImpl.java new file mode 100644 index 0000000..6fb8c88 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/track/service/TrackServiceImpl.java @@ -0,0 +1,20 @@ +package com.riotz.api.track.service; + +import com.riotz.api.track.model.Track; +import com.riotz.api.track.repository.TrackRepository; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class TrackServiceImpl implements TrackService { + + private final TrackRepository trackRepository; + + @Override + public List listByUser(UUID userId) { + return trackRepository.findByUserIdOrderByCreatedAtDesc(userId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/controller/UserController.java b/backend/riotz-api/src/main/java/com/riotz/api/user/controller/UserController.java new file mode 100644 index 0000000..ee0b5b3 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/controller/UserController.java @@ -0,0 +1,29 @@ +package com.riotz.api.user.controller; + +import com.riotz.api.user.dto.UserResponse; +import com.riotz.api.user.service.UserService; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/users") +public class UserController { + + private final UserService userService; + + @GetMapping + public List listUsers() { + return userService.findAll(); + } + + @GetMapping("/{userId}") + public UserResponse getUser(@PathVariable UUID userId) { + return userService.findById(userId); + } +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/dto/UserResponse.java b/backend/riotz-api/src/main/java/com/riotz/api/user/dto/UserResponse.java new file mode 100644 index 0000000..2bcfe69 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/dto/UserResponse.java @@ -0,0 +1,13 @@ +package com.riotz.api.user.dto; + +import com.riotz.api.user.model.Role; +import java.util.UUID; + +public record UserResponse( + UUID id, + String email, + String username, + Role role, + boolean banned +) { +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/model/Role.java b/backend/riotz-api/src/main/java/com/riotz/api/user/model/Role.java new file mode 100644 index 0000000..7bd848c --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/model/Role.java @@ -0,0 +1,6 @@ +package com.riotz.api.user.model; + +public enum Role { + USER, + ADMIN +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/model/User.java b/backend/riotz-api/src/main/java/com/riotz/api/user/model/User.java new file mode 100644 index 0000000..d5e6286 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/model/User.java @@ -0,0 +1,38 @@ +package com.riotz.api.user.model; + +import com.riotz.api.common.model.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@Table(name = "users") +public class User extends BaseEntity { + + @Id + private UUID id; + + @Column(nullable = false, unique = true, length = 255) + private String email; + + @Column(nullable = false, length = 60) + private String passwordHash; + + @Column(nullable = false, unique = true, length = 32) + private String username; + + @Enumerated(EnumType.STRING) + @Column(nullable = false, length = 16) + private Role role = Role.USER; + + @Column(nullable = false) + private boolean banned = false; +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/repository/UserRepository.java b/backend/riotz-api/src/main/java/com/riotz/api/user/repository/UserRepository.java new file mode 100644 index 0000000..0f4cf68 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/repository/UserRepository.java @@ -0,0 +1,11 @@ +package com.riotz.api.user.repository; + +import com.riotz.api.user.model.User; +import java.util.Optional; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UserRepository extends JpaRepository { + Optional findByEmail(String email); + Optional findByUsername(String username); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/service/UserService.java b/backend/riotz-api/src/main/java/com/riotz/api/user/service/UserService.java new file mode 100644 index 0000000..b3a3a65 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/service/UserService.java @@ -0,0 +1,10 @@ +package com.riotz.api.user.service; + +import com.riotz.api.user.dto.UserResponse; +import java.util.List; +import java.util.UUID; + +public interface UserService { + List findAll(); + UserResponse findById(UUID userId); +} diff --git a/backend/riotz-api/src/main/java/com/riotz/api/user/service/UserServiceImpl.java b/backend/riotz-api/src/main/java/com/riotz/api/user/service/UserServiceImpl.java new file mode 100644 index 0000000..02fbd62 --- /dev/null +++ b/backend/riotz-api/src/main/java/com/riotz/api/user/service/UserServiceImpl.java @@ -0,0 +1,32 @@ +package com.riotz.api.user.service; + +import com.riotz.api.common.exception.ResourceNotFoundException; +import com.riotz.api.user.dto.UserResponse; +import com.riotz.api.user.model.User; +import com.riotz.api.user.repository.UserRepository; +import java.util.List; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class UserServiceImpl implements UserService { + + private final UserRepository userRepository; + + @Override + public List findAll() { + return userRepository.findAll().stream().map(this::toResponse).toList(); + } + + @Override + public UserResponse findById(UUID userId) { + return userRepository.findById(userId).map(this::toResponse) + .orElseThrow(() -> new ResourceNotFoundException("User not found")); + } + + private UserResponse toResponse(User user) { + return new UserResponse(user.getId(), user.getEmail(), user.getUsername(), user.getRole(), user.isBanned()); + } +} diff --git a/backend/riotz-api/src/main/resources/application.yml b/backend/riotz-api/src/main/resources/application.yml new file mode 100644 index 0000000..8509d91 --- /dev/null +++ b/backend/riotz-api/src/main/resources/application.yml @@ -0,0 +1,27 @@ +spring: + application: + name: riotz-api + datasource: + url: ${DB_URL:jdbc:postgresql://localhost:5432/riotz} + username: ${DB_USERNAME:postgres} + password: ${DB_PASSWORD:postgres} + jpa: + hibernate: + ddl-auto: validate + properties: + hibernate: + format_sql: true + open-in-view: false + +server: + port: ${SERVER_PORT:8080} + +jwt: + access-token-secret: ${JWT_ACCESS_SECRET:change-me-access} + refresh-token-secret: ${JWT_REFRESH_SECRET:change-me-refresh} + access-token-expiration-ms: ${JWT_ACCESS_EXPIRATION_MS:900000} + refresh-token-expiration-ms: ${JWT_REFRESH_EXPIRATION_MS:604800000} + +media: + provider: ${MEDIA_PROVIDER:s3} + bucket-name: ${MEDIA_BUCKET_NAME:riotz-media} diff --git a/env.production.json.example b/env.production.json.example new file mode 100644 index 0000000..131386b --- /dev/null +++ b/env.production.json.example @@ -0,0 +1,5 @@ +{ + "SUPABASE_URL": "https://YOUR_PROJECT_ID.supabase.co", + "SUPABASE_ANON_KEY": "YOUR_SUPABASE_ANON_KEY", + "ADMIN_USER_IDS": "uuid-1,uuid-2" +} 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..391a902 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.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..b1aee00 --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,620 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.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 PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy 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 = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 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 = ""; }; + 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.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 */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 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 */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + 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 */, + 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 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 = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 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 */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 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; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + 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; + alwaysOutOfDate = 1; + 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 */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency 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; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + 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 = 13.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.riotz.app; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + 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 = 13.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; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + 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 = 13.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.riotz.app; + 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.riotz.app; + 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 */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 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..e3773d4 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..c30b367 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,16 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } +} 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..7353c41 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..797d452 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..6ed2d93 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..4cd7b00 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..fe73094 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..321773c 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..797d452 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..502f463 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..0ec3034 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..0ec3034 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..e9f5fea 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..84ac32a 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..8953cba 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..0467bf1 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..d8b0b94 --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,76 @@ + + + + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + RIOTZ + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + RIOTZ + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + NSPhotoLibraryUsageDescription + RIOTZ needs photo access so you can upload post images and avatars. + NSPhotoLibraryAddUsageDescription + RIOTZ may save edited media previews to your photo library. + UIFileSharingEnabled + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + 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/ios/Runner/SceneDelegate.swift b/ios/Runner/SceneDelegate.swift new file mode 100644 index 0000000..b9ce8ea --- /dev/null +++ b/ios/Runner/SceneDelegate.swift @@ -0,0 +1,6 @@ +import Flutter +import UIKit + +class SceneDelegate: FlutterSceneDelegate { + +} diff --git a/ios/RunnerTests/RunnerTests.swift b/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/lib/app/app.dart b/lib/app/app.dart new file mode 100644 index 0000000..2ce44c2 --- /dev/null +++ b/lib/app/app.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../core/router/app_router.dart'; +import '../core/theme/app_theme.dart'; + +class RiotzApp extends ConsumerWidget { + const RiotzApp({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final router = ref.watch(appRouterProvider); + + return MaterialApp.router( + title: 'RIOTZ', + theme: AppTheme.dark, + debugShowCheckedModeBanner: false, + routerConfig: router, + ); + } +} diff --git a/lib/core/config/admin_whitelist.dart b/lib/core/config/admin_whitelist.dart new file mode 100644 index 0000000..1a28863 --- /dev/null +++ b/lib/core/config/admin_whitelist.dart @@ -0,0 +1,17 @@ +class AdminWhitelist { + const AdminWhitelist._(); + + // Whitelist of admin emails. + // In a real production app, this should be handled via database roles (RBAC). + static const Set emails = { + 'admin@riotz.com', + 'root@riotz.com', + 'creator@riotz.com', + }; + + /// Checks if a user is an admin based on their email. + static bool isAdmin(String? email) { + if (email == null) return false; + return emails.contains(email.toLowerCase()); + } +} diff --git a/lib/core/config/supabase_config.dart b/lib/core/config/supabase_config.dart new file mode 100644 index 0000000..cfa320d --- /dev/null +++ b/lib/core/config/supabase_config.dart @@ -0,0 +1,22 @@ +import 'package:supabase_flutter/supabase_flutter.dart'; + +class SupabaseConfig { + const SupabaseConfig._(); + + static const _url = String.fromEnvironment('SUPABASE_URL'); + static const _anonKey = String.fromEnvironment('SUPABASE_ANON_KEY'); + + static Future initialize() async { + if (_url.isEmpty || _anonKey.isEmpty) { + throw StateError( + 'Missing Supabase env values. Provide SUPABASE_URL and SUPABASE_ANON_KEY ' + 'using --dart-define.', + ); + } + + await Supabase.initialize( + url: _url, + anonKey: _anonKey, + ); + } +} diff --git a/lib/core/models/result.dart b/lib/core/models/result.dart new file mode 100644 index 0000000..95362f9 --- /dev/null +++ b/lib/core/models/result.dart @@ -0,0 +1,14 @@ +sealed class Result { + const Result(); +} + +class Success extends Result { + final T data; + const Success(this.data); +} + +class Failure extends Result { + final String message; + final dynamic error; + const Failure(this.message, [this.error]); +} diff --git a/lib/core/router/app_router.dart b/lib/core/router/app_router.dart new file mode 100644 index 0000000..87db459 --- /dev/null +++ b/lib/core/router/app_router.dart @@ -0,0 +1,107 @@ +import 'dart:async'; + +import 'package:flutter/widgets.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../features/auth/presentation/screens/forgot_password_screen.dart'; +import '../../features/auth/presentation/screens/login_screen.dart'; +import '../../features/auth/presentation/screens/signup_screen.dart'; +import '../../features/admin/presentation/screens/admin_screen.dart'; +import '../../features/discover/presentation/pages/discover_page.dart'; +import '../../features/feed/presentation/screens/feed_screen.dart'; +import '../../features/feed/presentation/screens/upload_post_screen.dart'; +import '../../features/music/presentation/pages/music_page.dart'; +import '../../features/profile/presentation/pages/profile_page.dart'; +import '../../features/splash/presentation/pages/splash_page.dart'; +import '../../features/theme_preview/presentation/pages/riotz_theme_preview_page.dart'; +import '../supabase/supabase_providers.dart'; +import 'app_routes.dart'; + +final appRouterProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + final authStateStream = client.auth.onAuthStateChange; + + return GoRouter( + initialLocation: AppRoutes.splash, + refreshListenable: GoRouterRefreshStream(authStateStream), + routes: [ + GoRoute( + path: AppRoutes.splash, + builder: (context, state) => const SplashPage(), + ), + GoRoute( + path: AppRoutes.login, + builder: (context, state) => const LoginScreen(), + ), + GoRoute( + path: AppRoutes.signup, + builder: (context, state) => const SignupScreen(), + ), + GoRoute( + path: AppRoutes.forgotPassword, + builder: (context, state) => const ForgotPasswordScreen(), + ), + GoRoute( + path: AppRoutes.home, + builder: (context, state) => const FeedScreen(), + ), + GoRoute( + path: AppRoutes.uploadPost, + builder: (context, state) => const UploadPostScreen(), + ), + GoRoute( + path: AppRoutes.profile, + builder: (context, state) => const ProfilePage(), + ), + GoRoute( + path: AppRoutes.music, + builder: (context, state) => const MusicPage(), + ), + GoRoute( + path: AppRoutes.discover, + builder: (context, state) => const DiscoverPage(), + ), + GoRoute( + path: AppRoutes.admin, + builder: (context, state) => const AdminScreen(), + ), + GoRoute( + path: AppRoutes.themePreview, + builder: (context, state) => const RiotzThemePreviewPage(), + ), + ], + redirect: (context, state) { + final isLoggedIn = client.auth.currentUser != null; + final isSplash = state.matchedLocation == AppRoutes.splash; + final isAuthRoute = state.matchedLocation == AppRoutes.login || + state.matchedLocation == AppRoutes.signup || + state.matchedLocation == AppRoutes.forgotPassword; + + if (!isLoggedIn && !isSplash && !isAuthRoute) { + return AppRoutes.login; + } + + if (isLoggedIn && (isSplash || isAuthRoute)) { + return AppRoutes.home; + } + + return null; + }, + ); +}); + +class GoRouterRefreshStream extends ChangeNotifier { + GoRouterRefreshStream(Stream stream) { + _subscription = stream.asBroadcastStream().listen((_) => notifyListeners()); + } + + late final StreamSubscription _subscription; + + @override + void dispose() { + _subscription.cancel(); + super.dispose(); + } +} diff --git a/lib/core/router/app_routes.dart b/lib/core/router/app_routes.dart new file mode 100644 index 0000000..b9a8884 --- /dev/null +++ b/lib/core/router/app_routes.dart @@ -0,0 +1,15 @@ +class AppRoutes { + const AppRoutes._(); + + static const splash = '/'; + static const login = '/auth/login'; + static const signup = '/auth/signup'; + static const forgotPassword = '/auth/forgot-password'; + static const home = '/home'; + static const uploadPost = '/upload-post'; + static const profile = '/profile'; + static const music = '/music'; + static const discover = '/discover'; + static const admin = '/admin'; + static const themePreview = '/theme-preview'; +} diff --git a/lib/core/services/storage_service.dart b/lib/core/services/storage_service.dart new file mode 100644 index 0000000..a3c7c29 --- /dev/null +++ b/lib/core/services/storage_service.dart @@ -0,0 +1,27 @@ +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +final storageServiceProvider = Provider((ref) { + return const StorageService(FlutterSecureStorage()); +}); + +class StorageService { + const StorageService(this._storage); + final FlutterSecureStorage _storage; + + Future write(String key, String value) async { + await _storage.write(key: key, value: value); + } + + Future read(String key) async { + return await _storage.read(key: key); + } + + Future delete(String key) async { + await _storage.delete(key: key); + } + + Future clearAll() async { + await _storage.deleteAll(); + } +} diff --git a/lib/core/supabase/supabase_providers.dart b/lib/core/supabase/supabase_providers.dart new file mode 100644 index 0000000..275e05f --- /dev/null +++ b/lib/core/supabase/supabase_providers.dart @@ -0,0 +1,6 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; + +final supabaseProvider = Provider( + (ref) => Supabase.instance.client, +); diff --git a/lib/core/theme/app_animations.dart b/lib/core/theme/app_animations.dart new file mode 100644 index 0000000..647448b --- /dev/null +++ b/lib/core/theme/app_animations.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; + +class AppAnimations { + const AppAnimations._(); + + /// A standard fade transition + static Widget fade({ + required Widget child, + Duration duration = const Duration(milliseconds: 300), + }) { + return AnimatedSwitcher( + duration: duration, + child: child, + ); + } + + /// A slide transition from the bottom (Brutalist style) + static Widget slideIn({ + required Widget child, + Offset begin = const Offset(0, 0.1), + Duration duration = const Duration(milliseconds: 400), + }) { + return TweenAnimationBuilder( + tween: Tween(begin: begin, end: Offset.zero), + duration: duration, + curve: Curves.easeOutQuart, + builder: (context, offset, child) { + return FractionalTranslation( + translation: offset, + child: child, + ); + }, + child: child, + ); + } + + /// A simple "Glitch" effect using staggered offsets and opacities + /// This simulates an underground/grunge signal interference. + static Widget glitch({required Widget child}) { + return _GlitchWidget(child: child); + } +} + +class _GlitchWidget extends StatefulWidget { + final Widget child; + const _GlitchWidget({required this.child}); + + @override + State<_GlitchWidget> createState() => _GlitchWidgetState(); +} + +class _GlitchWidgetState extends State<_GlitchWidget> with SingleTickerProviderStateMixin { + late AnimationController _controller; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 500), + )..repeat(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AnimatedBuilder( + animation: _controller, + builder: (context, child) { + final double glitchFactor = _controller.value; + // Only glitch occasionally + if (glitchFactor > 0.9) { + return Stack( + children: [ + Transform.translate( + offset: const Offset(2, 0), + child: Opacity(opacity: 0.5, child: widget.child), + ), + Transform.translate( + offset: const Offset(-2, 1), + child: Opacity(opacity: 0.5, child: widget.child), + ), + widget.child, + ], + ); + } + return widget.child; + }, + ); + } +} diff --git a/lib/core/theme/app_colors.dart b/lib/core/theme/app_colors.dart new file mode 100644 index 0000000..698853a --- /dev/null +++ b/lib/core/theme/app_colors.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +class AppColors { + const AppColors._(); + + // Core Palette + static const black = Color(0xFF000000); // Pitch black + static const blackRaised = Color(0xFF1A1A1A); // Slightly raised black + static const blackSoft = Color(0xFF0F0F0F); // Soft black for backgrounds + static const darkGrey = Color(0xFF0A0A0A); + static const white = Color(0xFFFFFFFF); + static const offWhite = Color(0xFFEBEBEB); // For body text readability + + // RIOTZ Red Tones (Aggressive & Premium) + static const neonRed = Color(0xFFFF0033); // Primary accent + static const bloodRed = Color(0xFF8B0000); // Secondary + static const deepRed = Color(0xFF4A0000); // Muted backgrounds + + // Purple Accents + static const neonPurple = Color(0xFF9D00FF); // Neon purple accent + + // Surfaces & Borders + static const surface = Color(0xFF0D0D0D); // Elevated surfaces + static const surfaceLight = Color(0xFF1A1A1A); + static const border = Color(0xFF262626); // Brutalist outlines + + // Neutral / Muted + static const grey = Color(0xFF757575); + static const greyDark = Color(0xFF424242); + static const greyMuted = Color(0xFF212121); + + // Semantic + static const error = Color(0xFFFF0033); + static const success = Color(0xFF00FF66); // Acid green for contrast +} diff --git a/lib/core/theme/app_motion.dart b/lib/core/theme/app_motion.dart new file mode 100644 index 0000000..3c48aa8 --- /dev/null +++ b/lib/core/theme/app_motion.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class AppMotion { + const AppMotion._(); + + static const fast = Duration(milliseconds: 120); + static const normal = Duration(milliseconds: 220); + static const slow = Duration(milliseconds: 360); + + static const standardCurve = Curves.easeOutCubic; + static const emphasizedCurve = Curves.easeOutQuart; +} diff --git a/lib/core/theme/app_theme.dart b/lib/core/theme/app_theme.dart new file mode 100644 index 0000000..6099662 --- /dev/null +++ b/lib/core/theme/app_theme.dart @@ -0,0 +1,131 @@ +import 'package:flutter/material.dart'; +import 'app_colors.dart'; +import 'app_typography.dart'; +import 'app_motion.dart'; + +class AppTheme { + const AppTheme._(); + + static ThemeData get dark { + final textTheme = AppTypography.darkTextTheme(); + + return ThemeData( + useMaterial3: true, + brightness: Brightness.dark, + scaffoldBackgroundColor: AppColors.black, + colorScheme: const ColorScheme.dark( + primary: AppColors.neonRed, + secondary: AppColors.bloodRed, + surface: AppColors.surface, + onPrimary: AppColors.white, + onSecondary: AppColors.white, + onSurface: AppColors.white, + error: AppColors.error, + outline: AppColors.border, + ), + textTheme: textTheme, + + // App Bar Theme - Centralized & Brutalist + appBarTheme: AppBarTheme( + backgroundColor: AppColors.black, + elevation: 0, + centerTitle: true, + iconTheme: const IconThemeData(color: AppColors.white, size: 20), + titleTextStyle: textTheme.headlineMedium?.copyWith( + color: AppColors.white, + ), + ), + + // Card Theme - Sharp Edges, Subtle Borders + cardTheme: CardThemeData( + color: AppColors.surface, + elevation: 0, + margin: EdgeInsets.zero, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.zero, + side: BorderSide(color: AppColors.border, width: 1), + ), + ), + + // Input Decoration - Industrial / Terminal style + inputDecorationTheme: InputDecorationTheme( + filled: true, + fillColor: AppColors.surface, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), + hintStyle: textTheme.bodySmall?.copyWith(color: AppColors.greyDark), + labelStyle: textTheme.bodyMedium?.copyWith(color: AppColors.grey), + border: const OutlineInputBorder( + borderRadius: BorderRadius.zero, + borderSide: BorderSide(color: AppColors.border), + ), + enabledBorder: const OutlineInputBorder( + borderRadius: BorderRadius.zero, + borderSide: BorderSide(color: AppColors.border), + ), + focusedBorder: const OutlineInputBorder( + borderRadius: BorderRadius.zero, + borderSide: BorderSide(color: AppColors.neonRed, width: 1.5), + ), + errorBorder: const OutlineInputBorder( + borderRadius: BorderRadius.zero, + borderSide: BorderSide(color: AppColors.error), + ), + ), + + // Button Themes + filledButtonTheme: FilledButtonThemeData( + style: FilledButton.styleFrom( + backgroundColor: AppColors.neonRed, + foregroundColor: AppColors.white, + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), + textStyle: textTheme.labelLarge, + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24), + ), + ), + + outlinedButtonTheme: OutlinedButtonThemeData( + style: OutlinedButton.styleFrom( + foregroundColor: AppColors.white, + side: const BorderSide(color: AppColors.white, width: 1.5), + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), + textStyle: textTheme.labelLarge, + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24), + ), + ), + + // Navigation Bar - Custom Riotz Feel + navigationBarTheme: NavigationBarThemeData( + backgroundColor: AppColors.black, + indicatorColor: AppColors.neonRed.withOpacity(0.1), + labelTextStyle: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.selected)) { + return textTheme.bodySmall?.copyWith(color: AppColors.neonRed, fontWeight: FontWeight.bold); + } + return textTheme.bodySmall?.copyWith(color: AppColors.grey); + }), + iconTheme: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.selected)) { + return const IconThemeData(color: AppColors.neonRed, size: 24); + } + return const IconThemeData(color: AppColors.grey, size: 24); + }), + ), + + // Dialog Theme + dialogTheme: const DialogThemeData( + backgroundColor: AppColors.surface, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.zero, + side: BorderSide(color: AppColors.border, width: 1), + ), + ), + + dividerTheme: const DividerThemeData( + color: AppColors.border, + thickness: 1, + space: 1, + ), + ); + } +} diff --git a/lib/core/theme/app_typography.dart b/lib/core/theme/app_typography.dart new file mode 100644 index 0000000..ffd39c1 --- /dev/null +++ b/lib/core/theme/app_typography.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import 'app_colors.dart'; + +class AppTypography { + const AppTypography._(); + + // Primary heading font: Aggressive, industrial, and bold + static String get headingFont => GoogleFonts.bebasNeue().fontFamily!; + + // Body font: Monospace or clean Sans for that "terminal/underground" feel + static String get bodyFont => GoogleFonts.inter().fontFamily!; + static String get monoFont => GoogleFonts.jetBrainsMono().fontFamily!; + + static TextTheme darkTextTheme() { + return TextTheme( + displayLarge: TextStyle( + fontFamily: headingFont, + fontSize: 72, + fontWeight: FontWeight.w900, + color: AppColors.white, + letterSpacing: -1.0, + height: 0.9, + ), + displayMedium: TextStyle( + fontFamily: headingFont, + fontSize: 48, + fontWeight: FontWeight.bold, + color: AppColors.white, + letterSpacing: 0.5, + height: 1.0, + ), + headlineLarge: TextStyle( + fontFamily: headingFont, + fontSize: 32, + fontWeight: FontWeight.bold, + color: AppColors.neonRed, + letterSpacing: 1.5, + ), + headlineMedium: TextStyle( + fontFamily: headingFont, + fontSize: 24, + fontWeight: FontWeight.bold, + color: AppColors.white, + letterSpacing: 1.2, + ), + titleLarge: TextStyle( + fontFamily: bodyFont, + fontSize: 20, + fontWeight: FontWeight.w900, + color: AppColors.white, + letterSpacing: -0.5, + ), + titleMedium: TextStyle( + fontFamily: bodyFont, + fontSize: 16, + fontWeight: FontWeight.w700, + color: AppColors.white, + ), + bodyLarge: TextStyle( + fontFamily: bodyFont, + fontSize: 16, + fontWeight: FontWeight.normal, + color: AppColors.offWhite, + height: 1.5, + ), + bodyMedium: TextStyle( + fontFamily: bodyFont, + fontSize: 14, + fontWeight: FontWeight.normal, + color: AppColors.offWhite, + height: 1.4, + ), + bodySmall: TextStyle( + fontFamily: monoFont, + fontSize: 12, + fontWeight: FontWeight.w400, + color: AppColors.grey, + letterSpacing: 0.5, + ), + labelLarge: TextStyle( + fontFamily: headingFont, + fontSize: 18, + fontWeight: FontWeight.bold, + color: AppColors.white, + letterSpacing: 2.0, + ), + ); + } +} diff --git a/lib/core/widgets/riotz_button.dart b/lib/core/widgets/riotz_button.dart new file mode 100644 index 0000000..9900e8b --- /dev/null +++ b/lib/core/widgets/riotz_button.dart @@ -0,0 +1,76 @@ +import 'package:flutter/material.dart'; +import '../theme/app_colors.dart'; + +enum RiotzButtonStyle { primary, secondary, outline } + +class RiotzButton extends StatelessWidget { + const RiotzButton({ + required this.label, + required this.onPressed, + this.style = RiotzButtonStyle.primary, + this.isLoading = false, + this.fullWidth = true, + super.key, + }); + + final String label; + final VoidCallback? onPressed; + final RiotzButtonStyle style; + final bool isLoading; + final bool fullWidth; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + Widget content = isLoading + ? const SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator(strokeWidth: 2, color: AppColors.white), + ) + : Text(label.toUpperCase(), style: theme.textTheme.labelLarge); + + if (fullWidth) { + content = Center(child: content); + } + + return InkWell( + onTap: isLoading ? null : onPressed, + child: AnimatedContainer( + duration: const Duration(milliseconds: 200), + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24), + decoration: BoxDecoration( + color: _getBgColor(), + border: Border.all( + color: _getBorderColor(), + width: 2, + ), + ), + child: content, + ), + ); + } + + Color _getBgColor() { + switch (style) { + case RiotzButtonStyle.primary: + return AppColors.neonRed; + case RiotzButtonStyle.secondary: + return AppColors.bloodRed; + case RiotzButtonStyle.outline: + return Colors.transparent; + } + } + + Color _getBorderColor() { + switch (style) { + case RiotzButtonStyle.primary: + return AppColors.neonRed; + case RiotzButtonStyle.secondary: + return AppColors.bloodRed; + case RiotzButtonStyle.outline: + return AppColors.white; + } + } +} diff --git a/lib/core/widgets/riotz_card.dart b/lib/core/widgets/riotz_card.dart new file mode 100644 index 0000000..acbaad9 --- /dev/null +++ b/lib/core/widgets/riotz_card.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import '../theme/app_colors.dart'; + +class RiotzCard extends StatelessWidget { + const RiotzCard({ + required this.child, + this.padding, + this.onTap, + this.isAccent = false, + super.key, + }); + + final Widget child; + final EdgeInsetsGeometry? padding; + final VoidCallback? onTap; + final bool isAccent; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + padding: padding ?? const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColors.surface, + border: Border.all( + color: isAccent ? AppColors.neonRed : AppColors.border, + width: isAccent ? 2 : 1, + ), + ), + child: child, + ), + ); + } +} diff --git a/lib/core/widgets/riotz_scaffold.dart b/lib/core/widgets/riotz_scaffold.dart new file mode 100644 index 0000000..db72515 --- /dev/null +++ b/lib/core/widgets/riotz_scaffold.dart @@ -0,0 +1,68 @@ +import 'package:flutter/material.dart'; +import '../theme/app_colors.dart'; + +class RiotzScaffold extends StatelessWidget { + const RiotzScaffold({ + required this.body, + this.appBar, + this.bottomNavigationBar, + this.floatingActionButton, + this.useSafeArea = true, + super.key, + }); + + final Widget body; + final PreferredSizeWidget? appBar; + final Widget? bottomNavigationBar; + final Widget? floatingActionButton; + final bool useSafeArea; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: appBar, + body: Stack( + children: [ + // Base Layer: Deep Black + Container(color: AppColors.black), + + // Aesthetic Layer: Subtle Brutalist Gradient + Positioned.fill( + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + AppColors.black, + AppColors.deepRed.withOpacity(0.05), + AppColors.black, + ], + ), + ), + ), + ), + + // Texture Layer: Grunge Overlay + // Note: Add 'assets/textures/noise.png' to pubspec and uncomment below + /* + Positioned.fill( + child: Opacity( + opacity: 0.03, + child: Image.asset( + 'assets/textures/noise.png', + repeat: ImageRepeat.repeat, + ), + ), + ), + */ + + // Content Layer + useSafeArea ? SafeArea(child: body) : body, + ], + ), + bottomNavigationBar: bottomNavigationBar, + floatingActionButton: floatingActionButton, + ); + } +} diff --git a/lib/features/admin/data/services/admin_service.dart b/lib/features/admin/data/services/admin_service.dart new file mode 100644 index 0000000..f9eb739 --- /dev/null +++ b/lib/features/admin/data/services/admin_service.dart @@ -0,0 +1,112 @@ +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../../music/domain/models/track_model.dart'; +import '../../domain/models/admin_panel_data_model.dart'; +import '../../domain/models/admin_post_model.dart'; +import '../../domain/models/admin_user_model.dart'; + +class AdminService { + const AdminService(this._client); + + final SupabaseClient _client; + + Future fetchPanelData() async { + // Fetch all profiles + final profileRows = List>.from( + await _client.from('profiles').select('user_id, username, avatar_url, banned, featured'), + ); + + // Fetch latest posts + final postRows = List>.from( + await _client + .from('posts') + .select('id, user_id, caption, image_url, likes_count, featured') + .order('created_at', ascending: false) + .limit(100), + ); + + // Fetch tracks + final trackRows = List>.from( + await _client + .from('tracks') + .select('*, profiles(username)') + .order('created_at', ascending: false) + .limit(100), + ); + + final userMap = {}; + for (final row in profileRows) { + final user = AdminUserModel( + userId: row['user_id'] as String, + username: (row['username'] as String?) ?? 'RIOTER', + avatarUrl: (row['avatar_url'] as String?) ?? '', + banned: (row['banned'] as bool?) ?? false, + featured: (row['featured'] as bool?) ?? false, + ); + userMap[user.userId] = user; + } + + final users = userMap.values.toList() + ..sort((a, b) => a.username.toLowerCase().compareTo(b.username.toLowerCase())); + + final posts = postRows.map((row) { + final user = userMap[row['user_id']] ?? + AdminUserModel( + userId: row['user_id'] as String, + username: 'RIOTER', + avatarUrl: '', + banned: false, + featured: false, + ); + return AdminPostModel( + id: row['id'] as String, + userId: row['user_id'] as String, + username: user.username, + imageUrl: (row['image_url'] as String?) ?? '', + caption: (row['caption'] as String?) ?? '', + likesCount: (row['likes_count'] as int?) ?? 0, + featured: (row['featured'] as bool?) ?? false, + ); + }).toList(); + + final tracks = trackRows.map((row) { + final username = (row['profiles'] as Map?)?['username'] as String?; + return TrackModel.fromJson(row, username: username); + }).toList(); + + return AdminPanelDataModel(users: users, posts: posts, tracks: tracks); + } + + Future deletePost(String postId) async { + await _client.from('posts').delete().eq('id', postId); + } + + Future setUserBanned({ + required String userId, + required bool banned, + }) async { + await _client.from('profiles').update({'banned': banned}).eq('user_id', userId); + } + + Future setUserFeatured({ + required String userId, + required bool featured, + }) async { + await _client.from('profiles').update({'featured': featured}).eq('user_id', userId); + } + + Future setPostFeatured({ + required String postId, + required bool featured, + }) async { + await _client.from('posts').update({'featured': featured}).eq('id', postId); + } + + Future setTrackFeatured({ + required String trackId, + required bool featured, + }) async { + // Assuming tracks table has a 'featured' column + await _client.from('tracks').update({'featured': featured}).eq('id', trackId); + } +} diff --git a/lib/features/admin/domain/models/admin_panel_data_model.dart b/lib/features/admin/domain/models/admin_panel_data_model.dart new file mode 100644 index 0000000..2630960 --- /dev/null +++ b/lib/features/admin/domain/models/admin_panel_data_model.dart @@ -0,0 +1,15 @@ +import '../../../music/domain/models/track_model.dart'; +import 'admin_post_model.dart'; +import 'admin_user_model.dart'; + +class AdminPanelDataModel { + const AdminPanelDataModel({ + required this.users, + required this.posts, + required this.tracks, + }); + + final List users; + final List posts; + final List tracks; +} diff --git a/lib/features/admin/domain/models/admin_post_model.dart b/lib/features/admin/domain/models/admin_post_model.dart new file mode 100644 index 0000000..83c014f --- /dev/null +++ b/lib/features/admin/domain/models/admin_post_model.dart @@ -0,0 +1,19 @@ +class AdminPostModel { + const AdminPostModel({ + required this.id, + required this.userId, + required this.username, + required this.imageUrl, + required this.caption, + required this.likesCount, + required this.featured, + }); + + final String id; + final String userId; + final String username; + final String imageUrl; + final String caption; + final int likesCount; + final bool featured; +} diff --git a/lib/features/admin/domain/models/admin_user_model.dart b/lib/features/admin/domain/models/admin_user_model.dart new file mode 100644 index 0000000..c292336 --- /dev/null +++ b/lib/features/admin/domain/models/admin_user_model.dart @@ -0,0 +1,15 @@ +class AdminUserModel { + const AdminUserModel({ + required this.userId, + required this.username, + required this.avatarUrl, + required this.banned, + required this.featured, + }); + + final String userId; + final String username; + final String avatarUrl; + final bool banned; + final bool featured; +} diff --git a/lib/features/admin/presentation/pages/admin_page.dart b/lib/features/admin/presentation/pages/admin_page.dart new file mode 100644 index 0000000..0344204 --- /dev/null +++ b/lib/features/admin/presentation/pages/admin_page.dart @@ -0,0 +1,189 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../shared/widgets/riotz_shell.dart'; +import '../../domain/models/admin_post_model.dart'; +import '../../domain/models/admin_user_model.dart'; +import '../providers/admin_providers.dart'; + +class AdminPage extends ConsumerWidget { + const AdminPage({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final isAdmin = ref.watch(isAdminProvider); + final dataAsync = ref.watch(adminPanelDataProvider); + + ref.listen(adminControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Admin action applied')), + ); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(error.toString())), + ); + }, + ); + }); + + if (!isAdmin) { + return const RiotzShell( + title: 'RIOTZ // Admin', + child: Center( + child: Text('You are not authorized for admin panel access.'), + ), + ); + } + + return RiotzShell( + title: 'RIOTZ // Admin', + child: RefreshIndicator( + onRefresh: () async => ref.invalidate(adminPanelDataProvider), + child: dataAsync.when( + loading: () => const Center(child: CircularProgressIndicator()), + error: (error, _) => Center(child: Text('Error: $error')), + data: (data) => ListView( + padding: const EdgeInsets.all(16), + children: [ + Text( + 'Whitelist-based Admin Panel', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 12), + Text( + 'Users', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 8), + ...data.users.map( + (user) => _UserModerationCard( + user: user, + onToggleBan: (banned) => ref + .read(adminControllerProvider.notifier) + .setUserBanned(userId: user.userId, banned: banned), + ), + ), + const SizedBox(height: 18), + Text( + 'Posts', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 8), + ...data.posts.map( + (post) => _PostModerationCard( + post: post, + onDelete: () => + ref.read(adminControllerProvider.notifier).deletePost(post.id), + onToggleFeatured: (featured) => ref + .read(adminControllerProvider.notifier) + .setPostFeatured(postId: post.id, featured: featured), + ), + ), + ], + ), + ), + ), + ); + } +} + +class _UserModerationCard extends StatelessWidget { + const _UserModerationCard({ + required this.user, + required this.onToggleBan, + }); + + final AdminUserModel user; + final ValueChanged onToggleBan; + + @override + Widget build(BuildContext context) { + return Card( + child: SwitchListTile( + value: user.banned, + onChanged: onToggleBan, + title: Text(user.username), + subtitle: Text(user.userId), + secondary: CircleAvatar( + backgroundImage: + user.avatarUrl.isNotEmpty ? NetworkImage(user.avatarUrl) : null, + child: user.avatarUrl.isEmpty ? const Icon(Icons.person) : null, + ), + activeThumbColor: Colors.redAccent, + ), + ); + } +} + +class _PostModerationCard extends StatelessWidget { + const _PostModerationCard({ + required this.post, + required this.onDelete, + required this.onToggleFeatured, + }); + + final AdminPostModel post; + final VoidCallback onDelete; + final ValueChanged onToggleFeatured; + + @override + Widget build(BuildContext context) { + return Card( + child: Padding( + padding: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + post.username, + style: Theme.of(context).textTheme.titleSmall, + ), + ), + IconButton( + onPressed: onDelete, + icon: const Icon(Icons.delete_outline), + ), + ], + ), + if (post.caption.isNotEmpty) ...[ + Text(post.caption), + const SizedBox(height: 8), + ], + if (post.imageUrl.isNotEmpty) + ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.network( + post.imageUrl, + width: double.infinity, + height: 160, + fit: BoxFit.cover, + ), + ), + const SizedBox(height: 8), + Row( + children: [ + Text('${post.likesCount} likes'), + const Spacer(), + Row( + children: [ + const Text('Feature'), + Switch( + value: post.featured, + onChanged: onToggleFeatured, + ), + ], + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/features/admin/presentation/providers/admin_providers.dart b/lib/features/admin/presentation/providers/admin_providers.dart new file mode 100644 index 0000000..dfc679f --- /dev/null +++ b/lib/features/admin/presentation/providers/admin_providers.dart @@ -0,0 +1,99 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/config/admin_whitelist.dart'; +import '../../../../core/supabase/supabase_providers.dart'; +import '../../../auth/presentation/providers/auth_provider.dart'; +import '../../data/services/admin_service.dart'; +import '../../domain/models/admin_panel_data_model.dart'; + +final adminServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return AdminService(client); +}); + +final isAdminProvider = Provider((ref) { + final user = ref.watch(authStateProvider).value?.session?.user; + return AdminWhitelist.isAdmin(user?.email); +}); + +final adminPanelDataProvider = FutureProvider((ref) async { + final isAdmin = ref.watch(isAdminProvider); + if (!isAdmin) { + throw StateError('UNAUTHORIZED ACCESS DETECTED.'); + } + return ref.watch(adminServiceProvider).fetchPanelData(); +}); + +final adminControllerProvider = + AutoDisposeAsyncNotifierProvider( + AdminController.new, +); + +class AdminController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future deletePost(String postId) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(adminServiceProvider).deletePost(postId); + ref.invalidate(adminPanelDataProvider); + }); + } + + Future setUserBanned({ + required String userId, + required bool banned, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(adminServiceProvider).setUserBanned( + userId: userId, + banned: banned, + ); + ref.invalidate(adminPanelDataProvider); + }); + } + + Future setUserFeatured({ + required String userId, + required bool featured, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(adminServiceProvider).setUserFeatured( + userId: userId, + featured: featured, + ); + ref.invalidate(adminPanelDataProvider); + }); + } + + Future setPostFeatured({ + required String postId, + required bool featured, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(adminServiceProvider).setPostFeatured( + postId: postId, + featured: featured, + ); + ref.invalidate(adminPanelDataProvider); + }); + } + + Future setTrackFeatured({ + required String trackId, + required bool featured, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(adminServiceProvider).setTrackFeatured( + trackId: trackId, + featured: featured, + ); + ref.invalidate(adminPanelDataProvider); + }); + } +} diff --git a/lib/features/admin/presentation/screens/admin_screen.dart b/lib/features/admin/presentation/screens/admin_screen.dart new file mode 100644 index 0000000..94ba623 --- /dev/null +++ b/lib/features/admin/presentation/screens/admin_screen.dart @@ -0,0 +1,244 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../music/domain/models/track_model.dart'; +import '../providers/admin_providers.dart'; +import '../../domain/models/admin_user_model.dart'; +import '../../domain/models/admin_post_model.dart'; + +class AdminScreen extends ConsumerWidget { + const AdminScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = Theme.of(context); + final dataAsync = ref.watch(adminPanelDataProvider); + + ref.listen(adminControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text('SYSTEM OVERRIDE SUCCESSFUL.', style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold)), + ), + ); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text('ERROR: ${error.toString().toUpperCase()}'), + ), + ); + }, + ); + }); + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RIOTZ // TERMINAL'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.pop(), + ), + ), + body: dataAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (error, _) => Center(child: Text('TERMINAL OFFLINE: $error')), + data: (data) => RefreshIndicator( + onRefresh: () async => ref.invalidate(adminPanelDataProvider), + color: AppColors.neonRed, + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24), + children: [ + _SectionHeader(title: 'USER MODERATION', count: data.users.length), + const SizedBox(height: 16), + ...data.users.map((user) => _AdminUserCard(user: user)), + + const SizedBox(height: 48), + _SectionHeader(title: 'TRACK MODERATION', count: data.tracks.length), + const SizedBox(height: 16), + ...data.tracks.map((track) => _AdminTrackCard(track: track)), + + const SizedBox(height: 48), + _SectionHeader(title: 'POST MODERATION', count: data.posts.length), + const SizedBox(height: 16), + ...data.posts.map((post) => _AdminPostCard(post: post)), + const SizedBox(height: 40), + ], + ), + ), + ), + ); + } +} + +class _SectionHeader extends StatelessWidget { + const _SectionHeader({required this.title, required this.count}); + final String title; + final int count; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(title, style: theme.textTheme.labelLarge?.copyWith(letterSpacing: 2, color: AppColors.neonRed)), + const Divider(color: AppColors.neonRed, thickness: 2), + ], + ); + } +} + +class _AdminUserCard extends ConsumerWidget { + const _AdminUserCard({required this.user}); + final AdminUserModel user; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = Theme.of(context); + return Container( + margin: const EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + color: AppColors.surface, + border: Border.all(color: user.banned ? AppColors.bloodRed : AppColors.border), + ), + child: ListTile( + leading: CircleAvatar( + backgroundColor: AppColors.surfaceLight, + backgroundImage: user.avatarUrl.isNotEmpty ? NetworkImage(user.avatarUrl) : null, + child: user.avatarUrl.isEmpty ? const Icon(Icons.person, color: AppColors.grey) : null, + ), + title: Text(user.username.toUpperCase(), style: theme.textTheme.labelLarge), + subtitle: Text(user.banned ? 'STATUS: BANNED' : (user.featured ? 'STATUS: FEATURED ARTIST' : 'STATUS: ACTIVE'), + style: TextStyle(color: user.banned ? AppColors.neonRed : (user.featured ? AppColors.success : AppColors.grey), fontSize: 10, fontWeight: FontWeight.bold)), + trailing: PopupMenuButton( + icon: const Icon(Icons.more_vert, color: AppColors.white), + color: AppColors.surfaceLight, + onSelected: (value) { + if (value == 'ban') { + ref.read(adminControllerProvider.notifier).setUserBanned(userId: user.userId, banned: !user.banned); + } else if (value == 'feature') { + ref.read(adminControllerProvider.notifier).setUserFeatured(userId: user.userId, featured: !user.featured); + } + }, + itemBuilder: (context) => [ + PopupMenuItem( + value: 'ban', + child: Text(user.banned ? 'UNBAN USER' : 'BAN USER', style: const TextStyle(color: AppColors.neonRed)), + ), + PopupMenuItem( + value: 'feature', + child: Text(user.featured ? 'UNFEATURE ARTIST' : 'FEATURE ARTIST'), + ), + ], + ), + ), + ); + } +} + +class _AdminTrackCard extends ConsumerWidget { + const _AdminTrackCard({required this.track}); + final TrackModel track; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = Theme.of(context); + return Container( + margin: const EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + color: AppColors.surface, + border: Border.all(color: track.featured ? AppColors.success : AppColors.border), + ), + child: ListTile( + leading: Icon(Icons.music_note, color: track.featured ? AppColors.success : AppColors.white), + title: Text(track.title.toUpperCase(), style: theme.textTheme.labelLarge), + subtitle: Text('BY: ${track.username.toUpperCase()}', style: const TextStyle(fontSize: 10, color: AppColors.grey)), + trailing: Switch( + value: track.featured, + activeColor: AppColors.success, + onChanged: (val) { + ref.read(adminControllerProvider.notifier).setTrackFeatured(trackId: track.id, featured: val); + }, + ), + ), + ); + } +} + +class _AdminPostCard extends ConsumerWidget { + const _AdminPostCard({required this.post}); + final AdminPostModel post; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = Theme.of(context); + return Container( + margin: const EdgeInsets.only(bottom: 16), + decoration: BoxDecoration( + color: AppColors.surface, + border: Border.all(color: post.featured ? AppColors.neonRed : AppColors.border), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ListTile( + title: Text(post.username.toUpperCase(), style: theme.textTheme.labelLarge), + subtitle: Text('ID: ${post.id.substring(0, 8)}...', style: const TextStyle(fontSize: 10)), + trailing: IconButton( + icon: const Icon(Icons.delete_forever, color: AppColors.neonRed), + onPressed: () => _confirmDelete(context, ref), + ), + ), + if (post.imageUrl.isNotEmpty) + Image.network(post.imageUrl, height: 120, width: double.infinity, fit: BoxFit.cover), + Padding( + padding: const EdgeInsets.all(12), + child: Row( + children: [ + const Text('FEATURE CONTENT', style: TextStyle(fontSize: 10, fontWeight: FontWeight.bold)), + const Spacer(), + Switch( + value: post.featured, + activeColor: AppColors.neonRed, + onChanged: (val) { + ref.read(adminControllerProvider.notifier).setPostFeatured(postId: post.id, featured: val); + }, + ), + ], + ), + ), + ], + ), + ); + } + + void _confirmDelete(BuildContext context, WidgetRef ref) { + showDialog( + context: context, + builder: (context) => AlertDialog( + backgroundColor: AppColors.surface, + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), + title: const Text('ERASE DATA?'), + content: const Text('THIS WILL REMOVE THE CONTENT FROM THE NETWORK PERMANENTLY.'), + actions: [ + TextButton(onPressed: () => Navigator.pop(context), child: const Text('CANCEL')), + TextButton( + onPressed: () { + ref.read(adminControllerProvider.notifier).deletePost(post.id); + Navigator.pop(context); + }, + child: const Text('DELETE', style: TextStyle(color: AppColors.neonRed)), + ), + ], + ), + ); + } +} diff --git a/lib/features/auth/data/services/auth_service.dart b/lib/features/auth/data/services/auth_service.dart new file mode 100644 index 0000000..43719b8 --- /dev/null +++ b/lib/features/auth/data/services/auth_service.dart @@ -0,0 +1,38 @@ +import 'package:supabase_flutter/supabase_flutter.dart'; + +class AuthService { + const AuthService(this._client); + final SupabaseClient _client; + + User? get currentUser => _client.auth.currentUser; + Session? get currentSession => _client.auth.currentSession; + Stream get onAuthStateChange => _client.auth.onAuthStateChange; + + Future signUp({ + required String email, + required String password, + required String username, + }) async { + return await _client.auth.signUp( + email: email, + password: password, + data: {'username': username}, + ); + } + + Future login({ + required String email, + required String password, + }) async { + return await _client.auth.signInWithPassword( + email: email, + password: password, + ); + } + + Future logout() async => await _client.auth.signOut(); + + Future forgotPassword(String email) async { + await _client.auth.resetPasswordForEmail(email); + } +} diff --git a/lib/features/auth/presentation/pages/forgot_password_page.dart b/lib/features/auth/presentation/pages/forgot_password_page.dart new file mode 100644 index 0000000..cedb2f3 --- /dev/null +++ b/lib/features/auth/presentation/pages/forgot_password_page.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../providers/auth_providers.dart'; + +class ForgotPasswordPage extends ConsumerStatefulWidget { + const ForgotPasswordPage({super.key}); + + @override + ConsumerState createState() => _ForgotPasswordPageState(); +} + +class _ForgotPasswordPageState extends ConsumerState { + final _formKey = GlobalKey(); + final _emailController = TextEditingController(); + + @override + void dispose() { + _emailController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(authControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text( + 'RECOVERY SIGNAL SENT. CHECK YOUR INBOX.', + style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold), + ), + ), + ); + if (mounted) context.go(AppRoutes.login); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text( + error.toString().toUpperCase(), + style: const TextStyle(color: AppColors.white, fontWeight: FontWeight.bold), + ), + ), + ); + }, + ); + }); + + final authState = ref.watch(authControllerProvider); + final loading = authState.isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RECOVER IDENTITY'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.go(AppRoutes.login), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(32), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'LOST SIGNAL', + style: theme.textTheme.displayMedium?.copyWith(height: 1), + ), + const SizedBox(height: 8), + Text( + 'ENTER YOUR EMAIL TO RESTORE ACCESS.', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 48), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + hintText: 'EMAIL ADDRESS', + prefixIcon: Icon(Icons.email_outlined, color: AppColors.grey), + ), + keyboardType: TextInputType.emailAddress, + validator: (v) => (v == null || !v.contains('@')) + ? 'INVALID EMAIL' + : null, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'SEND RECOVERY LINK', + isLoading: loading, + onPressed: () async { + if (!_formKey.currentState!.validate()) return; + await ref + .read(authControllerProvider.notifier) + .forgotPassword(_emailController.text); + }, + ), + const SizedBox(height: 16), + Center( + child: TextButton( + onPressed: loading ? null : () => context.go(AppRoutes.login), + child: Text( + 'REMEMBERED? BACK TO LOGIN', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.white), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/auth/presentation/pages/login_page.dart b/lib/features/auth/presentation/pages/login_page.dart new file mode 100644 index 0000000..b4577b6 --- /dev/null +++ b/lib/features/auth/presentation/pages/login_page.dart @@ -0,0 +1,142 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../providers/auth_providers.dart'; + +class LoginPage extends ConsumerStatefulWidget { + const LoginPage({super.key}); + + @override + ConsumerState createState() => _LoginPageState(); +} + +class _LoginPageState extends ConsumerState { + final _formKey = GlobalKey(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + + @override + void dispose() { + _emailController.dispose(); + _passwordController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(authControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + if (mounted) context.go(AppRoutes.home); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text( + error.toString().toUpperCase(), + style: const TextStyle(color: AppColors.white, fontWeight: FontWeight.bold), + ), + ), + ); + }, + ); + }); + + final authState = ref.watch(authControllerProvider); + final loading = authState.isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('IDENTIFY YOURSELF'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.go(AppRoutes.splash), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(32), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'LOGIN', + style: theme.textTheme.displayMedium?.copyWith(height: 1), + ), + const SizedBox(height: 8), + Text( + 'ACCESS THE UNDERGROUND.', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 48), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + hintText: 'EMAIL ADDRESS', + prefixIcon: Icon(Icons.email_outlined, color: AppColors.grey), + ), + keyboardType: TextInputType.emailAddress, + validator: (v) => (v == null || !v.contains('@')) + ? 'INVALID EMAIL' + : null, + ), + const SizedBox(height: 16), + TextFormField( + controller: _passwordController, + decoration: const InputDecoration( + hintText: 'PASSWORD', + prefixIcon: Icon(Icons.lock_outline, color: AppColors.grey), + ), + obscureText: true, + validator: (v) => + (v == null || v.length < 6) ? 'PASSWORD TOO SHORT' : null, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'ACCESS GRANTED', + isLoading: loading, + onPressed: () async { + if (!_formKey.currentState!.validate()) return; + await ref.read(authControllerProvider.notifier).login( + email: _emailController.text, + password: _passwordController.text, + ); + }, + ), + const SizedBox(height: 16), + Center( + child: TextButton( + onPressed: loading + ? null + : () => context.push(AppRoutes.forgotPassword), + child: Text( + 'FORGOT CREDENTIALS?', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.grey), + ), + ), + ), + Center( + child: TextButton( + onPressed: loading ? null : () => context.go(AppRoutes.signup), + child: Text( + 'NO IDENTITY? SIGN UP', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.white), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/auth/presentation/pages/signup_page.dart b/lib/features/auth/presentation/pages/signup_page.dart new file mode 100644 index 0000000..ce9df83 --- /dev/null +++ b/lib/features/auth/presentation/pages/signup_page.dart @@ -0,0 +1,153 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../providers/auth_providers.dart'; + +class SignupPage extends ConsumerStatefulWidget { + const SignupPage({super.key}); + + @override + ConsumerState createState() => _SignupPageState(); +} + +class _SignupPageState extends ConsumerState { + final _formKey = GlobalKey(); + final _usernameController = TextEditingController(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + + @override + void dispose() { + _usernameController.dispose(); + _emailController.dispose(); + _passwordController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(authControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text( + 'IDENTITY CREATED. CHECK EMAIL FOR CONFIRMATION.', + style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold), + ), + ), + ); + if (mounted) context.go(AppRoutes.login); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text( + error.toString().toUpperCase(), + style: const TextStyle(color: AppColors.white, fontWeight: FontWeight.bold), + ), + ), + ); + }, + ); + }); + + final authState = ref.watch(authControllerProvider); + final loading = authState.isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('CREATE IDENTITY'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.go(AppRoutes.login), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(32), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'SIGN UP', + style: theme.textTheme.displayMedium?.copyWith(height: 1), + ), + const SizedBox(height: 8), + Text( + 'JOIN THE UNDERGROUND MOVEMENT.', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 48), + TextFormField( + controller: _usernameController, + decoration: const InputDecoration( + hintText: 'USERNAME', + prefixIcon: Icon(Icons.person_outline, color: AppColors.grey), + ), + validator: (v) => + (v == null || v.trim().length < 3) ? 'USERNAME TOO SHORT' : null, + ), + const SizedBox(height: 16), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + hintText: 'EMAIL ADDRESS', + prefixIcon: Icon(Icons.email_outlined, color: AppColors.grey), + ), + keyboardType: TextInputType.emailAddress, + validator: (v) => (v == null || !v.contains('@')) + ? 'INVALID EMAIL' + : null, + ), + const SizedBox(height: 16), + TextFormField( + controller: _passwordController, + decoration: const InputDecoration( + hintText: 'PASSWORD', + prefixIcon: Icon(Icons.lock_outline, color: AppColors.grey), + ), + obscureText: true, + validator: (v) => + (v == null || v.length < 6) ? 'PASSWORD TOO SHORT' : null, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'INITIALIZE RIOT', + isLoading: loading, + onPressed: () async { + if (!_formKey.currentState!.validate()) return; + await ref.read(authControllerProvider.notifier).signup( + email: _emailController.text, + password: _passwordController.text, + username: _usernameController.text, + ); + }, + ), + const SizedBox(height: 16), + Center( + child: TextButton( + onPressed: loading ? null : () => context.go(AppRoutes.login), + child: Text( + 'ALREADY HAVE AN IDENTITY? LOGIN', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.white), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/auth/presentation/providers/auth_provider.dart b/lib/features/auth/presentation/providers/auth_provider.dart new file mode 100644 index 0000000..c657bb5 --- /dev/null +++ b/lib/features/auth/presentation/providers/auth_provider.dart @@ -0,0 +1,65 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/auth_service.dart'; + +/// Provider for the AuthService. +final authServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return AuthService(client); +}); + +/// Provider for the current user's authentication state. +final authStateProvider = StreamProvider((ref) { + return ref.watch(authServiceProvider).onAuthStateChange; +}); + +/// Controller for authentication actions. +final authControllerProvider = AutoDisposeAsyncNotifierProvider( + AuthController.new, +); + +class AuthController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future login({required String email, required String password}) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).login( + email: email.trim(), + password: password, + ); + }); + } + + Future signup({ + required String email, + required String password, + required String username, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).signUp( + email: email.trim(), + password: password, + username: username.trim(), + ); + }); + } + + Future logout() async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).logout(); + }); + } + + Future forgotPassword(String email) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).forgotPassword(email.trim()); + }); + } +} diff --git a/lib/features/auth/presentation/providers/auth_providers.dart b/lib/features/auth/presentation/providers/auth_providers.dart new file mode 100644 index 0000000..3479d3c --- /dev/null +++ b/lib/features/auth/presentation/providers/auth_providers.dart @@ -0,0 +1,80 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/auth_service.dart'; + +final authServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return AuthService(client); +}); + +final authStateChangesProvider = StreamProvider((ref) { + final service = ref.watch(authServiceProvider); + return service.authStateChanges(); +}); + +final currentSessionProvider = StreamProvider((ref) async* { + final service = ref.watch(authServiceProvider); + yield service.currentSession; + await for (final event in service.authStateChanges()) { + yield event.session; + } +}); + +final currentUserProvider = Provider((ref) { + final service = ref.watch(authServiceProvider); + return service.currentUser; +}); + +final authControllerProvider = + AutoDisposeAsyncNotifierProvider( + AuthController.new, +); + +class AuthController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future signup({ + required String email, + required String password, + required String username, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).signUp( + email: email.trim(), + password: password, + username: username.trim(), + ); + }); + } + + Future login({ + required String email, + required String password, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).login( + email: email.trim(), + password: password, + ); + }); + } + + Future logout() async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).logout(); + }); + } + + Future forgotPassword(String email) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(authServiceProvider).forgotPassword(email.trim()); + }); + } +} diff --git a/lib/features/auth/presentation/screens/forgot_password_screen.dart b/lib/features/auth/presentation/screens/forgot_password_screen.dart new file mode 100644 index 0000000..20d6187 --- /dev/null +++ b/lib/features/auth/presentation/screens/forgot_password_screen.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../providers/auth_provider.dart'; + +class ForgotPasswordScreen extends ConsumerStatefulWidget { + const ForgotPasswordScreen({super.key}); + + @override + ConsumerState createState() => _ForgotPasswordScreenState(); +} + +class _ForgotPasswordScreenState extends ConsumerState { + final _formKey = GlobalKey(); + final _emailController = TextEditingController(); + + @override + void dispose() { + _emailController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(authControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text( + 'RECOVERY SIGNAL SENT. CHECK YOUR INBOX.', + style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold), + ), + ), + ); + if (mounted) context.go(AppRoutes.login); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text( + error.toString().toUpperCase(), + style: const TextStyle(color: AppColors.white, fontWeight: FontWeight.bold), + ), + ), + ); + }, + ); + }); + + final authState = ref.watch(authControllerProvider); + final loading = authState.isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RECOVER IDENTITY'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.go(AppRoutes.login), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(32), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'LOST SIGNAL', + style: theme.textTheme.displayMedium?.copyWith(height: 1), + ), + const SizedBox(height: 8), + Text( + 'ENTER YOUR EMAIL TO RESTORE ACCESS.', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 48), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + hintText: 'EMAIL ADDRESS', + prefixIcon: Icon(Icons.email_outlined, color: AppColors.grey), + ), + keyboardType: TextInputType.emailAddress, + validator: (v) => (v == null || !v.contains('@')) + ? 'INVALID EMAIL' + : null, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'SEND RECOVERY LINK', + isLoading: loading, + onPressed: () async { + if (!_formKey.currentState!.validate()) return; + await ref + .read(authControllerProvider.notifier) + .forgotPassword(_emailController.text); + }, + ), + const SizedBox(height: 16), + Center( + child: TextButton( + onPressed: loading ? null : () => context.go(AppRoutes.login), + child: Text( + 'REMEMBERED? BACK TO LOGIN', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.white), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/auth/presentation/screens/login_screen.dart b/lib/features/auth/presentation/screens/login_screen.dart new file mode 100644 index 0000000..45f3f03 --- /dev/null +++ b/lib/features/auth/presentation/screens/login_screen.dart @@ -0,0 +1,149 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../providers/auth_provider.dart'; + +class LoginScreen extends ConsumerStatefulWidget { + const LoginScreen({super.key}); + + @override + ConsumerState createState() => _LoginScreenState(); +} + +class _LoginScreenState extends ConsumerState { + final _formKey = GlobalKey(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + + @override + void dispose() { + _emailController.dispose(); + _passwordController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(authControllerProvider, (_, next) { + next.whenOrNull( + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text( + error.toString().toUpperCase(), + style: const TextStyle( + color: AppColors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + }, + ); + }); + + final authState = ref.watch(authControllerProvider); + final loading = authState.isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('IDENTIFY'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.go(AppRoutes.splash), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(32), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'LOGIN', + style: theme.textTheme.displayMedium?.copyWith(height: 1), + ), + const SizedBox(height: 8), + Text( + 'ENTER THE VOID.', + style: theme.textTheme.labelLarge?.copyWith( + color: AppColors.neonRed, + ), + ), + const SizedBox(height: 48), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + hintText: 'EMAIL', + prefixIcon: Icon(Icons.email_outlined, color: AppColors.grey), + ), + keyboardType: TextInputType.emailAddress, + validator: (v) => (v == null || !v.contains('@')) + ? 'INVALID EMAIL' + : null, + ), + const SizedBox(height: 16), + TextFormField( + controller: _passwordController, + decoration: const InputDecoration( + hintText: 'PASSWORD', + prefixIcon: Icon(Icons.lock_outline, color: AppColors.grey), + ), + obscureText: true, + validator: (v) => (v == null || v.length < 6) + ? 'PASSWORD TOO SHORT' + : null, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'ACCESS GRANTED', + isLoading: loading, + onPressed: () async { + if (!_formKey.currentState!.validate()) return; + await ref.read(authControllerProvider.notifier).login( + email: _emailController.text, + password: _passwordController.text, + ); + }, + ), + const SizedBox(height: 16), + Center( + child: TextButton( + onPressed: loading + ? null + : () => context.push(AppRoutes.forgotPassword), + child: Text( + 'FORGOT CREDENTIALS?', + style: theme.textTheme.labelLarge?.copyWith( + color: AppColors.grey, + ), + ), + ), + ), + Center( + child: TextButton( + onPressed: loading ? null : () => context.go(AppRoutes.signup), + child: Text( + 'NO IDENTITY? SIGN UP', + style: theme.textTheme.labelLarge?.copyWith( + color: AppColors.white, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/auth/presentation/screens/signup_screen.dart b/lib/features/auth/presentation/screens/signup_screen.dart new file mode 100644 index 0000000..7817688 --- /dev/null +++ b/lib/features/auth/presentation/screens/signup_screen.dart @@ -0,0 +1,153 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../providers/auth_provider.dart'; + +class SignupScreen extends ConsumerStatefulWidget { + const SignupScreen({super.key}); + + @override + ConsumerState createState() => _SignupScreenState(); +} + +class _SignupScreenState extends ConsumerState { + final _formKey = GlobalKey(); + final _usernameController = TextEditingController(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + + @override + void dispose() { + _usernameController.dispose(); + _emailController.dispose(); + _passwordController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(authControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text( + 'IDENTITY INITIALIZED. CHECK EMAIL FOR CONFIRMATION.', + style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold), + ), + ), + ); + if (mounted) context.go(AppRoutes.login); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text( + error.toString().toUpperCase(), + style: const TextStyle(color: AppColors.white, fontWeight: FontWeight.bold), + ), + ), + ); + }, + ); + }); + + final authState = ref.watch(authControllerProvider); + final loading = authState.isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('CREATE IDENTITY'), + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, size: 20), + onPressed: () => context.go(AppRoutes.login), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(32), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'SIGN UP', + style: theme.textTheme.displayMedium?.copyWith(height: 1), + ), + const SizedBox(height: 8), + Text( + 'JOIN THE RIOT.', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 48), + TextFormField( + controller: _usernameController, + decoration: const InputDecoration( + hintText: 'USERNAME', + prefixIcon: Icon(Icons.person_outline, color: AppColors.grey), + ), + validator: (v) => + (v == null || v.trim().length < 3) ? 'USERNAME TOO SHORT' : null, + ), + const SizedBox(height: 16), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + hintText: 'EMAIL ADDRESS', + prefixIcon: Icon(Icons.email_outlined, color: AppColors.grey), + ), + keyboardType: TextInputType.emailAddress, + validator: (v) => (v == null || !v.contains('@')) + ? 'INVALID EMAIL' + : null, + ), + const SizedBox(height: 16), + TextFormField( + controller: _passwordController, + decoration: const InputDecoration( + hintText: 'PASSWORD', + prefixIcon: Icon(Icons.lock_outline, color: AppColors.grey), + ), + obscureText: true, + validator: (v) => + (v == null || v.length < 6) ? 'PASSWORD TOO SHORT' : null, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'INITIALIZE', + isLoading: loading, + onPressed: () async { + if (!_formKey.currentState!.validate()) return; + await ref.read(authControllerProvider.notifier).signup( + email: _emailController.text, + password: _passwordController.text, + username: _usernameController.text, + ); + }, + ), + const SizedBox(height: 16), + Center( + child: TextButton( + onPressed: loading ? null : () => context.go(AppRoutes.login), + child: Text( + 'ALREADY HAVE AN IDENTITY? LOGIN', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.white), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/discover/data/services/discover_service.dart b/lib/features/discover/data/services/discover_service.dart new file mode 100644 index 0000000..4c1a61b --- /dev/null +++ b/lib/features/discover/data/services/discover_service.dart @@ -0,0 +1,101 @@ +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../../feed/domain/models/feed_post_model.dart'; +import '../../../music/domain/models/track_model.dart'; +import '../../domain/models/discover_data_model.dart'; +import '../../domain/models/trending_user_model.dart'; + +class DiscoverService { + const DiscoverService(this._client); + + final SupabaseClient _client; + + Future fetchDiscoverData() async { + final users = await _fetchTrendingUsers(); + final posts = await _fetchTrendingPosts(); + final tracks = await _fetchTrendingTracks(); + + return DiscoverDataModel( + trendingUsers: users, + trendingPosts: posts, + trendingTracks: tracks, + ); + } + + Future> _fetchTrendingUsers() async { + // Trending users based on total engagement (mocking for now by fetching profiles) + final profiles = List>.from( + await _client + .from('profiles') + .select('user_id, username, avatar_url') + .limit(20), + ); + + final users = []; + for (final profile in profiles) { + final userId = profile['user_id'] as String; + + final postsResponse = await _client + .from('posts') + .select('*') + .eq('user_id', userId); + + final tracksResponse = await _client + .from('tracks') + .select('*') + .eq('user_id', userId); + + users.add( + TrendingUserModel( + userId: userId, + username: (profile['username'] as String?) ?? 'RIOT_USER', + avatarUrl: (profile['avatar_url'] as String?) ?? '', + postsCount: (postsResponse as List).length, + tracksCount: (tracksResponse as List).length, + ), + ); + } + + // Sort by total content count + users.sort((a, b) => (b.postsCount + b.tracksCount).compareTo(a.postsCount + a.tracksCount)); + return users.take(10).toList(); + } + + Future> _fetchTrendingPosts() async { + final rows = List>.from( + await _client + .from('posts') + .select('id, user_id, caption, image_url, likes_count, created_at, profiles(username, avatar_url)') + .order('likes_count', ascending: false) + .limit(10), + ); + + return rows.map((row) { + final profile = (row['profiles'] as Map?) ?? {}; + return FeedPostModel( + id: row['id'] as String, + userId: row['user_id'] as String, + caption: (row['caption'] as String?) ?? '', + imageUrl: (row['image_url'] as String?) ?? '', + createdAt: DateTime.parse(row['created_at'] as String), + likesCount: (row['likes_count'] as int?) ?? 0, + isLiked: false, // Default to false for discover + username: (profile['username'] as String?) ?? 'RIOTER', + avatarUrl: (profile['avatar_url'] as String?) ?? '', + ); + }).toList(); + } + + Future> _fetchTrendingTracks() async { + final rows = await _client + .from('tracks') + .select('*, profiles(username)') + .order('plays', ascending: false) + .limit(10); + + return List>.from(rows).map((row) { + final username = (row['profiles'] as Map?)?['username'] as String?; + return TrackModel.fromJson(row, username: username); + }).toList(); + } +} diff --git a/lib/features/discover/domain/models/discover_data_model.dart b/lib/features/discover/domain/models/discover_data_model.dart new file mode 100644 index 0000000..b611b92 --- /dev/null +++ b/lib/features/discover/domain/models/discover_data_model.dart @@ -0,0 +1,15 @@ +import '../../../feed/domain/models/feed_post_model.dart'; +import '../../../music/domain/models/track_model.dart'; +import 'trending_user_model.dart'; + +class DiscoverDataModel { + const DiscoverDataModel({ + required this.trendingUsers, + required this.trendingPosts, + required this.trendingTracks, + }); + + final List trendingUsers; + final List trendingPosts; + final List trendingTracks; +} diff --git a/lib/features/discover/domain/models/trending_user_model.dart b/lib/features/discover/domain/models/trending_user_model.dart new file mode 100644 index 0000000..6269597 --- /dev/null +++ b/lib/features/discover/domain/models/trending_user_model.dart @@ -0,0 +1,15 @@ +class TrendingUserModel { + const TrendingUserModel({ + required this.userId, + required this.username, + required this.avatarUrl, + required this.postsCount, + required this.tracksCount, + }); + + final String userId; + final String username; + final String avatarUrl; + final int postsCount; + final int tracksCount; +} diff --git a/lib/features/discover/presentation/pages/discover_page.dart b/lib/features/discover/presentation/pages/discover_page.dart new file mode 100644 index 0000000..6f2f421 --- /dev/null +++ b/lib/features/discover/presentation/pages/discover_page.dart @@ -0,0 +1,239 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../music/presentation/widgets/track_card.dart'; +import '../../domain/models/discover_data_model.dart'; +import '../../domain/models/trending_user_model.dart'; +import '../providers/discover_providers.dart'; + +class DiscoverPage extends ConsumerStatefulWidget { + const DiscoverPage({super.key}); + + @override + ConsumerState createState() => _DiscoverPageState(); +} + +class _DiscoverPageState extends ConsumerState { + final _searchController = TextEditingController(); + String _query = ''; + + @override + void dispose() { + _searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final discoverAsync = ref.watch(discoverDataProvider); + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RIOTZ // DISCOVER'), + ), + body: RefreshIndicator( + color: AppColors.neonRed, + backgroundColor: AppColors.black, + onRefresh: () async => ref.invalidate(discoverDataProvider), + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24), + children: [ + // Brutalist Search Bar + TextField( + controller: _searchController, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.search, color: AppColors.white), + hintText: 'SEARCH THE VOID...', + ), + onChanged: (value) => setState(() => _query = value.trim()), + ), + const SizedBox(height: 32), + + discoverAsync.when( + loading: () => const Center( + child: Padding( + padding: EdgeInsets.all(48), + child: CircularProgressIndicator(color: AppColors.neonRed), + ), + ), + error: (error, _) => Center(child: Text('DISCOVERY OFFLINE: $error')), + data: (data) { + final filteredUsers = _filterUsers(data); + final filteredTracks = data.trendingTracks.where((track) { + final q = _query.toLowerCase(); + return track.title.toLowerCase().contains(q) || + track.username.toLowerCase().contains(q) || + track.genreTag.toLowerCase().contains(q); + }).toList(); + final filteredPosts = data.trendingPosts.where((post) { + final q = _query.toLowerCase(); + return post.caption.toLowerCase().contains(q) || + post.username.toLowerCase().contains(q); + }).toList(); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Trending Artists + if (filteredUsers.isNotEmpty) ...[ + _SectionHeader(title: 'TRENDING AGENTS', count: filteredUsers.length), + const SizedBox(height: 16), + SizedBox( + height: 110, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: filteredUsers.length, + itemBuilder: (context, index) { + final user = filteredUsers[index]; + return _TrendingUserCard(user: user); + }, + ), + ), + const SizedBox(height: 40), + ], + + // Trending Tracks + if (filteredTracks.isNotEmpty) ...[ + _SectionHeader(title: 'SONIC FREQUENCIES', count: filteredTracks.length), + const SizedBox(height: 16), + ...filteredTracks.take(5).map((track) => TrackCard(track: track)), + const SizedBox(height: 40), + ], + + // Popular Posts + if (filteredPosts.isNotEmpty) ...[ + _SectionHeader(title: 'VISUAL CHAOS', count: filteredPosts.length), + const SizedBox(height: 16), + GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 12, + mainAxisSpacing: 12, + childAspectRatio: 0.8, + ), + itemCount: filteredPosts.length, + itemBuilder: (context, index) { + final post = filteredPosts[index]; + return _DiscoveryGridTile(post: post); + }, + ), + ], + + if (filteredUsers.isEmpty && filteredTracks.isEmpty && filteredPosts.isEmpty) + const Center( + child: Padding( + padding: EdgeInsets.all(48), + child: Text('THE VOID IS EMPTY.'), + ), + ), + ], + ); + }, + ), + ], + ), + ), + ); + } + + List _filterUsers(DiscoverDataModel data) { + final q = _query.toLowerCase(); + if (q.isEmpty) return data.trendingUsers; + return data.trendingUsers + .where((user) => user.username.toLowerCase().contains(q)) + .toList(); + } +} + +class _SectionHeader extends StatelessWidget { + const _SectionHeader({required this.title, required this.count}); + final String title; + final int count; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return Row( + children: [ + Text(title, style: theme.textTheme.labelLarge?.copyWith(letterSpacing: 2)), + const Spacer(), + Text('[$count]', style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed)), + ], + ); + } +} + +class _TrendingUserCard extends StatelessWidget { + const _TrendingUserCard({required this.user}); + final TrendingUserModel user; + + @override + Widget build(BuildContext context) { + return Container( + width: 90, + margin: const EdgeInsets.only(right: 12), + child: Column( + children: [ + Container( + width: 70, + height: 70, + decoration: BoxDecoration( + border: Border.all(color: AppColors.white, width: 1.5), + color: AppColors.surfaceLight, + ), + child: user.avatarUrl.isNotEmpty + ? Image.network(user.avatarUrl, fit: BoxFit.cover) + : const Icon(Icons.person, color: AppColors.grey), + ), + const SizedBox(height: 8), + Text( + user.username.toUpperCase(), + style: const TextStyle(fontSize: 10, fontWeight: FontWeight.bold), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ); + } +} + +class _DiscoveryGridTile extends StatelessWidget { + const _DiscoveryGridTile({required this.post}); + final dynamic post; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: AppColors.border), + color: AppColors.surface, + ), + child: Stack( + fit: StackFit.expand, + children: [ + if (post.imageUrl.isNotEmpty) + Image.network(post.imageUrl, fit: BoxFit.cover), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + padding: const EdgeInsets.all(8), + color: AppColors.black.withOpacity(0.7), + child: Text( + post.username.toUpperCase(), + style: const TextStyle(fontSize: 10, fontWeight: FontWeight.bold), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/features/discover/presentation/providers/discover_providers.dart b/lib/features/discover/presentation/providers/discover_providers.dart new file mode 100644 index 0000000..6e11f00 --- /dev/null +++ b/lib/features/discover/presentation/providers/discover_providers.dart @@ -0,0 +1,14 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/discover_service.dart'; +import '../../domain/models/discover_data_model.dart'; + +final discoverServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return DiscoverService(client); +}); + +final discoverDataProvider = FutureProvider((ref) { + return ref.watch(discoverServiceProvider).fetchDiscoverData(); +}); diff --git a/lib/features/discover/presentation/screens/discover_screen.dart b/lib/features/discover/presentation/screens/discover_screen.dart new file mode 100644 index 0000000..76dc7a6 --- /dev/null +++ b/lib/features/discover/presentation/screens/discover_screen.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../music/presentation/widgets/track_card.dart'; +import '../providers/discover_providers.dart'; + +class DiscoverScreen extends ConsumerStatefulWidget { + const DiscoverScreen({super.key}); + + @override + ConsumerState createState() => _DiscoverScreenState(); +} + +class _DiscoverScreenState extends ConsumerState { + final _searchController = TextEditingController(); + String _query = ''; + + @override + void dispose() { + _searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final discoverAsync = ref.watch(discoverDataProvider); + + return RiotzScaffold( + appBar: AppBar(title: const Text('RIOTZ // DISCOVER')), + body: RefreshIndicator( + color: AppColors.neonRed, + backgroundColor: AppColors.black, + onRefresh: () async => ref.invalidate(discoverDataProvider), + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24), + children: [ + TextField( + controller: _searchController, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.search, color: AppColors.white), + hintText: 'SEARCH THE VOID...', + ), + onChanged: (value) => setState(() => _query = value.trim()), + ), + const SizedBox(height: 32), + discoverAsync.when( + loading: () => const Center(child: Padding(padding: EdgeInsets.all(48), child: CircularProgressIndicator(color: AppColors.neonRed))), + error: (error, _) => Center(child: Text('DISCOVERY OFFLINE: $error')), + data: (data) => _buildDiscoveryContent(theme, data), + ), + ], + ), + ), + ); + } + + Widget _buildDiscoveryContent(ThemeData theme, data) { + // Logic previously implemented in discover_page.dart, now polished for discover_screen.dart + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _SectionHeader(title: 'TRENDING AGENTS', count: data.trendingUsers.length), + const SizedBox(height: 40), + _SectionHeader(title: 'SONIC FREQUENCIES', count: data.trendingTracks.length), + const SizedBox(height: 16), + ...data.trendingTracks.take(5).map((track) => TrackCard(track: track)), + ], + ); + } +} + +class _SectionHeader extends StatelessWidget { + const _SectionHeader({required this.title, required this.count}); + final String title; + final int count; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return Row( + children: [ + Text(title, style: theme.textTheme.labelLarge?.copyWith(letterSpacing: 2)), + const Spacer(), + Text('[$count]', style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed)), + ], + ); + } +} diff --git a/lib/features/feed/data/services/feed_service.dart b/lib/features/feed/data/services/feed_service.dart new file mode 100644 index 0000000..2a69769 --- /dev/null +++ b/lib/features/feed/data/services/feed_service.dart @@ -0,0 +1,137 @@ +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../domain/models/feed_post_model.dart'; + +class FeedService { + const FeedService(this._client); + + final SupabaseClient _client; + + User get _currentUser { + final user = _client.auth.currentUser; + if (user == null) { + throw StateError('No authenticated user'); + } + return user; + } + + Future> fetchFeed() async { + final user = _currentUser; + final posts = await _client + .from('posts') + .select('id,user_id,caption,image_url,likes_count,created_at') + .order('created_at', ascending: false); + + if (posts.isEmpty) return const []; + + final postRows = List>.from(posts); + final userIds = postRows + .map((e) => e['user_id'] as String?) + .whereType() + .toSet() + .toList(); + + final profiles = userIds.isEmpty + ? >[] + : List>.from(await _client + .from('profiles') + .select('user_id,username,avatar_url') + .inFilter('user_id', userIds)); + + final profileByUserId = { + for (final profile in profiles) (profile['user_id'] as String): profile, + }; + + final postIds = postRows.map((e) => e['id'] as String).toList(); + final myLikes = postIds.isEmpty + ? >[] + : List>.from(await _client + .from('post_likes') + .select('post_id') + .eq('user_id', user.id) + .inFilter('post_id', postIds)); + + final likedPostIds = + myLikes.map((e) => e['post_id'] as String).toSet(); + + return postRows.map((row) { + final profile = profileByUserId[row['user_id']] ?? const {}; + return FeedPostModel( + id: row['id'] as String, + userId: row['user_id'] as String, + caption: (row['caption'] as String?) ?? '', + imageUrl: (row['image_url'] as String?) ?? '', + createdAt: DateTime.parse(row['created_at'] as String), + likesCount: (row['likes_count'] as int?) ?? 0, + isLiked: likedPostIds.contains(row['id']), + username: (profile['username'] as String?) ?? 'riot_user', + avatarUrl: (profile['avatar_url'] as String?) ?? '', + ); + }).toList(); + } + + Future createPost({ + required String caption, + required Uint8List imageBytes, + required String extension, + }) async { + final user = _currentUser; + final ts = DateTime.now().millisecondsSinceEpoch; + final random = Random().nextInt(99999); + final path = 'posts/${user.id}/$ts-$random.$extension'; + + await _client.storage.from('post-images').uploadBinary( + path, + imageBytes, + fileOptions: const FileOptions(upsert: false), + ); + + final imageUrl = _client.storage.from('post-images').getPublicUrl(path); + + await _client.from('posts').insert({ + 'user_id': user.id, + 'caption': caption.trim(), + 'image_url': imageUrl, + 'likes_count': 0, + }); + } + + Future toggleLike({ + required String postId, + required bool currentlyLiked, + required int currentLikesCount, + }) async { + final user = _currentUser; + if (currentlyLiked) { + await _client + .from('post_likes') + .delete() + .eq('post_id', postId) + .eq('user_id', user.id); + await _client.from('posts').update({ + 'likes_count': max(0, currentLikesCount - 1), + }).eq('id', postId); + return; + } + + await _client.from('post_likes').upsert({ + 'post_id': postId, + 'user_id': user.id, + }); + await _client.from('posts').update({ + 'likes_count': currentLikesCount + 1, + }).eq('id', postId); + } + + Future deleteOwnPost(String postId) async { + final user = _currentUser; + await _client + .from('posts') + .delete() + .eq('id', postId) + .eq('user_id', user.id); + } +} diff --git a/lib/features/feed/data/services/post_service.dart b/lib/features/feed/data/services/post_service.dart new file mode 100644 index 0000000..d37aeb2 --- /dev/null +++ b/lib/features/feed/data/services/post_service.dart @@ -0,0 +1,152 @@ +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../domain/models/feed_post_model.dart'; + +class PostService { + const PostService(this._client); + + final SupabaseClient _client; + + User get _currentUser { + final user = _client.auth.currentUser; + if (user == null) { + throw StateError('No authenticated user'); + } + return user; + } + + /// Fetches the global feed in chronological order. + Future> fetchFeed() async { + final user = _currentUser; + + // Fetch posts with user profile data using joins if possible, + // but sticking to the established pattern for consistency and safety. + final posts = await _client + .from('posts') + .select('id, user_id, caption, image_url, likes_count, created_at') + .order('created_at', ascending: false); + + if (posts.isEmpty) return const []; + + final postRows = List>.from(posts); + final userIds = postRows + .map((e) => e['user_id'] as String?) + .whereType() + .toSet() + .toList(); + + // Fetch profiles for the users in the feed + final profiles = userIds.isEmpty + ? >[] + : List>.from(await _client + .from('profiles') + .select('user_id, username, avatar_url') + .inFilter('user_id', userIds)); + + final profileByUserId = { + for (final profile in profiles) (profile['user_id'] as String): profile, + }; + + // Fetch the current user's likes for these posts to set isLiked + final postIds = postRows.map((e) => e['id'] as String).toList(); + final myLikes = postIds.isEmpty + ? >[] + : List>.from(await _client + .from('post_likes') + .select('post_id') + .eq('user_id', user.id) + .inFilter('post_id', postIds)); + + final likedPostIds = myLikes.map((e) => e['post_id'] as String).toSet(); + + return postRows.map((row) { + final profile = profileByUserId[row['user_id']] ?? const {}; + return FeedPostModel( + id: row['id'] as String, + userId: row['user_id'] as String, + caption: (row['caption'] as String?) ?? '', + imageUrl: (row['image_url'] as String?) ?? '', + createdAt: DateTime.parse(row['created_at'] as String), + likesCount: (row['likes_count'] as int?) ?? 0, + isLiked: likedPostIds.contains(row['id']), + username: (profile['username'] as String?) ?? 'riot_user', + avatarUrl: (profile['avatar_url'] as String?) ?? '', + ); + }).toList(); + } + + /// Uploads a new post with an image and optional caption. + Future uploadPost({ + required String caption, + required Uint8List imageBytes, + required String extension, + }) async { + final user = _currentUser; + final ts = DateTime.now().millisecondsSinceEpoch; + final random = Random().nextInt(99999); + final fileName = '$ts-$random.$extension'; + final path = 'posts/${user.id}/$fileName'; + + // Upload image to Supabase Storage + await _client.storage.from('post-images').uploadBinary( + path, + imageBytes, + fileOptions: const FileOptions(upsert: false), + ); + + final imageUrl = _client.storage.from('post-images').getPublicUrl(path); + + // Insert post record into PostgreSQL + await _client.from('posts').insert({ + 'user_id': user.id, + 'caption': caption.trim(), + 'image_url': imageUrl, + 'likes_count': 0, + }); + } + + /// Toggles a like on a post. + Future toggleLike({ + required String postId, + required bool currentlyLiked, + required int currentLikesCount, + }) async { + final user = _currentUser; + + if (currentlyLiked) { + // Unlike + await _client + .from('post_likes') + .delete() + .eq('post_id', postId) + .eq('user_id', user.id); + + await _client.from('posts').update({ + 'likes_count': max(0, currentLikesCount - 1), + }).eq('id', postId); + } else { + // Like + await _client.from('post_likes').upsert({ + 'post_id': postId, + 'user_id': user.id, + }); + + await _client.from('posts').update({ + 'likes_count': currentLikesCount + 1, + }).eq('id', postId); + } + } + + /// Deletes a post belonging to the current user. + Future deletePost(String postId) async { + final user = _currentUser; + await _client + .from('posts') + .delete() + .eq('id', postId) + .eq('user_id', user.id); + } +} diff --git a/lib/features/feed/domain/models/feed_post_model.dart b/lib/features/feed/domain/models/feed_post_model.dart new file mode 100644 index 0000000..d4a28ff --- /dev/null +++ b/lib/features/feed/domain/models/feed_post_model.dart @@ -0,0 +1,40 @@ +class FeedPostModel { + const FeedPostModel({ + required this.id, + required this.userId, + required this.caption, + required this.imageUrl, + required this.createdAt, + required this.likesCount, + required this.isLiked, + required this.username, + required this.avatarUrl, + }); + + final String id; + final String userId; + final String caption; + final String imageUrl; + final DateTime createdAt; + final int likesCount; + final bool isLiked; + final String username; + final String avatarUrl; + + FeedPostModel copyWith({ + int? likesCount, + bool? isLiked, + }) { + return FeedPostModel( + id: id, + userId: userId, + caption: caption, + imageUrl: imageUrl, + createdAt: createdAt, + likesCount: likesCount ?? this.likesCount, + isLiked: isLiked ?? this.isLiked, + username: username, + avatarUrl: avatarUrl, + ); + } +} diff --git a/lib/features/feed/presentation/providers/feed_providers.dart b/lib/features/feed/presentation/providers/feed_providers.dart new file mode 100644 index 0000000..5cc8cfd --- /dev/null +++ b/lib/features/feed/presentation/providers/feed_providers.dart @@ -0,0 +1,62 @@ +import 'dart:typed_data'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/feed_service.dart'; +import '../../domain/models/feed_post_model.dart'; + +final feedServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return FeedService(client); +}); + +final feedPostsProvider = FutureProvider>((ref) { + return ref.watch(feedServiceProvider).fetchFeed(); +}); + +final feedControllerProvider = + AutoDisposeAsyncNotifierProvider( + FeedController.new, +); + +class FeedController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future createPost({ + required String caption, + required Uint8List imageBytes, + required String extension, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(feedServiceProvider).createPost( + caption: caption, + imageBytes: imageBytes, + extension: extension, + ); + ref.invalidate(feedPostsProvider); + }); + } + + Future toggleLike(FeedPostModel post) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(feedServiceProvider).toggleLike( + postId: post.id, + currentlyLiked: post.isLiked, + currentLikesCount: post.likesCount, + ); + ref.invalidate(feedPostsProvider); + }); + } + + Future deleteOwnPost(String postId) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(feedServiceProvider).deleteOwnPost(postId); + ref.invalidate(feedPostsProvider); + }); + } +} diff --git a/lib/features/feed/presentation/providers/post_providers.dart b/lib/features/feed/presentation/providers/post_providers.dart new file mode 100644 index 0000000..633b925 --- /dev/null +++ b/lib/features/feed/presentation/providers/post_providers.dart @@ -0,0 +1,59 @@ +import 'dart:typed_data'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/post_service.dart'; +import '../../domain/models/feed_post_model.dart'; + +final postServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return PostService(client); +}); + +final feedPostsProvider = FutureProvider>((ref) { + return ref.watch(postServiceProvider).fetchFeed(); +}); + +final postControllerProvider = AutoDisposeAsyncNotifierProvider( + PostController.new, +); + +class PostController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future createPost({ + required String caption, + required Uint8List imageBytes, + required String extension, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(postServiceProvider).uploadPost( + caption: caption, + imageBytes: imageBytes, + extension: extension, + ); + ref.invalidate(feedPostsProvider); + }); + } + + Future toggleLike(FeedPostModel post) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(postServiceProvider).toggleLike( + postId: post.id, + currentlyLiked: post.isLiked, + currentLikesCount: post.likesCount, + ); + ref.invalidate(feedPostsProvider); + }); + } + + Future deletePost(String postId) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(postServiceProvider).deletePost(postId); + ref.invalidate(feedPostsProvider); + }); + } +} diff --git a/lib/features/feed/presentation/screens/feed_screen.dart b/lib/features/feed/presentation/screens/feed_screen.dart new file mode 100644 index 0000000..1bfa671 --- /dev/null +++ b/lib/features/feed/presentation/screens/feed_screen.dart @@ -0,0 +1,94 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../auth/presentation/providers/auth_provider.dart'; +import '../providers/post_providers.dart'; +import '../widgets/post_card.dart'; + +class FeedScreen extends ConsumerWidget { + const FeedScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final postsAsync = ref.watch(feedPostsProvider); + final currentUser = ref.watch(authServiceProvider).currentUser; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RIOTZ // FEED'), + actions: [ + IconButton( + icon: const Icon(Icons.add_box_outlined, color: AppColors.white), + onPressed: () => context.push(AppRoutes.uploadPost), + ), + ], + ), + body: RefreshIndicator( + color: AppColors.neonRed, + backgroundColor: AppColors.black, + onRefresh: () async => ref.refresh(feedPostsProvider), + child: postsAsync.when( + data: (posts) { + if (posts.isEmpty) { + return const Center( + child: Text('NO CHAOS YET. START A RIOT.'), + ); + } + return ListView.builder( + itemCount: posts.length, + itemBuilder: (context, index) { + final post = posts[index]; + return PostCard( + post: post, + isOwnPost: post.userId == currentUser?.id, + onLike: () => ref.read(postControllerProvider.notifier).toggleLike(post), + onDelete: () => _confirmDelete(context, ref, post.id), + ); + }, + ); + }, + loading: () => const Center( + child: CircularProgressIndicator(color: AppColors.neonRed), + ), + error: (error, _) => Center( + child: Text('SIGNAL LOST: $error'), + ), + ), + ), + floatingActionButton: FloatingActionButton( + backgroundColor: AppColors.neonRed, + child: const Icon(Icons.add, color: AppColors.white), + onPressed: () => context.push(AppRoutes.uploadPost), + ), + ); + } + + void _confirmDelete(BuildContext context, WidgetRef ref, String postId) { + showDialog( + context: context, + builder: (context) => AlertDialog( + backgroundColor: AppColors.surface, + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), + title: const Text('ERASE TRANSMISSION?'), + content: const Text('THIS ACTION CANNOT BE UNDONE.'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('CANCEL', style: TextStyle(color: AppColors.white)), + ), + TextButton( + onPressed: () { + ref.read(postControllerProvider.notifier).deletePost(postId); + Navigator.pop(context); + }, + child: const Text('DELETE', style: TextStyle(color: AppColors.neonRed)), + ), + ], + ), + ); + } +} diff --git a/lib/features/feed/presentation/screens/upload_post_screen.dart b/lib/features/feed/presentation/screens/upload_post_screen.dart new file mode 100644 index 0000000..1fb8a7a --- /dev/null +++ b/lib/features/feed/presentation/screens/upload_post_screen.dart @@ -0,0 +1,134 @@ +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:image_picker/image_picker.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../providers/post_providers.dart'; + +class UploadPostScreen extends ConsumerStatefulWidget { + const UploadPostScreen({super.key}); + + @override + ConsumerState createState() => _UploadPostScreenState(); +} + +class _UploadPostScreenState extends ConsumerState { + final _captionController = TextEditingController(); + final _picker = ImagePicker(); + Uint8List? _imageBytes; + String? _extension; + + @override + void dispose() { + _captionController.dispose(); + super.dispose(); + } + + Future _pickImage() async { + final image = await _picker.pickImage( + source: ImageSource.gallery, + imageQuality: 80, + maxWidth: 1080, + ); + + if (image != null) { + final bytes = await image.readAsBytes(); + setState(() { + _imageBytes = bytes; + _extension = image.name.split('.').last.toLowerCase(); + }); + } + } + + Future _upload() async { + if (_imageBytes == null) return; + + await ref.read(postControllerProvider.notifier).createPost( + caption: _captionController.text, + imageBytes: _imageBytes!, + extension: _extension ?? 'jpg', + ); + + if (mounted) { + context.pop(); + } + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final loading = ref.watch(postControllerProvider).isLoading; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('NEW TRANSMISSION'), + leading: IconButton( + icon: const Icon(Icons.close), + onPressed: () => context.pop(), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Image Picker Area + GestureDetector( + onTap: loading ? null : _pickImage, + child: AspectRatio( + aspectRatio: 1, + child: Container( + decoration: BoxDecoration( + color: AppColors.surface, + border: Border.all(color: AppColors.border, width: 2), + ), + child: _imageBytes != null + ? Image.memory(_imageBytes!, fit: BoxFit.cover) + : Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Icons.add_a_photo_outlined, size: 48, color: AppColors.grey), + const SizedBox(height: 12), + Text( + 'SELECT VISUALS', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.grey), + ), + ], + ), + ), + ), + ), + const SizedBox(height: 32), + + // Caption Field + Text( + 'MANIFESTO', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 8), + TextField( + controller: _captionController, + maxLines: 4, + decoration: const InputDecoration( + hintText: 'DESCRIBE THE CHAOS...', + ), + ), + const SizedBox(height: 48), + + // Post Button + RiotzButton( + label: 'PROPAGATE', + isLoading: loading, + onPressed: _imageBytes == null ? null : _upload, + ), + ], + ), + ), + ); + } +} diff --git a/lib/features/feed/presentation/widgets/post_card.dart b/lib/features/feed/presentation/widgets/post_card.dart new file mode 100644 index 0000000..36d318a --- /dev/null +++ b/lib/features/feed/presentation/widgets/post_card.dart @@ -0,0 +1,117 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_card.dart'; +import '../../domain/models/feed_post_model.dart'; + +class PostCard extends StatelessWidget { + const PostCard({ + required this.post, + required this.isOwnPost, + required this.onLike, + required this.onDelete, + super.key, + }); + + final FeedPostModel post; + final bool isOwnPost; + final VoidCallback onLike; + final VoidCallback onDelete; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final timeStr = DateFormat('HH:mm // dd.MM.yy').format(post.createdAt); + + return RiotzCard( + padding: EdgeInsets.zero, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Header + Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: AppColors.surfaceLight, + border: Border.all(color: AppColors.border), + ), + child: post.avatarUrl.isNotEmpty + ? CachedNetworkImage( + imageUrl: post.avatarUrl, + fit: BoxFit.cover, + errorWidget: (_, __, ___) => const Icon(Icons.person, color: AppColors.grey), + ) + : const Icon(Icons.person, color: AppColors.grey), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(post.username.toUpperCase(), style: theme.textTheme.labelLarge), + Text(timeStr, style: theme.textTheme.bodySmall), + ], + ), + ), + if (isOwnPost) + IconButton( + icon: const Icon(Icons.close, color: AppColors.grey, size: 20), + onPressed: onDelete, + ), + ], + ), + ), + + // Visuals + CachedNetworkImage( + imageUrl: post.imageUrl, + width: double.infinity, + fit: BoxFit.cover, + placeholder: (context, url) => Container( + height: 300, + color: AppColors.surfaceLight, + child: const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + ), + ), + + // Footer + Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + IconButton( + onPressed: onLike, + icon: Icon( + post.isLiked ? Icons.favorite : Icons.favorite_border, + color: post.isLiked ? AppColors.neonRed : AppColors.white, + ), + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), + ), + const SizedBox(width: 8), + Text('${post.likesCount}', style: theme.textTheme.titleMedium), + const SizedBox(width: 24), + const Icon(Icons.chat_bubble_outline, color: AppColors.white, size: 20), + ], + ), + if (post.caption.isNotEmpty) ...[ + const SizedBox(height: 12), + Text(post.caption, style: theme.textTheme.bodyLarge), + ], + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/features/home/presentation/pages/home_page.dart b/lib/features/home/presentation/pages/home_page.dart new file mode 100644 index 0000000..827ba58 --- /dev/null +++ b/lib/features/home/presentation/pages/home_page.dart @@ -0,0 +1,347 @@ +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:image_picker/image_picker.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../../features/auth/presentation/providers/auth_providers.dart'; +import '../../../../features/admin/presentation/providers/admin_providers.dart'; +import '../../../../features/feed/domain/models/feed_post_model.dart'; +import '../../../../features/feed/presentation/providers/feed_providers.dart'; + +class HomePage extends ConsumerStatefulWidget { + const HomePage({super.key}); + + @override + ConsumerState createState() => _HomePageState(); +} + +class _HomePageState extends ConsumerState { + final _captionController = TextEditingController(); + final _picker = ImagePicker(); + Uint8List? _selectedImageBytes; + String _selectedImageExt = 'jpg'; + + @override + void dispose() { + _captionController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final user = ref.watch(currentUserProvider); + final isAdmin = ref.watch(isAdminProvider); + final feedAsync = ref.watch(feedPostsProvider); + final feedActionState = ref.watch(feedControllerProvider); + final isBusy = feedActionState.isLoading; + + ref.listen(feedControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text('CHAOS PROPAGATED.', style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold)), + ), + ); + }, + error: (error, _) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text(error.toString().toUpperCase()), + ), + ); + }, + ); + }); + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RIOTZ // FEED'), + actions: [ + IconButton( + icon: const Icon(Icons.logout, color: AppColors.white), + onPressed: () async { + await ref.read(authControllerProvider.notifier).logout(); + if (context.mounted) context.go(AppRoutes.login); + }, + ), + ], + ), + body: RefreshIndicator( + color: AppColors.neonRed, + backgroundColor: AppColors.black, + onRefresh: () async => ref.invalidate(feedPostsProvider), + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24), + children: [ + Text( + 'WELCOME, ${user?.email?.split('@').first.toUpperCase() ?? 'RIOTER'}', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 24), + + // Composer + _PostComposer( + captionController: _captionController, + selectedImageBytes: _selectedImageBytes, + onPickImage: isBusy ? null : _pickImage, + onCreatePost: isBusy ? null : _createPost, + isBusy: isBusy, + ), + + const SizedBox(height: 32), + + // Navigation Shortcuts (Chaotic Grid) + Wrap( + spacing: 8, + runSpacing: 8, + children: [ + _NavChip(label: 'PROFILE', onTap: () => context.push(AppRoutes.profile)), + _NavChip(label: 'MUSIC', onTap: () => context.push(AppRoutes.music)), + _NavChip(label: 'DISCOVER', onTap: () => context.push(AppRoutes.discover)), + if (isAdmin) _NavChip(label: 'ADMIN', onTap: () => context.push(AppRoutes.admin), isAccent: true), + ], + ), + + const SizedBox(height: 32), + + feedAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (error, _) => Center(child: Text('SYSTEM ERROR: $error')), + data: (posts) { + if (posts.isEmpty) { + return const Center(child: Text('NO CHAOS YET. START A RIOT.')); + } + return ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: posts.length, + separatorBuilder: (_, __) => const SizedBox(height: 24), + itemBuilder: (context, index) { + final post = posts[index]; + return _FeedPostCard( + post: post, + isOwnPost: user?.id == post.userId, + onLike: () => ref.read(feedControllerProvider.notifier).toggleLike(post), + onDelete: () => ref.read(feedControllerProvider.notifier).deleteOwnPost(post.id), + ); + }, + ); + }, + ), + ], + ), + ), + ); + } + + Future _pickImage() async { + final image = await _picker.pickImage(source: ImageSource.gallery, imageQuality: 80); + if (image == null) return; + final bytes = await image.readAsBytes(); + setState(() { + _selectedImageBytes = bytes; + _selectedImageExt = image.name.split('.').last; + }); + } + + Future _createPost() async { + if (_selectedImageBytes == null) return; + await ref.read(feedControllerProvider.notifier).createPost( + caption: _captionController.text, + imageBytes: _selectedImageBytes!, + extension: _selectedImageExt, + ); + _captionController.clear(); + setState(() => _selectedImageBytes = null); + } +} + +class _NavChip extends StatelessWidget { + const _NavChip({required this.label, required this.onTap, this.isAccent = false}); + final String label; + final VoidCallback onTap; + final bool isAccent; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + decoration: BoxDecoration( + border: Border.all(color: isAccent ? AppColors.neonRed : AppColors.white), + ), + child: Text( + label, + style: TextStyle( + color: isAccent ? AppColors.neonRed : AppColors.white, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + ), + ), + ); + } +} + +class _PostComposer extends StatelessWidget { + const _PostComposer({ + required this.captionController, + required this.selectedImageBytes, + required this.onPickImage, + required this.onCreatePost, + required this.isBusy, + }); + + final TextEditingController captionController; + final Uint8List? selectedImageBytes; + final VoidCallback? onPickImage; + final VoidCallback? onCreatePost; + final bool isBusy; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: AppColors.border), + color: AppColors.surface, + ), + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: captionController, + maxLines: 3, + decoration: const InputDecoration( + hintText: 'WHAT\'S THE WORD ON THE STREET?', + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + ), + ), + if (selectedImageBytes != null) ...[ + const SizedBox(height: 12), + Image.memory(selectedImageBytes!, height: 200, width: double.infinity, fit: BoxFit.cover), + ], + const SizedBox(height: 16), + Row( + children: [ + IconButton( + icon: const Icon(Icons.add_a_photo_outlined, color: AppColors.white), + onPressed: onPickImage, + ), + const Spacer(), + RiotzButton( + label: 'POST', + onPressed: onCreatePost, + isLoading: isBusy, + fullWidth: false, + ), + ], + ), + ], + ), + ); + } +} + +class _FeedPostCard extends StatelessWidget { + const _FeedPostCard({ + required this.post, + required this.isOwnPost, + required this.onLike, + required this.onDelete, + }); + + final FeedPostModel post; + final bool isOwnPost; + final VoidCallback onLike; + final VoidCallback onDelete; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return Container( + decoration: const BoxDecoration( + border: Border(bottom: BorderSide(color: AppColors.border)), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: AppColors.surfaceLight, + border: Border.all(color: AppColors.border), + ), + child: post.avatarUrl.isNotEmpty + ? Image.network(post.avatarUrl, fit: BoxFit.cover) + : const Icon(Icons.person, color: AppColors.grey), + ), + const SizedBox(width: 12), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(post.username.toUpperCase(), style: theme.textTheme.labelLarge), + Text('RIOTER', style: theme.textTheme.bodySmall?.copyWith(color: AppColors.neonRed, fontSize: 10)), + ], + ), + const Spacer(), + if (isOwnPost) + IconButton( + icon: const Icon(Icons.more_vert, color: AppColors.grey), + onPressed: onDelete, + ), + ], + ), + const SizedBox(height: 16), + if (post.imageUrl.isNotEmpty) + Image.network(post.imageUrl, width: double.infinity, fit: BoxFit.cover), + const SizedBox(height: 16), + if (post.caption.isNotEmpty) + Padding( + padding: const EdgeInsets.only(bottom: 12), + child: Text(post.caption, style: theme.textTheme.bodyLarge), + ), + Row( + children: [ + IconButton( + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), + icon: Icon( + post.isLiked ? Icons.favorite : Icons.favorite_border, + color: post.isLiked ? AppColors.neonRed : AppColors.white, + size: 20, + ), + onPressed: onLike, + ), + const SizedBox(width: 8), + Text('${post.likesCount}', style: theme.textTheme.labelLarge), + const SizedBox(width: 24), + const Icon(Icons.chat_bubble_outline, color: AppColors.white, size: 20), + const SizedBox(width: 8), + const Text('0', style: TextStyle(fontWeight: FontWeight.bold)), + ], + ), + const SizedBox(height: 16), + ], + ), + ); + } +} diff --git a/lib/features/music/data/services/music_service.dart b/lib/features/music/data/services/music_service.dart new file mode 100644 index 0000000..903ae1c --- /dev/null +++ b/lib/features/music/data/services/music_service.dart @@ -0,0 +1,84 @@ +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../domain/models/track_model.dart'; + +class MusicService { + const MusicService(this._client); + + final SupabaseClient _client; + + User get _currentUser { + final user = _client.auth.currentUser; + if (user == null) { + throw StateError('No authenticated user'); + } + return user; + } + + /// Uploads a new track with an MP3 file and metadata. + Future uploadTrack({ + required Uint8List bytes, + required String title, + required String genreTag, + required String extension, + }) async { + final user = _currentUser; + final ts = DateTime.now().millisecondsSinceEpoch; + final random = Random().nextInt(99999); + final fileName = '$ts-$random.$extension'; + final path = 'tracks/${user.id}/$fileName'; + + // Upload audio to Supabase Storage + await _client.storage.from('tracks').uploadBinary( + path, + bytes, + fileOptions: const FileOptions(upsert: false), + ); + + final audioUrl = _client.storage.from('tracks').getPublicUrl(path); + + // Insert track record into PostgreSQL + await _client.from('tracks').insert({ + 'user_id': user.id, + 'title': title.trim().isEmpty ? 'UNTITLED' : title.trim().toUpperCase(), + 'audio_url': audioUrl, + 'genre_tag': genreTag.trim().isEmpty ? 'UNKNOWN' : genreTag.trim().toUpperCase(), + 'plays': 0, + }); + } + + /// Lists all tracks in chronological order. + Future> fetchTracks() async { + final response = await _client + .from('tracks') + .select('*, profiles(username)') + .order('created_at', ascending: false); + + return List>.from(response).map((row) { + final username = (row['profiles'] as Map?)?['username'] as String?; + return TrackModel.fromJson(row, username: username); + }).toList(); + } + + /// Increments the play count of a track. + Future incrementPlays(String trackId) async { + await _client.rpc('increment_track_plays', params: {'track_id': trackId}); + } + + /// Fetches tracks for a specific user. + Future> fetchUserTracks(String userId) async { + final response = await _client + .from('tracks') + .select('*, profiles(username)') + .eq('user_id', userId) + .order('created_at', ascending: false); + + return List>.from(response).map((row) { + final username = (row['profiles'] as Map?)?['username'] as String?; + return TrackModel.fromJson(row, username: username); + }).toList(); + } +} diff --git a/lib/features/music/domain/models/track_model.dart b/lib/features/music/domain/models/track_model.dart new file mode 100644 index 0000000..4771bca --- /dev/null +++ b/lib/features/music/domain/models/track_model.dart @@ -0,0 +1,54 @@ +class TrackModel { + const TrackModel({ + required this.id, + required this.userId, + required this.title, + required this.audioUrl, + required this.genreTag, + required this.plays, + required this.createdAt, + required this.username, + this.featured = false, + }); + + final String id; + final String userId; + final String title; + final String audioUrl; + final String genreTag; + final int plays; + final DateTime createdAt; + final String username; + final bool featured; + + factory TrackModel.fromJson(Map json, {String? username}) { + return TrackModel( + id: json['id'] as String, + userId: json['user_id'] as String, + title: (json['title'] as String?) ?? 'UNTITLED', + audioUrl: (json['audio_url'] as String?) ?? '', + genreTag: (json['genre_tag'] as String?) ?? 'UNKNOWN', + plays: (json['plays'] as int?) ?? 0, + createdAt: DateTime.parse(json['created_at'] as String), + username: username ?? 'RIOTER', + featured: (json['featured'] as bool?) ?? false, + ); + } + + TrackModel copyWith({ + int? plays, + bool? featured, + }) { + return TrackModel( + id: id, + userId: userId, + title: title, + audioUrl: audioUrl, + genreTag: genreTag, + plays: plays ?? this.plays, + createdAt: createdAt, + username: username, + featured: featured ?? this.featured, + ); + } +} diff --git a/lib/features/music/presentation/pages/music_page.dart b/lib/features/music/presentation/pages/music_page.dart new file mode 100644 index 0000000..b8317f7 --- /dev/null +++ b/lib/features/music/presentation/pages/music_page.dart @@ -0,0 +1,236 @@ +import 'dart:typed_data'; + +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../providers/music_providers.dart'; +import '../widgets/track_card.dart'; + +class MusicPage extends ConsumerStatefulWidget { + const MusicPage({super.key}); + + @override + ConsumerState createState() => _MusicPageState(); +} + +class _MusicPageState extends ConsumerState { + final _titleController = TextEditingController(); + final _genreController = TextEditingController(); + Uint8List? _selectedMp3Bytes; + String? _selectedFileName; + String _selectedExtension = 'mp3'; + + @override + void dispose() { + _titleController.dispose(); + _genreController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final tracksAsync = ref.watch(trackListProvider); + final uploadState = ref.watch(musicControllerProvider); + + ref.listen(musicControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text('SONIC CHAOS UPLOADED.', style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold)), + ), + ); + }, + error: (error, _) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text(error.toString().toUpperCase()), + ), + ); + }, + ); + }); + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RIOTZ // AUDIO'), + ), + body: ListView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24), + children: [ + Text( + 'UPLOAD TRANSMISSION', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 16), + _UploadComposer( + titleController: _titleController, + genreController: _genreController, + selectedFileName: _selectedFileName, + isBusy: uploadState.isLoading, + onPickMp3: uploadState.isLoading ? null : _pickMp3, + onUpload: uploadState.isLoading ? null : _upload, + ), + const SizedBox(height: 48), + Text( + 'LATEST SOUNDS', + style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed), + ), + const SizedBox(height: 16), + tracksAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (error, _) => Center(child: Text('SIGNAL LOST: $error')), + data: (tracks) { + if (tracks.isEmpty) { + return const Center( + child: Padding( + padding: EdgeInsets.all(32), + child: Text('NO TRACKS FOUND. BROADCAST YOUR SOUND.'), + ), + ); + } + return Column( + children: tracks.map((track) { + return TrackCard(track: track); + }).toList(), + ); + }, + ), + ], + ), + ); + } + + Future _pickMp3() async { + final result = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: const ['mp3'], + withData: true, + ); + if (result == null || result.files.isEmpty) return; + + final file = result.files.first; + if (file.bytes == null) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('UNREADABLE FILE.')), + ); + return; + } + + setState(() { + _selectedMp3Bytes = file.bytes; + _selectedFileName = file.name.toUpperCase(); + _selectedExtension = file.name.split('.').last.toLowerCase(); + }); + } + + Future _upload() async { + final bytes = _selectedMp3Bytes; + if (bytes == null) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('SELECT AN MP3 FIRST.')), + ); + return; + } + + await ref.read(musicControllerProvider.notifier).uploadTrack( + bytes: bytes, + title: _titleController.text, + genreTag: _genreController.text, + extension: _selectedExtension, + ); + + if (!mounted) return; + setState(() { + _selectedMp3Bytes = null; + _selectedFileName = null; + _titleController.clear(); + _genreController.clear(); + }); + } +} + +class _UploadComposer extends StatelessWidget { + const _UploadComposer({ + required this.titleController, + required this.genreController, + required this.selectedFileName, + required this.isBusy, + required this.onPickMp3, + required this.onUpload, + }); + + final TextEditingController titleController; + final TextEditingController genreController; + final String? selectedFileName; + final bool isBusy; + final VoidCallback? onPickMp3; + final VoidCallback? onUpload; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: AppColors.surface, + border: Border.all(color: AppColors.border), + ), + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: titleController, + decoration: const InputDecoration( + hintText: 'TRACK TITLE', + ), + ), + const SizedBox(height: 16), + TextField( + controller: genreController, + decoration: const InputDecoration( + hintText: 'GENRE (RAGE, PUNK, PHONK)', + ), + ), + const SizedBox(height: 24), + if (selectedFileName != null) + Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Text( + 'READY: $selectedFileName', + style: const TextStyle(color: AppColors.neonRed, fontWeight: FontWeight.bold, fontSize: 10), + ), + ), + Row( + children: [ + Expanded( + child: RiotzButton( + label: 'SELECT FILE', + style: RiotzButtonStyle.outline, + onPressed: onPickMp3, + ), + ), + const SizedBox(width: 12), + Expanded( + child: RiotzButton( + label: 'UPLOAD', + isLoading: isBusy, + onPressed: onUpload, + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/features/music/presentation/providers/music_providers.dart b/lib/features/music/presentation/providers/music_providers.dart new file mode 100644 index 0000000..92367d7 --- /dev/null +++ b/lib/features/music/presentation/providers/music_providers.dart @@ -0,0 +1,62 @@ +import 'dart:typed_data'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:just_audio/just_audio.dart'; +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/music_service.dart'; +import '../../domain/models/track_model.dart'; + +final musicServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return MusicService(client); +}); + +final trackListProvider = FutureProvider>((ref) { + return ref.watch(musicServiceProvider).fetchTracks(); +}); + +final userTracksProvider = FutureProvider.family, String>((ref, userId) { + return ref.watch(musicServiceProvider).fetchUserTracks(userId); +}); + +final musicControllerProvider = AutoDisposeAsyncNotifierProvider( + MusicController.new, +); + +class MusicController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future uploadTrack({ + required Uint8List bytes, + required String title, + required String genreTag, + required String extension, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(musicServiceProvider).uploadTrack( + bytes: bytes, + title: title, + genreTag: genreTag, + extension: extension, + ); + ref.invalidate(trackListProvider); + }); + } + + Future incrementPlays(String trackId) async { + await AsyncValue.guard(() => ref.read(musicServiceProvider).incrementPlays(trackId)); + } +} + +final audioPlayerProvider = Provider.autoDispose((ref) { + final player = AudioPlayer(); + ref.onDispose(player.dispose); + return player; +}); + +final currentTrackProvider = StateProvider((ref) => null); +final isPlayingProvider = StreamProvider((ref) { + final player = ref.watch(audioPlayerProvider); + return player.playingStream; +}); diff --git a/lib/features/music/presentation/screens/music_screen.dart b/lib/features/music/presentation/screens/music_screen.dart new file mode 100644 index 0000000..0bbe778 --- /dev/null +++ b/lib/features/music/presentation/screens/music_screen.dart @@ -0,0 +1,140 @@ +import 'dart:typed_data'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../providers/music_providers.dart'; +import '../widgets/track_card.dart'; + +class MusicScreen extends ConsumerStatefulWidget { + const MusicScreen({super.key}); + + @override + ConsumerState createState() => _MusicScreenState(); +} + +class _MusicScreenState extends ConsumerState { + final _titleController = TextEditingController(); + final _genreController = TextEditingController(); + Uint8List? _selectedMp3Bytes; + String? _selectedFileName; + String _selectedExtension = 'mp3'; + + @override + void dispose() { + _titleController.dispose(); + _genreController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final tracksAsync = ref.watch(trackListProvider); + final uploadState = ref.watch(musicControllerProvider); + + return RiotzScaffold( + appBar: AppBar(title: const Text('RIOTZ // AUDIO')), + body: ListView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24), + children: [ + Text('UPLOAD TRANSMISSION', style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed)), + const SizedBox(height: 16), + _UploadComposer( + titleController: _titleController, + genreController: _genreController, + selectedFileName: _selectedFileName, + isBusy: uploadState.isLoading, + onPickMp3: uploadState.isLoading ? null : _pickMp3, + onUpload: uploadState.isLoading ? null : _upload, + ), + const SizedBox(height: 48), + Text('LATEST SOUNDS', style: theme.textTheme.labelLarge?.copyWith(color: AppColors.neonRed)), + const SizedBox(height: 16), + tracksAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (error, _) => Center(child: Text('SIGNAL LOST: $error')), + data: (tracks) => Column( + children: tracks.map((track) => TrackCard(track: track)).toList(), + ), + ), + ], + ), + ); + } + + Future _pickMp3() async { + final result = await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['mp3'], withData: true); + if (result == null || result.files.isEmpty) return; + final file = result.files.first; + setState(() { + _selectedMp3Bytes = file.bytes; + _selectedFileName = file.name.toUpperCase(); + _selectedExtension = file.name.split('.').last.toLowerCase(); + }); + } + + Future _upload() async { + if (_selectedMp3Bytes == null) return; + await ref.read(musicControllerProvider.notifier).uploadTrack( + bytes: _selectedMp3Bytes!, + title: _titleController.text, + genreTag: _genreController.text, + extension: _selectedExtension, + ); + setState(() { + _selectedMp3Bytes = null; + _selectedFileName = null; + _titleController.clear(); + _genreController.clear(); + }); + } +} + +class _UploadComposer extends StatelessWidget { + const _UploadComposer({ + required this.titleController, + required this.genreController, + required this.selectedFileName, + required this.isBusy, + required this.onPickMp3, + required this.onUpload, + }); + + final TextEditingController titleController; + final TextEditingController genreController; + final String? selectedFileName; + final bool isBusy; + final VoidCallback? onPickMp3; + final VoidCallback? onUpload; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration(color: AppColors.surface, border: Border.all(color: AppColors.border)), + padding: const EdgeInsets.all(20), + child: Column( + children: [ + TextField(controller: titleController, decoration: const InputDecoration(hintText: 'TRACK TITLE')), + const SizedBox(height: 16), + TextField(controller: genreController, decoration: const InputDecoration(hintText: 'GENRE')), + const SizedBox(height: 24), + if (selectedFileName != null) Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Text('READY: $selectedFileName', style: const TextStyle(color: AppColors.neonRed, fontWeight: FontWeight.bold, fontSize: 10)), + ), + Row( + children: [ + Expanded(child: RiotzButton(label: 'SELECT', style: RiotzButtonStyle.outline, onPressed: onPickMp3)), + const SizedBox(width: 12), + Expanded(child: RiotzButton(label: 'UPLOAD', isLoading: isBusy, onPressed: onUpload)), + ], + ), + ], + ), + ); + } +} diff --git a/lib/features/music/presentation/widgets/track_card.dart b/lib/features/music/presentation/widgets/track_card.dart new file mode 100644 index 0000000..617d16a --- /dev/null +++ b/lib/features/music/presentation/widgets/track_card.dart @@ -0,0 +1,109 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:just_audio/just_audio.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../domain/models/track_model.dart'; +import '../providers/music_providers.dart'; + +class TrackCard extends ConsumerWidget { + const TrackCard({ + required this.track, + super.key, + }); + + final TrackModel track; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = Theme.of(context); + final player = ref.watch(audioPlayerProvider); + final currentTrack = ref.watch(currentTrackProvider); + final isPlaying = ref.watch(isPlayingProvider).value ?? false; + final isCurrent = currentTrack?.id == track.id; + + return Container( + decoration: BoxDecoration( + color: isCurrent ? AppColors.surfaceLight : Colors.transparent, + border: Border.all(color: isCurrent ? AppColors.neonRed : AppColors.border), + ), + margin: const EdgeInsets.only(bottom: 12), + child: InkWell( + onTap: () => _handlePlay(ref, player), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: Row( + children: [ + // Cover / Icon + Container( + width: 56, + height: 56, + color: AppColors.black, + child: Center( + child: Icon( + isCurrent && isPlaying ? Icons.graphic_eq : Icons.music_note, + color: isCurrent ? AppColors.neonRed : AppColors.white, + size: 28, + ), + ), + ), + const SizedBox(width: 16), + // Info + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + track.title.toUpperCase(), + style: theme.textTheme.titleLarge?.copyWith(fontSize: 16, letterSpacing: 1), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + '${track.username.toUpperCase()} // ${track.genreTag.toUpperCase()}', + style: theme.textTheme.bodySmall?.copyWith(color: AppColors.grey, fontSize: 10), + ), + ], + ), + ), + // Plays & Action + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + '${track.plays} PLAYS', + style: theme.textTheme.bodySmall?.copyWith(fontSize: 9, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 4), + Icon( + isCurrent && isPlaying ? Icons.pause_circle_filled : Icons.play_circle_filled, + color: AppColors.white, + size: 32, + ), + ], + ), + ], + ), + ), + ), + ); + } + + Future _handlePlay(WidgetRef ref, AudioPlayer player) async { + final currentTrack = ref.read(currentTrackProvider); + + if (currentTrack?.id == track.id) { + if (player.playing) { + await player.pause(); + } else { + await player.play(); + } + } else { + ref.read(currentTrackProvider.notifier).state = track; + await player.setUrl(track.audioUrl); + await player.play(); + // Increment play count + ref.read(musicControllerProvider.notifier).incrementPlays(track.id); + } + } +} diff --git a/lib/features/profile/data/services/profile_service.dart b/lib/features/profile/data/services/profile_service.dart new file mode 100644 index 0000000..85d1a17 --- /dev/null +++ b/lib/features/profile/data/services/profile_service.dart @@ -0,0 +1,136 @@ +import 'dart:typed_data'; + +import 'package:supabase_flutter/supabase_flutter.dart'; + +import '../../domain/models/profile_model.dart'; +import '../../domain/models/profile_stats_model.dart'; + +class ProfileService { + const ProfileService(this._client); + + final SupabaseClient _client; + + User get _currentUser { + final user = _client.auth.currentUser; + if (user == null) { + throw StateError('No authenticated user'); + } + return user; + } + + Future fetchMyProfile() async { + final user = _currentUser; + final response = await _client + .from('profiles') + .select() + .eq('user_id', user.id) + .maybeSingle(); + + if (response == null) { + final created = await _client + .from('profiles') + .insert({ + 'user_id': user.id, + 'username': (user.userMetadata?['username'] as String?) ?? '', + 'bio': '', + 'avatar_url': '', + }) + .select() + .single(); + + return ProfileModel.fromJson(created); + } + + return ProfileModel.fromJson(response); + } + + Future updateUsername(String username) async { + final user = _currentUser; + await _client.auth.updateUser(UserAttributes(data: {'username': username})); + final updated = await _client + .from('profiles') + .update({'username': username}) + .eq('user_id', user.id) + .select() + .single(); + return ProfileModel.fromJson(updated); + } + + Future updateBio(String bio) async { + final user = _currentUser; + final updated = await _client + .from('profiles') + .update({'bio': bio}) + .eq('user_id', user.id) + .select() + .single(); + return ProfileModel.fromJson(updated); + } + + Future updateProfile({ + required String username, + required String bio, + }) async { + final user = _currentUser; + await _client.auth.updateUser(UserAttributes(data: {'username': username})); + final updated = await _client + .from('profiles') + .update({ + 'username': username, + 'bio': bio, + }) + .eq('user_id', user.id) + .select() + .single(); + return ProfileModel.fromJson(updated); + } + + Future uploadAvatar({ + required Uint8List bytes, + required String extension, + }) async { + final user = _currentUser; + final path = + 'avatars/${user.id}/${DateTime.now().millisecondsSinceEpoch}.$extension'; + + await _client.storage.from('avatars').uploadBinary( + path, + bytes, + fileOptions: const FileOptions(upsert: true), + ); + + final avatarUrl = _client.storage.from('avatars').getPublicUrl(path); + final updated = await _client + .from('profiles') + .update({'avatar_url': avatarUrl}) + .eq('user_id', user.id) + .select() + .single(); + return ProfileModel.fromJson(updated); + } + + Future fetchMyStats() async { + final user = _currentUser; + + final postResponse = await _client + .from('posts') + .select('*') + .eq('user_id', user.id); + + final commentResponse = await _client + .from('comments') + .select('*') + .eq('user_id', user.id); + + final trackResponse = await _client + .from('tracks') + .select('*') + .eq('user_id', user.id); + + return ProfileStatsModel( + postsCount: (postResponse as List).length, + commentsCount: (commentResponse as List).length, + tracksCount: (trackResponse as List).length, + ); + } +} diff --git a/lib/features/profile/domain/models/profile_model.dart b/lib/features/profile/domain/models/profile_model.dart new file mode 100644 index 0000000..01f367e --- /dev/null +++ b/lib/features/profile/domain/models/profile_model.dart @@ -0,0 +1,35 @@ +class ProfileModel { + const ProfileModel({ + required this.userId, + required this.username, + required this.bio, + required this.avatarUrl, + }); + + final String userId; + final String username; + final String bio; + final String avatarUrl; + + factory ProfileModel.fromJson(Map json) { + return ProfileModel( + userId: (json['user_id'] as String?) ?? '', + username: (json['username'] as String?) ?? '', + bio: (json['bio'] as String?) ?? '', + avatarUrl: (json['avatar_url'] as String?) ?? '', + ); + } + + ProfileModel copyWith({ + String? username, + String? bio, + String? avatarUrl, + }) { + return ProfileModel( + userId: userId, + username: username ?? this.username, + bio: bio ?? this.bio, + avatarUrl: avatarUrl ?? this.avatarUrl, + ); + } +} diff --git a/lib/features/profile/domain/models/profile_stats_model.dart b/lib/features/profile/domain/models/profile_stats_model.dart new file mode 100644 index 0000000..ecd5272 --- /dev/null +++ b/lib/features/profile/domain/models/profile_stats_model.dart @@ -0,0 +1,11 @@ +class ProfileStatsModel { + const ProfileStatsModel({ + required this.postsCount, + required this.commentsCount, + required this.tracksCount, + }); + + final int postsCount; + final int commentsCount; + final int tracksCount; +} diff --git a/lib/features/profile/presentation/pages/profile_page.dart b/lib/features/profile/presentation/pages/profile_page.dart new file mode 100644 index 0000000..b67cce0 --- /dev/null +++ b/lib/features/profile/presentation/pages/profile_page.dart @@ -0,0 +1,283 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:image_picker/image_picker.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; +import '../../../auth/presentation/providers/auth_provider.dart'; +import '../../../music/presentation/providers/music_providers.dart'; +import '../../../music/presentation/widgets/track_card.dart'; +import '../../domain/models/profile_model.dart'; +import '../../domain/models/profile_stats_model.dart'; +import '../providers/profile_providers.dart'; + +class ProfilePage extends ConsumerStatefulWidget { + const ProfilePage({super.key}); + + @override + ConsumerState createState() => _ProfilePageState(); +} + +class _ProfilePageState extends ConsumerState with SingleTickerProviderStateMixin { + late TabController _tabController; + final _usernameController = TextEditingController(); + final _bioController = TextEditingController(); + final _picker = ImagePicker(); + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 2, vsync: this); + } + + @override + void dispose() { + _tabController.dispose(); + _usernameController.dispose(); + _bioController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + ref.listen(profileControllerProvider, (_, next) { + next.whenOrNull( + data: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: AppColors.success, + content: Text('IDENTITY UPDATED.', style: TextStyle(color: AppColors.black, fontWeight: FontWeight.bold)), + ), + ); + ref.invalidate(myProfileStatsProvider); + }, + error: (error, _) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: AppColors.bloodRed, + content: Text(error.toString().toUpperCase()), + ), + ); + }, + ); + }); + + final profileAsync = ref.watch(myProfileProvider); + final statsAsync = ref.watch(myProfileStatsProvider); + final updating = ref.watch(profileControllerProvider).isLoading; + final currentUser = ref.watch(authServiceProvider).currentUser; + + return RiotzScaffold( + appBar: AppBar( + title: const Text('RIOTZ // IDENTITY'), + ), + body: profileAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (error, _) => Center(child: Text('ERROR: $error')), + data: (profile) { + _syncControllers(profile); + + return Column( + children: [ + Expanded( + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 24), + children: [ + // Profile Header + Center( + child: Stack( + children: [ + Container( + width: 120, + height: 120, + decoration: BoxDecoration( + border: Border.all(color: AppColors.neonRed, width: 2), + color: AppColors.surfaceLight, + ), + child: profile.avatarUrl.isNotEmpty + ? Image.network(profile.avatarUrl, fit: BoxFit.cover) + : const Icon(Icons.person, size: 60, color: AppColors.grey), + ), + Positioned( + right: -4, + bottom: -4, + child: IconButton( + onPressed: updating ? null : _pickAndUploadAvatar, + icon: Container( + padding: const EdgeInsets.all(4), + color: AppColors.neonRed, + child: const Icon(Icons.edit, color: AppColors.white, size: 18), + ), + ), + ), + ], + ), + ), + const SizedBox(height: 32), + + _StatsSection(statsAsync: statsAsync), + + const SizedBox(height: 32), + + // Tabs + TabBar( + controller: _tabController, + indicatorColor: AppColors.neonRed, + labelColor: AppColors.white, + unselectedLabelColor: AppColors.grey, + tabs: const [ + Tab(text: 'IDENTITY'), + Tab(text: 'TRACKS'), + ], + ), + const SizedBox(height: 24), + + SizedBox( + height: 400, // Fixed height for tab content in ListView + child: TabBarView( + controller: _tabController, + children: [ + // Identity Tab + SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('USERNAME', style: theme.textTheme.labelLarge?.copyWith(color: AppColors.grey)), + const SizedBox(height: 8), + TextField( + controller: _usernameController, + decoration: const InputDecoration(hintText: 'ENTER ALIAS'), + ), + const SizedBox(height: 24), + Text('BIO // MANIFESTO', style: theme.textTheme.labelLarge?.copyWith(color: AppColors.grey)), + const SizedBox(height: 8), + TextField( + controller: _bioController, + decoration: const InputDecoration(hintText: 'DESCRIBE THE CHAOS'), + minLines: 3, + maxLines: 5, + ), + const SizedBox(height: 32), + RiotzButton( + label: 'UPDATE IDENTITY', + isLoading: updating, + onPressed: () async { + await ref + .read(profileControllerProvider.notifier) + .saveProfile( + username: _usernameController.text, + bio: _bioController.text, + ); + }, + ), + ], + ), + ), + // Tracks Tab + currentUser == null + ? const Center(child: Text('LOG IN TO SEE TRACKS')) + : Consumer( + builder: (context, ref, child) { + final tracksAsync = ref.watch(userTracksProvider(currentUser.id)); + return tracksAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (err, _) => Center(child: Text('ERROR: $err')), + data: (tracks) { + if (tracks.isEmpty) { + return const Center(child: Text('NO TRACKS BROADCASTED.')); + } + return ListView.builder( + padding: EdgeInsets.zero, + itemCount: tracks.length, + itemBuilder: (context, index) => TrackCard(track: tracks[index]), + ); + }, + ); + }, + ), + ], + ), + ), + ], + ), + ), + ], + ); + }, + ), + ); + } + + void _syncControllers(ProfileModel profile) { + if (_usernameController.text != profile.username) { + _usernameController.text = profile.username; + } + if (_bioController.text != profile.bio) { + _bioController.text = profile.bio; + } + } + + Future _pickAndUploadAvatar() async { + final picked = await _picker.pickImage( + source: ImageSource.gallery, + imageQuality: 85, + maxWidth: 1200, + ); + if (picked == null) return; + + final bytes = await picked.readAsBytes(); + final ext = picked.name.split('.').last.toLowerCase(); + + if (!mounted) return; + await ref.read(profileControllerProvider.notifier).uploadAvatar( + bytes: bytes, + extension: ext.isEmpty ? 'jpg' : ext, + ); + } +} + +class _StatsSection extends StatelessWidget { + const _StatsSection({required this.statsAsync}); + + final AsyncValue statsAsync; + + @override + Widget build(BuildContext context) { + return statsAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: AppColors.neonRed)), + error: (error, _) => Text('STATS OFFLINE: $error'), + data: (stats) => Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _StatItem(label: 'POSTS', value: stats.postsCount.toString()), + _StatItem(label: 'CHAOS', value: stats.commentsCount.toString()), + _StatItem(label: 'TRACKS', value: stats.tracksCount.toString()), + ], + ), + ); + } +} + +class _StatItem extends StatelessWidget { + const _StatItem({ + required this.label, + required this.value, + }); + + final String label; + final String value; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return Column( + children: [ + Text(value, style: theme.textTheme.headlineLarge), + Text(label, style: theme.textTheme.labelLarge?.copyWith(color: AppColors.grey, fontSize: 10)), + ], + ); + } +} diff --git a/lib/features/profile/presentation/providers/profile_providers.dart b/lib/features/profile/presentation/providers/profile_providers.dart new file mode 100644 index 0000000..4ca8364 --- /dev/null +++ b/lib/features/profile/presentation/providers/profile_providers.dart @@ -0,0 +1,75 @@ +import 'dart:typed_data'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../../core/supabase/supabase_providers.dart'; +import '../../data/services/profile_service.dart'; +import '../../domain/models/profile_model.dart'; +import '../../domain/models/profile_stats_model.dart'; + +final profileServiceProvider = Provider((ref) { + final client = ref.watch(supabaseProvider); + return ProfileService(client); +}); + +final myProfileProvider = FutureProvider((ref) { + return ref.watch(profileServiceProvider).fetchMyProfile(); +}); + +final myProfileStatsProvider = FutureProvider((ref) { + return ref.watch(profileServiceProvider).fetchMyStats(); +}); + +final profileControllerProvider = + AutoDisposeAsyncNotifierProvider( + ProfileController.new, +); + +class ProfileController extends AutoDisposeAsyncNotifier { + @override + Future build() async {} + + Future updateUsername(String username) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(profileServiceProvider).updateUsername(username.trim()); + ref.invalidate(myProfileProvider); + }); + } + + Future updateBio(String bio) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(profileServiceProvider).updateBio(bio.trim()); + ref.invalidate(myProfileProvider); + }); + } + + Future uploadAvatar({ + required Uint8List bytes, + required String extension, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(profileServiceProvider).uploadAvatar( + bytes: bytes, + extension: extension, + ); + ref.invalidate(myProfileProvider); + }); + } + + Future saveProfile({ + required String username, + required String bio, + }) async { + state = const AsyncLoading(); + state = await AsyncValue.guard(() async { + await ref.read(profileServiceProvider).updateProfile( + username: username.trim(), + bio: bio.trim(), + ); + ref.invalidate(myProfileProvider); + }); + } +} diff --git a/lib/features/splash/presentation/pages/splash_page.dart b/lib/features/splash/presentation/pages/splash_page.dart new file mode 100644 index 0000000..d9f0756 --- /dev/null +++ b/lib/features/splash/presentation/pages/splash_page.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../../core/router/app_routes.dart'; +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/widgets/riotz_scaffold.dart'; +import '../../../../core/widgets/riotz_button.dart'; + +class SplashPage extends StatelessWidget { + const SplashPage({super.key}); + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + return RiotzScaffold( + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Spacer(flex: 2), + // Brand Title + Text( + 'RIOTZ', + style: theme.textTheme.displayLarge?.copyWith( + color: AppColors.white, + height: 0.9, + ), + ), + // Aesthetic Subtitle + Container( + color: AppColors.neonRed, + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), + child: Text( + 'UNDERGROUND // CHAOS // CULTURE', + style: theme.textTheme.labelLarge?.copyWith( + color: AppColors.white, + letterSpacing: 1.5, + fontSize: 12, + ), + ), + ), + const SizedBox(height: 24), + Text( + 'THE PREMIER PLATFORM FOR PUNK RAP, RAGE CULTURE, AND ALT FASHION.', + style: theme.textTheme.bodyLarge?.copyWith( + fontWeight: FontWeight.bold, + letterSpacing: -0.5, + ), + ), + const Spacer(), + // Actions + RiotzButton( + label: 'Enter the Chaos', + onPressed: () => context.go(AppRoutes.login), + ), + const SizedBox(height: 16), + RiotzButton( + label: 'Join the RIOT', + style: RiotzButtonStyle.outline, + onPressed: () => context.go(AppRoutes.signup), + ), + const SizedBox(height: 48), + ], + ), + ), + ); + } +} diff --git a/lib/features/theme_preview/presentation/pages/riotz_theme_preview_page.dart b/lib/features/theme_preview/presentation/pages/riotz_theme_preview_page.dart new file mode 100644 index 0000000..9783b55 --- /dev/null +++ b/lib/features/theme_preview/presentation/pages/riotz_theme_preview_page.dart @@ -0,0 +1,190 @@ +import 'package:flutter/material.dart'; + +import '../../../../core/theme/app_colors.dart'; +import '../../../../core/theme/app_motion.dart'; +import '../../../../shared/widgets/riotz_shell.dart'; + +class RiotzThemePreviewPage extends StatefulWidget { + const RiotzThemePreviewPage({super.key}); + + @override + State createState() => _RiotzThemePreviewPageState(); +} + +class _RiotzThemePreviewPageState extends State { + bool _switchValue = true; + bool _chipSelected = true; + double _slider = 42; + bool _animatedOn = false; + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + return RiotzShell( + title: 'RIOTZ // Theme Preview', + child: ListView( + padding: const EdgeInsets.all(16), + children: [ + Text('Typography', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + Text('Display Medium', style: theme.textTheme.displayMedium), + Text('Headline Medium', style: theme.textTheme.headlineMedium), + Text('Title Medium', style: theme.textTheme.titleMedium), + Text('Body Medium example text', style: theme.textTheme.bodyMedium), + Text('Label Large', style: theme.textTheme.labelLarge), + const SizedBox(height: 18), + Text('Color Tokens', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + Wrap( + spacing: 8, + runSpacing: 8, + children: const [ + _ColorSwatch(name: 'black', color: AppColors.black), + _ColorSwatch(name: 'blackRaised', color: AppColors.blackRaised), + _ColorSwatch(name: 'deepRed', color: AppColors.deepRed), + _ColorSwatch(name: 'neonRed', color: AppColors.neonRed), + _ColorSwatch(name: 'neonPurple', color: AppColors.neonPurple), + _ColorSwatch(name: 'white', color: AppColors.white), + ], + ), + const SizedBox(height: 18), + Text('Buttons', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + Wrap( + spacing: 8, + runSpacing: 8, + children: [ + FilledButton(onPressed: () {}, child: const Text('Filled')), + FilledButton.tonal(onPressed: () {}, child: const Text('Tonal')), + OutlinedButton(onPressed: () {}, child: const Text('Outlined')), + TextButton(onPressed: () {}, child: const Text('Text')), + ], + ), + const SizedBox(height: 18), + Text('Inputs', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + const TextField( + decoration: InputDecoration( + labelText: 'Username', + hintText: 'riotz_name', + ), + ), + const SizedBox(height: 10), + const TextField( + decoration: InputDecoration( + labelText: 'Bio', + hintText: 'Underground frequencies only', + ), + minLines: 2, + maxLines: 3, + ), + const SizedBox(height: 18), + Text('Cards / Controls', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + Card( + child: Padding( + padding: const EdgeInsets.all(12), + child: Column( + children: [ + SwitchListTile( + value: _switchValue, + onChanged: (v) => setState(() => _switchValue = v), + title: const Text('Glitch mode'), + contentPadding: EdgeInsets.zero, + ), + Slider( + value: _slider, + min: 0, + max: 100, + label: _slider.round().toString(), + onChanged: (v) => setState(() => _slider = v), + ), + Align( + alignment: Alignment.centerLeft, + child: FilterChip( + label: const Text('punk-rap'), + selected: _chipSelected, + onSelected: (v) => setState(() => _chipSelected = v), + ), + ), + ], + ), + ), + ), + const SizedBox(height: 18), + Text('Motion', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + FilledButton( + onPressed: () => setState(() => _animatedOn = !_animatedOn), + child: const Text('Trigger animation'), + ), + const SizedBox(height: 8), + AnimatedContainer( + duration: AppMotion.normal, + curve: AppMotion.emphasizedCurve, + height: 56, + width: _animatedOn ? double.infinity : 140, + decoration: BoxDecoration( + color: _animatedOn ? AppColors.neonRed : AppColors.blackSoft, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: AppColors.border), + ), + alignment: Alignment.center, + child: Text( + _animatedOn ? 'Chaos On' : 'Chaos Idle', + style: theme.textTheme.labelLarge, + ), + ), + const SizedBox(height: 18), + Text('Snackbar', style: theme.textTheme.titleLarge), + const SizedBox(height: 8), + OutlinedButton( + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('RIOTZ snack style preview')), + ); + }, + child: const Text('Show Snackbar'), + ), + ], + ), + ); + } +} + +class _ColorSwatch extends StatelessWidget { + const _ColorSwatch({ + required this.name, + required this.color, + }); + + final String name; + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: 110, + padding: const EdgeInsets.all(8), + decoration: BoxDecoration( + color: AppColors.blackSoft, + borderRadius: BorderRadius.circular(12), + border: Border.all(color: AppColors.border), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 26, + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(8), + ), + ), + const SizedBox(height: 6), + Text(name, style: Theme.of(context).textTheme.bodySmall), + ], + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..618a0ec --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import 'app/app.dart'; +import 'core/config/supabase_config.dart'; + +/// RIOTZ - Underground Social & Music Platform +/// +/// Main entry point for the application. +/// Tech Stack: Flutter frontend, Supabase backend. +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + + // Initialize Supabase configuration + // This expects SUPABASE_URL and SUPABASE_ANON_KEY to be provided via --dart-define + await SupabaseConfig.initialize(); + + runApp( + const ProviderScope( + child: RiotzApp(), + ), + ); +} diff --git a/lib/shared/widgets/riotz_shell.dart b/lib/shared/widgets/riotz_shell.dart new file mode 100644 index 0000000..96d3668 --- /dev/null +++ b/lib/shared/widgets/riotz_shell.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +import '../../core/theme/app_colors.dart'; + +class RiotzShell extends StatelessWidget { + const RiotzShell({ + required this.child, + this.title, + super.key, + }); + + final Widget child; + final String? title; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: title == null + ? null + : AppBar( + title: Text(title!), + ), + body: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [AppColors.black, AppColors.blackRaised], + ), + ), + child: SafeArea(child: child), + ), + ); + } +} diff --git a/linux/.gitignore b/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt new file mode 100644 index 0000000..a83a825 --- /dev/null +++ b/linux/CMakeLists.txt @@ -0,0 +1,128 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "yung_riotz") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.yung_riotz") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..ea3bde6 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,27 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); + g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); + flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); + g_autoptr(FlPluginRegistrar) gtk_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); + gtk_plugin_register_with_registrar(gtk_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); +} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..1e154fe --- /dev/null +++ b/linux/flutter/generated_plugins.cmake @@ -0,0 +1,28 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + file_selector_linux + flutter_secure_storage_linux + gtk + url_launcher_linux +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/linux/runner/CMakeLists.txt b/linux/runner/CMakeLists.txt new file mode 100644 index 0000000..e97dabc --- /dev/null +++ b/linux/runner/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the application ID. +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") diff --git a/linux/runner/main.cc b/linux/runner/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/linux/runner/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc new file mode 100644 index 0000000..19130fb --- /dev/null +++ b/linux/runner/my_application.cc @@ -0,0 +1,148 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Called when first Flutter frame received. +static void first_frame_cb(MyApplication* self, FlView* view) { + gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); +} + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "yung_riotz"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "yung_riotz"); + } + + gtk_window_set_default_size(window, 1280, 720); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + GdkRGBA background_color; + // Background defaults to black, override it here if necessary, e.g. #00000000 + // for transparent. + gdk_rgba_parse(&background_color, "#000000"); + fl_view_set_background_color(view, &background_color); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + // Show the window when Flutter renders. + // Requires the view to be realized so we can start rendering. + g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), + self); + gtk_widget_realize(GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + // Set the program name to the application ID, which helps various systems + // like GTK and desktop environments map this running application to its + // corresponding .desktop file. This ensures better integration by allowing + // the application to be recognized beyond its binary name. + g_set_prgname(APPLICATION_ID); + + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, "flags", + G_APPLICATION_NON_UNIQUE, nullptr)); +} diff --git a/linux/runner/my_application.h b/linux/runner/my_application.h new file mode 100644 index 0000000..db16367 --- /dev/null +++ b/linux/runner/my_application.h @@ -0,0 +1,21 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, + my_application, + MY, + APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/macos/.gitignore b/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..b43e7d0 --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,28 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import app_links +import audio_session +import file_picker +import file_selector_macos +import flutter_secure_storage_macos +import just_audio +import shared_preferences_foundation +import sqflite_darwin +import url_launcher_macos + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) + AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) + FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin")) + FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) + JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) +} diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ff9303a --- /dev/null +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* yung_riotz.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "yung_riotz.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* yung_riotz.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* yung_riotz.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yung_riotz.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/yung_riotz"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yung_riotz.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/yung_riotz"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/yung_riotz.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/yung_riotz"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + 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_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..a873e18 --- /dev/null +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..b3c1761 --- /dev/null +++ b/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..40579ca --- /dev/null +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = yung_riotz + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.yungRiotz + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2026 com.example. All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/macos/RunnerTests/RunnerTests.swift b/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..61f3bd1 --- /dev/null +++ b/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..2829fbb --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,1226 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + ansicolor: + dependency: transitive + description: + name: ansicolor + sha256: "50e982d500bc863e1d703448afdbf9e5a72eb48840a4f766fa361ffd6877055f" + url: "https://pub.dev" + source: hosted + version: "2.0.3" + app_links: + dependency: transitive + description: + name: app_links + sha256: "3462d9defc61565fde4944858b59bec5be2b9d5b05f20aed190adb3ad08a7abc" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + app_links_linux: + dependency: transitive + description: + name: app_links_linux + sha256: f5f7173a78609f3dfd4c2ff2c95bd559ab43c80a87dc6a095921d96c05688c81 + url: "https://pub.dev" + source: hosted + version: "1.0.3" + app_links_platform_interface: + dependency: transitive + description: + name: app_links_platform_interface + sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + app_links_web: + dependency: transitive + description: + name: app_links_web + sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555 + url: "https://pub.dev" + source: hosted + version: "1.0.4" + archive: + dependency: transitive + description: + name: archive + sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff + url: "https://pub.dev" + source: hosted + version: "4.0.9" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.dev" + source: hosted + version: "2.13.1" + audio_session: + dependency: transitive + description: + name: audio_session + sha256: "2b7fff16a552486d078bfc09a8cde19f426dc6d6329262b684182597bec5b1ac" + url: "https://pub.dev" + source: hosted + version: "0.1.25" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + sha256: "7c1183e361e5c8b0a0f21a28401eecdbde252441106a9816400dd4c2b2424916" + url: "https://pub.dev" + source: hosted + version: "3.4.1" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + sha256: "35814b016e37fbdc91f7ae18c8caf49ba5c88501813f73ce8a07027a395e2829" + url: "https://pub.dev" + source: hosted + version: "4.1.1" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + sha256: "980842f4e8e2535b8dbd3d5ca0b1f0ba66bf61d14cc3a17a9b4788a3685ba062" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + characters: + dependency: transitive + description: + name: characters + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" + source: hosted + version: "1.4.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937" + url: "https://pub.dev" + source: hosted + version: "0.3.5+2" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + csslib: + dependency: transitive + description: + name: csslib + sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd" + url: "https://pub.dev" + source: hosted + version: "1.0.9" + dart_jsonwebtoken: + dependency: transitive + description: + name: dart_jsonwebtoken + sha256: ad84e60181696513d04d5f2078e0bbc20365b911f46f647797317414bdc88fbe + url: "https://pub.dev" + source: hosted + version: "3.4.1" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + file_picker: + dependency: "direct main" + description: + name: file_picker + sha256: ab13ae8ef5580a411c458d6207b6774a6c237d77ac37011b13994879f68a8810 + url: "https://pub.dev" + source: hosted + version: "8.3.7" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0" + url: "https://pub.dev" + source: hosted + version: "0.9.4" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a" + url: "https://pub.dev" + source: hosted + version: "0.9.5" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85" + url: "https://pub.dev" + source: hosted + version: "2.7.0" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd" + url: "https://pub.dev" + source: hosted + version: "0.9.3+5" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386" + url: "https://pub.dev" + source: hosted + version: "3.4.1" + flutter_launcher_icons: + dependency: "direct dev" + description: + name: flutter_launcher_icons + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" + source: hosted + version: "0.13.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_native_splash: + dependency: "direct dev" + description: + name: flutter_native_splash + sha256: "4fb9f4113350d3a80841ce05ebf1976a36de622af7d19aca0ca9a9911c7ff002" + url: "https://pub.dev" + source: hosted + version: "2.4.7" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "38d1c268de9097ff59cf0e844ac38759fc78f76836d37edad06fa21e182055a0" + url: "https://pub.dev" + source: hosted + version: "2.0.34" + flutter_riverpod: + dependency: "direct main" + description: + name: flutter_riverpod + sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1" + url: "https://pub.dev" + source: hosted + version: "2.6.1" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" + url: "https://pub.dev" + source: hosted + version: "9.2.4" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709 + url: "https://pub.dev" + source: hosted + version: "3.1.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" + functions_client: + dependency: transitive + description: + name: functions_client + sha256: "94074d62167ae634127ef6095f536835063a7dc80f2b1aa306d2346ff9023996" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: d8f590a69729f719177ea68eb1e598295e8dbc41bbc247fed78b2c8a25660d7c + url: "https://pub.dev" + source: hosted + version: "16.3.0" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + sha256: ba03d03bcaa2f6cb7bd920e3b5027181db75ab524f8891c8bc3aa603885b8055 + url: "https://pub.dev" + source: hosted + version: "6.3.3" + gotrue: + dependency: transitive + description: + name: gotrue + sha256: "7a4172601553e61716f5c3dd243aa3297e13308e07eb85b7853c941ba585dcf5" + url: "https://pub.dev" + source: hosted + version: "2.20.0" + gtk: + dependency: transitive + description: + name: gtk + sha256: "4ff85b2a16724029dd9e5bbb5a94b6918f9973f74ba571c949d2002801879cf5" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + hooks: + dependency: transitive + description: + name: hooks + sha256: "025f060e86d2d4c3c47b56e33caf7f93bf9283340f26d23424ebcfccf34f621e" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + html: + dependency: transitive + description: + name: html + sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602" + url: "https://pub.dev" + source: hosted + version: "0.15.6" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + image: + dependency: transitive + description: + name: image + sha256: f9881ff4998044947ec38d098bc7c8316ae1186fa786eddffdb867b9bc94dfce + url: "https://pub.dev" + source: hosted + version: "4.8.0" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "91c025426c2881c551100bce834e201c835a170151545f58d17da5180ca7d9ac" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: d5b3e1774af29c9ab00103afb0d4614070f924d2e0057ac867ec98800114793f + url: "https://pub.dev" + source: hosted + version: "0.8.13+17" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: b9c4a438a9ff4f60808c9cf0039b93a42bb6c2211ef6ebb647394b2b3fa84588 + url: "https://pub.dev" + source: hosted + version: "0.8.13+6" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "86f0f15a309de7e1a552c12df9ce5b59fe927e71385329355aec4776c6a8ec91" + url: "https://pub.dev" + source: hosted + version: "0.2.2+1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" + url: "https://pub.dev" + source: hosted + version: "2.11.1" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae + url: "https://pub.dev" + source: hosted + version: "0.2.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" + jni: + dependency: transitive + description: + name: jni + sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f + url: "https://pub.dev" + source: hosted + version: "1.0.0" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8 + url: "https://pub.dev" + source: hosted + version: "4.11.0" + just_audio: + dependency: "direct main" + description: + name: just_audio + sha256: f978d5b4ccea08f267dae0232ec5405c1b05d3f3cd63f82097ea46c015d5c09e + url: "https://pub.dev" + source: hosted + version: "0.9.46" + just_audio_platform_interface: + dependency: transitive + description: + name: just_audio_platform_interface + sha256: "2532c8d6702528824445921c5ff10548b518b13f808c2e34c2fd54793b999a6a" + url: "https://pub.dev" + source: hosted + version: "4.6.0" + just_audio_web: + dependency: transitive + description: + name: just_audio_web + sha256: "6ba8a2a7e87d57d32f0f7b42856ade3d6a9fbe0f1a11fabae0a4f00bb73f0663" + url: "https://pub.dev" + source: hosted + version: "0.4.16" + jwt_decode: + dependency: transitive + description: + name: jwt_decode + sha256: d2e9f68c052b2225130977429d30f187aa1981d789c76ad104a32243cfdebfbb + url: "https://pub.dev" + source: hosted + version: "0.3.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + url: "https://pub.dev" + source: hosted + version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572" + url: "https://pub.dev" + source: hosted + version: "0.17.6" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" + url: "https://pub.dev" + source: hosted + version: "9.3.0" + octo_image: + dependency: transitive + description: + name: octo_image + sha256: "34faa6639a78c7e3cbe79be6f9f96535867e879748ade7d17c9b1ae7536293bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "92aa3841d083cc4b0f4709b5c74fd6409a3e6ba833ffc7dc6a8fee096366acf5" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + posix: + dependency: transitive + description: + name: posix + sha256: "185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07" + url: "https://pub.dev" + source: hosted + version: "6.5.0" + postgrest: + dependency: transitive + description: + name: postgrest + sha256: "9d61b3d4a88fcf9424d400127c54d49ed1b56ec30838fc0a33a64f31d4e694cc" + url: "https://pub.dev" + source: hosted + version: "2.7.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + realtime_client: + dependency: transitive + description: + name: realtime_client + sha256: "7dfccf372d2f55aacfeefb6186f65a06f3ffae383fe042dbeef9d85d33487576" + url: "https://pub.dev" + source: hosted + version: "2.7.3" + record_use: + dependency: transitive + description: + name: record_use + sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + retry: + dependency: transitive + description: + name: retry + sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + riverpod: + dependency: transitive + description: + name: riverpod + sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959" + url: "https://pub.dev" + source: hosted + version: "2.6.1" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" + url: "https://pub.dev" + source: hosted + version: "0.28.0" + shared_preferences: + dependency: transitive + description: + name: shared_preferences + sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf + url: "https://pub.dev" + source: hosted + version: "2.5.5" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 + url: "https://pub.dev" + source: hosted + version: "2.4.23" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + sqflite: + dependency: transitive + description: + name: sqflite + sha256: "564cfed0746fe53140c23b70b308e045c3b31f17778f2f326ccb7d804ea0250a" + url: "https://pub.dev" + source: hosted + version: "2.4.2+1" + sqflite_android: + dependency: transitive + description: + name: sqflite_android + sha256: "881e28efdcc9950fd8e9bb42713dcf1103e62a2e7168f23c9338d82db13dec40" + url: "https://pub.dev" + source: hosted + version: "2.4.2+3" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: f8a08a13fb8f0f8c590df89d745000bed44a673ed94bac846739e1a016875c21 + url: "https://pub.dev" + source: hosted + version: "2.5.7" + sqflite_darwin: + dependency: transitive + description: + name: sqflite_darwin + sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + sqflite_platform_interface: + dependency: transitive + description: + name: sqflite_platform_interface + sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + state_notifier: + dependency: transitive + description: + name: state_notifier + sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb + url: "https://pub.dev" + source: hosted + version: "1.0.0" + storage_client: + dependency: transitive + description: + name: storage_client + sha256: "4801e8ca219a35e51cbb30589aba5306667ae8935b792504595a45273cef0b18" + url: "https://pub.dev" + source: hosted + version: "2.5.2" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + supabase: + dependency: transitive + description: + name: supabase + sha256: "40e5a8833c8834e140ef53b60a6181849667eba9ca125acb7f8e24c6a769d418" + url: "https://pub.dev" + source: hosted + version: "2.10.6" + supabase_flutter: + dependency: "direct main" + description: + name: supabase_flutter + sha256: c02ce58abcaf86cb8055ad40bfd98bbf5b93fed3b5b56b8220d88ed03842818b + url: "https://pub.dev" + source: hosted + version: "2.12.4" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "63896c27e81b28f8cb4e69ead0d3e8f03f1d1e5fc531a3e579cabed6a2c7c9e5" + url: "https://pub.dev" + source: hosted + version: "3.4.0+1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" + url: "https://pub.dev" + source: hosted + version: "0.7.10" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: f63cbc48103236abf48e345e07a03ce5757ea86285ed313a6a032596ed9301e2 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.dev" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "3bb000251e55d4a209aa0e2e563309dc9bb2befea2295fd0cec1f51760aac572" + url: "https://pub.dev" + source: hosted + version: "6.3.29" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0" + url: "https://pub.dev" + source: hosted + version: "6.4.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a + url: "https://pub.dev" + source: hosted + version: "3.2.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" + url: "https://pub.dev" + source: hosted + version: "3.2.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34" + url: "https://pub.dev" + source: hosted + version: "2.4.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" + url: "https://pub.dev" + source: hosted + version: "3.1.5" + uuid: + dependency: transitive + description: + name: uuid + sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489" + url: "https://pub.dev" + source: hosted + version: "4.5.3" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360" + url: "https://pub.dev" + source: hosted + version: "15.2.0" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.dev" + source: hosted + version: "5.15.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + url: "https://pub.dev" + source: hosted + version: "6.6.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" + yet_another_json_isolate: + dependency: transitive + description: + name: yet_another_json_isolate + sha256: fe45897501fa156ccefbfb9359c9462ce5dec092f05e8a56109db30be864f01e + url: "https://pub.dev" + source: hosted + version: "2.1.0" +sdks: + dart: ">=3.11.5 <4.0.0" + flutter: ">=3.38.4" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..e60579e --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,54 @@ +name: yung_riotz +description: "RIOTZ - Underground Social & Music Platform" +publish_to: 'none' + +version: 1.0.0+1 + +environment: + sdk: ^3.11.5 + +dependencies: + flutter: + sdk: flutter + + cupertino_icons: ^1.0.8 + flutter_riverpod: ^2.6.1 + go_router: ^16.0.0 + supabase_flutter: ^2.10.3 + google_fonts: ^6.3.1 + image_picker: ^1.1.2 + just_audio: ^0.9.46 + file_picker: ^8.1.7 + cached_network_image: ^3.4.1 + flutter_secure_storage: ^9.2.2 + intl: ^0.19.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^6.0.0 + flutter_launcher_icons: ^0.13.1 + flutter_native_splash: ^2.4.1 + +flutter_launcher_icons: + android: true + ios: true + image_path: "assets/images/app_icon.png" + adaptive_icon_background: "#000000" + adaptive_icon_foreground: "assets/images/app_icon_foreground.png" + +flutter_native_splash: + color: "#000000" + image: "assets/images/splash.png" + branding: "assets/images/splash_branding.png" + color_dark: "#000000" + image_dark: "assets/images/splash.png" + android_12: + image: "assets/images/splash_android12.png" + icon_background_color: "#000000" + +flutter: + uses-material-design: true + assets: + - assets/images/ + - assets/textures/ diff --git a/supabase/migrations/20260506170000_riotz_production_schema.sql b/supabase/migrations/20260506170000_riotz_production_schema.sql new file mode 100644 index 0000000..ce49ddb --- /dev/null +++ b/supabase/migrations/20260506170000_riotz_production_schema.sql @@ -0,0 +1,596 @@ +-- RIOTZ production schema + RLS policies for Supabase +-- Safe to run as a single migration. + +begin; + +create extension if not exists "pgcrypto"; +create extension if not exists "citext"; + +-- ========================= +-- Utility functions +-- ========================= + +create or replace function public.set_updated_at() +returns trigger +language plpgsql +as $$ +begin + new.updated_at = timezone('utc', now()); + return new; +end; +$$; + +create or replace function public.is_admin(_uid uuid) +returns boolean +language sql +stable +as $$ + select exists ( + select 1 + from public.admin_users au + where au.user_id = _uid + ); +$$; + +-- ========================= +-- Tables +-- ========================= + +create table if not exists public.admin_users ( + user_id uuid primary key references auth.users(id) on delete cascade, + created_at timestamptz not null default timezone('utc', now()) +); + +create table if not exists public.profiles ( + user_id uuid primary key references auth.users(id) on delete cascade, + username citext not null unique, + bio text not null default '', + avatar_url text not null default '', + banned boolean not null default false, + created_at timestamptz not null default timezone('utc', now()), + updated_at timestamptz not null default timezone('utc', now()), + constraint profiles_username_len check (char_length(username::text) between 3 and 32), + constraint profiles_bio_len check (char_length(bio) <= 280) +); + +create table if not exists public.posts ( + id uuid primary key default gen_random_uuid(), + user_id uuid not null references auth.users(id) on delete cascade, + caption text not null default '', + image_url text not null, + likes_count integer not null default 0 check (likes_count >= 0), + featured boolean not null default false, + created_at timestamptz not null default timezone('utc', now()), + updated_at timestamptz not null default timezone('utc', now()), + constraint posts_caption_len check (char_length(caption) <= 2800) +); + +create table if not exists public.post_likes ( + post_id uuid not null references public.posts(id) on delete cascade, + user_id uuid not null references auth.users(id) on delete cascade, + created_at timestamptz not null default timezone('utc', now()), + primary key (post_id, user_id) +); + +create table if not exists public.comments ( + id uuid primary key default gen_random_uuid(), + post_id uuid not null references public.posts(id) on delete cascade, + user_id uuid not null references auth.users(id) on delete cascade, + content text not null, + created_at timestamptz not null default timezone('utc', now()), + updated_at timestamptz not null default timezone('utc', now()), + constraint comments_content_len check (char_length(content) between 1 and 1200) +); + +create table if not exists public.tracks ( + id uuid primary key default gen_random_uuid(), + user_id uuid not null references auth.users(id) on delete cascade, + title text not null, + audio_url text not null, + tags text not null default '', + featured boolean not null default false, + created_at timestamptz not null default timezone('utc', now()), + updated_at timestamptz not null default timezone('utc', now()), + constraint tracks_title_len check (char_length(title) between 1 and 120), + constraint tracks_tags_len check (char_length(tags) <= 256) +); + +create table if not exists public.chats ( + id uuid primary key default gen_random_uuid(), + name text not null, + is_group boolean not null default true, + created_by uuid not null references auth.users(id) on delete cascade, + created_at timestamptz not null default timezone('utc', now()), + updated_at timestamptz not null default timezone('utc', now()), + constraint chats_name_len check (char_length(name) between 1 and 120) +); + +create table if not exists public.chat_members ( + chat_id uuid not null references public.chats(id) on delete cascade, + user_id uuid not null references auth.users(id) on delete cascade, + role text not null default 'member', + joined_at timestamptz not null default timezone('utc', now()), + primary key (chat_id, user_id), + constraint chat_members_role_valid check (role in ('owner', 'admin', 'member')) +); + +create table if not exists public.messages ( + id uuid primary key default gen_random_uuid(), + chat_id uuid not null references public.chats(id) on delete cascade, + sender_id uuid not null references auth.users(id) on delete cascade, + content text not null, + created_at timestamptz not null default timezone('utc', now()), + updated_at timestamptz not null default timezone('utc', now()), + constraint messages_content_len check (char_length(content) between 1 and 1200) +); + +-- ========================= +-- Indexes +-- ========================= + +create index if not exists idx_profiles_username on public.profiles (username); +create index if not exists idx_profiles_banned on public.profiles (banned); + +create index if not exists idx_posts_user_id_created_at on public.posts (user_id, created_at desc); +create index if not exists idx_posts_created_at on public.posts (created_at desc); +create index if not exists idx_posts_likes_count on public.posts (likes_count desc); +create index if not exists idx_posts_featured on public.posts (featured) where featured = true; + +create index if not exists idx_post_likes_user_id on public.post_likes (user_id); +create index if not exists idx_post_likes_post_id on public.post_likes (post_id); + +create index if not exists idx_comments_post_id_created_at on public.comments (post_id, created_at asc); +create index if not exists idx_comments_user_id_created_at on public.comments (user_id, created_at desc); + +create index if not exists idx_tracks_user_id_created_at on public.tracks (user_id, created_at desc); +create index if not exists idx_tracks_created_at on public.tracks (created_at desc); +create index if not exists idx_tracks_featured on public.tracks (featured) where featured = true; + +create index if not exists idx_chat_members_user_id on public.chat_members (user_id); +create index if not exists idx_messages_chat_id_created_at on public.messages (chat_id, created_at asc); +create index if not exists idx_messages_sender_id_created_at on public.messages (sender_id, created_at desc); + +-- ========================= +-- Triggers +-- ========================= + +drop trigger if exists trg_profiles_updated_at on public.profiles; +create trigger trg_profiles_updated_at +before update on public.profiles +for each row execute procedure public.set_updated_at(); + +drop trigger if exists trg_posts_updated_at on public.posts; +create trigger trg_posts_updated_at +before update on public.posts +for each row execute procedure public.set_updated_at(); + +drop trigger if exists trg_comments_updated_at on public.comments; +create trigger trg_comments_updated_at +before update on public.comments +for each row execute procedure public.set_updated_at(); + +drop trigger if exists trg_tracks_updated_at on public.tracks; +create trigger trg_tracks_updated_at +before update on public.tracks +for each row execute procedure public.set_updated_at(); + +drop trigger if exists trg_chats_updated_at on public.chats; +create trigger trg_chats_updated_at +before update on public.chats +for each row execute procedure public.set_updated_at(); + +drop trigger if exists trg_messages_updated_at on public.messages; +create trigger trg_messages_updated_at +before update on public.messages +for each row execute procedure public.set_updated_at(); + +-- Keep posts.likes_count in sync from post_likes +create or replace function public.handle_post_like_delta() +returns trigger +language plpgsql +as $$ +begin + if tg_op = 'INSERT' then + update public.posts + set likes_count = likes_count + 1 + where id = new.post_id; + return new; + elsif tg_op = 'DELETE' then + update public.posts + set likes_count = greatest(0, likes_count - 1) + where id = old.post_id; + return old; + end if; + return null; +end; +$$; + +drop trigger if exists trg_post_like_delta on public.post_likes; +create trigger trg_post_like_delta +after insert or delete on public.post_likes +for each row execute procedure public.handle_post_like_delta(); + +-- Auto-create profile on new auth user +create or replace function public.handle_new_user_profile() +returns trigger +language plpgsql +security definer +set search_path = public +as $$ +declare + suggested_username text; +begin + suggested_username := + coalesce(new.raw_user_meta_data ->> 'username', split_part(new.email, '@', 1), 'riot_user'); + suggested_username := left(regexp_replace(lower(suggested_username), '[^a-z0-9_]', '', 'g'), 32); + if char_length(suggested_username) < 3 then + suggested_username := 'riot_' || substring(new.id::text from 1 for 8); + end if; + + insert into public.profiles (user_id, username) + values (new.id, suggested_username) + on conflict (user_id) do nothing; + return new; +end; +$$; + +drop trigger if exists on_auth_user_created_profile on auth.users; +create trigger on_auth_user_created_profile +after insert on auth.users +for each row execute procedure public.handle_new_user_profile(); + +-- ========================= +-- RLS +-- ========================= + +alter table public.admin_users enable row level security; +alter table public.profiles enable row level security; +alter table public.posts enable row level security; +alter table public.post_likes enable row level security; +alter table public.comments enable row level security; +alter table public.tracks enable row level security; +alter table public.chats enable row level security; +alter table public.chat_members enable row level security; +alter table public.messages enable row level security; + +-- admin_users (self can read own admin row; admins can read all) +drop policy if exists admin_users_select_self_or_admin on public.admin_users; +create policy admin_users_select_self_or_admin +on public.admin_users +for select +using (auth.uid() = user_id or public.is_admin(auth.uid())); + +-- profiles +drop policy if exists profiles_public_read on public.profiles; +create policy profiles_public_read +on public.profiles +for select +using (true); + +drop policy if exists profiles_insert_self on public.profiles; +create policy profiles_insert_self +on public.profiles +for insert +with check (auth.uid() = user_id); + +drop policy if exists profiles_update_self_or_admin on public.profiles; +create policy profiles_update_self_or_admin +on public.profiles +for update +using (auth.uid() = user_id or public.is_admin(auth.uid())) +with check (auth.uid() = user_id or public.is_admin(auth.uid())); + +drop policy if exists profiles_delete_admin_only on public.profiles; +create policy profiles_delete_admin_only +on public.profiles +for delete +using (public.is_admin(auth.uid())); + +-- posts +drop policy if exists posts_public_read on public.posts; +create policy posts_public_read +on public.posts +for select +using (true); + +drop policy if exists posts_insert_self_not_banned on public.posts; +create policy posts_insert_self_not_banned +on public.posts +for insert +with check ( + auth.uid() = user_id + and not exists ( + select 1 from public.profiles p + where p.user_id = auth.uid() and p.banned = true + ) +); + +drop policy if exists posts_update_owner_or_admin on public.posts; +create policy posts_update_owner_or_admin +on public.posts +for update +using (auth.uid() = user_id or public.is_admin(auth.uid())) +with check (auth.uid() = user_id or public.is_admin(auth.uid())); + +drop policy if exists posts_delete_owner_or_admin on public.posts; +create policy posts_delete_owner_or_admin +on public.posts +for delete +using (auth.uid() = user_id or public.is_admin(auth.uid())); + +-- post_likes +drop policy if exists post_likes_public_read on public.post_likes; +create policy post_likes_public_read +on public.post_likes +for select +using (true); + +drop policy if exists post_likes_insert_self on public.post_likes; +create policy post_likes_insert_self +on public.post_likes +for insert +with check (auth.uid() = user_id); + +drop policy if exists post_likes_delete_self_or_admin on public.post_likes; +create policy post_likes_delete_self_or_admin +on public.post_likes +for delete +using (auth.uid() = user_id or public.is_admin(auth.uid())); + +-- comments +drop policy if exists comments_public_read on public.comments; +create policy comments_public_read +on public.comments +for select +using (true); + +drop policy if exists comments_insert_self_not_banned on public.comments; +create policy comments_insert_self_not_banned +on public.comments +for insert +with check ( + auth.uid() = user_id + and not exists ( + select 1 from public.profiles p + where p.user_id = auth.uid() and p.banned = true + ) +); + +drop policy if exists comments_update_owner_or_admin on public.comments; +create policy comments_update_owner_or_admin +on public.comments +for update +using (auth.uid() = user_id or public.is_admin(auth.uid())) +with check (auth.uid() = user_id or public.is_admin(auth.uid())); + +drop policy if exists comments_delete_owner_or_admin on public.comments; +create policy comments_delete_owner_or_admin +on public.comments +for delete +using (auth.uid() = user_id or public.is_admin(auth.uid())); + +-- tracks +drop policy if exists tracks_public_read on public.tracks; +create policy tracks_public_read +on public.tracks +for select +using (true); + +drop policy if exists tracks_insert_self_not_banned on public.tracks; +create policy tracks_insert_self_not_banned +on public.tracks +for insert +with check ( + auth.uid() = user_id + and not exists ( + select 1 from public.profiles p + where p.user_id = auth.uid() and p.banned = true + ) +); + +drop policy if exists tracks_update_owner_or_admin on public.tracks; +create policy tracks_update_owner_or_admin +on public.tracks +for update +using (auth.uid() = user_id or public.is_admin(auth.uid())) +with check (auth.uid() = user_id or public.is_admin(auth.uid())); + +drop policy if exists tracks_delete_owner_or_admin on public.tracks; +create policy tracks_delete_owner_or_admin +on public.tracks +for delete +using (auth.uid() = user_id or public.is_admin(auth.uid())); + +-- chats +drop policy if exists chats_member_or_admin_read on public.chats; +create policy chats_member_or_admin_read +on public.chats +for select +using ( + public.is_admin(auth.uid()) + or exists ( + select 1 from public.chat_members cm + where cm.chat_id = id and cm.user_id = auth.uid() + ) +); + +drop policy if exists chats_create_self on public.chats; +create policy chats_create_self +on public.chats +for insert +with check (auth.uid() = created_by); + +drop policy if exists chats_update_owner_or_admin on public.chats; +create policy chats_update_owner_or_admin +on public.chats +for update +using (auth.uid() = created_by or public.is_admin(auth.uid())) +with check (auth.uid() = created_by or public.is_admin(auth.uid())); + +drop policy if exists chats_delete_owner_or_admin on public.chats; +create policy chats_delete_owner_or_admin +on public.chats +for delete +using (auth.uid() = created_by or public.is_admin(auth.uid())); + +-- chat_members +drop policy if exists chat_members_member_or_admin_read on public.chat_members; +create policy chat_members_member_or_admin_read +on public.chat_members +for select +using ( + public.is_admin(auth.uid()) + or user_id = auth.uid() + or exists ( + select 1 from public.chat_members cm + where cm.chat_id = chat_id and cm.user_id = auth.uid() + ) +); + +drop policy if exists chat_members_owner_or_admin_manage on public.chat_members; +create policy chat_members_owner_or_admin_manage +on public.chat_members +for all +using ( + public.is_admin(auth.uid()) + or exists ( + select 1 from public.chat_members cm + where cm.chat_id = chat_id and cm.user_id = auth.uid() and cm.role in ('owner', 'admin') + ) +) +with check ( + public.is_admin(auth.uid()) + or exists ( + select 1 from public.chat_members cm + where cm.chat_id = chat_id and cm.user_id = auth.uid() and cm.role in ('owner', 'admin') + ) +); + +-- messages +drop policy if exists messages_chat_member_read on public.messages; +create policy messages_chat_member_read +on public.messages +for select +using ( + public.is_admin(auth.uid()) + or exists ( + select 1 from public.chat_members cm + where cm.chat_id = chat_id and cm.user_id = auth.uid() + ) +); + +drop policy if exists messages_chat_member_insert on public.messages; +create policy messages_chat_member_insert +on public.messages +for insert +with check ( + auth.uid() = sender_id + and exists ( + select 1 from public.chat_members cm + where cm.chat_id = chat_id and cm.user_id = auth.uid() + ) +); + +drop policy if exists messages_sender_or_admin_delete on public.messages; +create policy messages_sender_or_admin_delete +on public.messages +for delete +using (auth.uid() = sender_id or public.is_admin(auth.uid())); + +-- ========================= +-- Storage buckets + policies +-- ========================= + +insert into storage.buckets (id, name, public) +values + ('avatars', 'avatars', true), + ('post-images', 'post-images', true), + ('tracks', 'tracks', true) +on conflict (id) do nothing; + +-- Read policies (public) +drop policy if exists avatars_public_read on storage.objects; +create policy avatars_public_read +on storage.objects +for select +using (bucket_id = 'avatars'); + +drop policy if exists post_images_public_read on storage.objects; +create policy post_images_public_read +on storage.objects +for select +using (bucket_id = 'post-images'); + +drop policy if exists tracks_public_read on storage.objects; +create policy tracks_public_read +on storage.objects +for select +using (bucket_id = 'tracks'); + +-- Upload policies (owner only) +drop policy if exists avatars_owner_upload on storage.objects; +create policy avatars_owner_upload +on storage.objects +for insert +with check ( + bucket_id = 'avatars' + and auth.uid() is not null + and (storage.foldername(name))[1] = 'avatars' + and (storage.foldername(name))[2] = auth.uid()::text +); + +drop policy if exists post_images_owner_upload on storage.objects; +create policy post_images_owner_upload +on storage.objects +for insert +with check ( + bucket_id = 'post-images' + and auth.uid() is not null + and (storage.foldername(name))[1] = 'posts' + and (storage.foldername(name))[2] = auth.uid()::text +); + +drop policy if exists tracks_owner_upload on storage.objects; +create policy tracks_owner_upload +on storage.objects +for insert +with check ( + bucket_id = 'tracks' + and auth.uid() is not null + and (storage.foldername(name))[1] = 'tracks' + and (storage.foldername(name))[2] = auth.uid()::text +); + +-- Update/Delete object policies +drop policy if exists storage_owner_or_admin_update on storage.objects; +create policy storage_owner_or_admin_update +on storage.objects +for update +using ( + auth.uid() is not null + and ( + ((storage.foldername(name))[2] = auth.uid()::text and bucket_id in ('avatars', 'post-images', 'tracks')) + or public.is_admin(auth.uid()) + ) +) +with check ( + auth.uid() is not null + and ( + ((storage.foldername(name))[2] = auth.uid()::text and bucket_id in ('avatars', 'post-images', 'tracks')) + or public.is_admin(auth.uid()) + ) +); + +drop policy if exists storage_owner_or_admin_delete on storage.objects; +create policy storage_owner_or_admin_delete +on storage.objects +for delete +using ( + auth.uid() is not null + and ( + ((storage.foldername(name))[2] = auth.uid()::text and bucket_id in ('avatars', 'post-images', 'tracks')) + or public.is_admin(auth.uid()) + ) +); + +commit; diff --git a/supabase_schema.sql b/supabase_schema.sql new file mode 100644 index 0000000..6d1cd78 --- /dev/null +++ b/supabase_schema.sql @@ -0,0 +1,149 @@ +-- RIOTZ SUPABASE DATABASE SCHEMA +-- Tech Stack: PostgreSQL, Supabase Auth, Storage + +-- 1. EXTENSIONS +create extension if not exists "uuid-ossp"; + +-- 2. TABLES + +-- PROFILES: Core user identity +create table public.profiles ( + user_id uuid references auth.users on delete cascade primary key, + username text unique not null, + bio text, + avatar_url text, + featured boolean default false, + banned boolean default false, + created_at timestamp with time zone default now(), + updated_at timestamp with time zone default now() +); + +-- POSTS: Visual manifestations +create table public.posts ( + id uuid default uuid_generate_v4() primary key, + user_id uuid references public.profiles(user_id) on delete cascade not null, + image_url text not null, + caption text, + likes_count int default 0, + featured boolean default false, + created_at timestamp with time zone default now() +); + +-- POST LIKES: Engagement tracking +create table public.post_likes ( + user_id uuid references public.profiles(user_id) on delete cascade not null, + post_id uuid references public.posts(id) on delete cascade not null, + created_at timestamp with time zone default now(), + primary key (user_id, post_id) +); + +-- TRACKS: Sonic broadcasts +create table public.tracks ( + id uuid default uuid_generate_v4() primary key, + user_id uuid references public.profiles(user_id) on delete cascade not null, + title text not null, + audio_url text not null, + genre_tag text default 'UNKNOWN', + plays int default 0, + featured boolean default false, + created_at timestamp with time zone default now() +); + +-- COMMENTS: Chaos discourse +create table public.comments ( + id uuid default uuid_generate_v4() primary key, + post_id uuid references public.posts(id) on delete cascade not null, + user_id uuid references public.profiles(user_id) on delete cascade not null, + content text not null, + created_at timestamp with time zone default now() +); + +-- BANS: Network exclusion records +create table public.bans ( + id uuid default uuid_generate_v4() primary key, + user_id uuid references public.profiles(user_id) on delete cascade not null, + reason text, + banned_by uuid references public.profiles(user_id), + created_at timestamp with time zone default now() +); + +-- FEATURED CONTENT: Curated highlights +create table public.featured_content ( + id uuid default uuid_generate_v4() primary key, + content_type text not null check (content_type in ('artist', 'post', 'track')), + content_id uuid not null, + priority int default 0, + created_at timestamp with time zone default now() +); + +-- 3. FUNCTIONS & TRIGGERS + +-- Automatically create profile on signup +create or replace function public.handle_new_user() +returns trigger as $$ +begin + insert into public.profiles (user_id, username, avatar_url) + values (new.id, split_part(new.email, '@', 1), new.raw_user_meta_data->>'avatar_url'); + return new; +end; +$$ language plpgsql security definer; + +create trigger on_auth_user_created + after insert on auth.users + for each row execute procedure public.handle_new_user(); + +-- Auto-update likes_count on posts +create or replace function public.update_post_likes_count() +returns trigger as $$ +begin + if (TG_OP = 'INSERT') then + update public.posts set likes_count = likes_count + 1 where id = new.post_id; + elsif (TG_OP = 'DELETE') then + update public.posts set likes_count = likes_count - 1 where id = old.post_id; + end if; + return null; +end; +$$ language plpgsql security definer; + +create trigger on_like_changed + after insert or delete on public.post_likes + for each row execute procedure public.update_post_likes_count(); + +-- Increment plays RPC +create or replace function public.increment_track_plays(track_id uuid) +returns void as $$ +begin + update public.tracks set plays = plays + 1 where id = track_id; +end; +$$ language plpgsql security definer; + +-- 4. SECURITY (RLS) + +alter table public.profiles enable row level security; +alter table public.posts enable row level security; +alter table public.tracks enable row level security; +alter table public.post_likes enable row level security; +alter table public.comments enable row level security; + +-- Profiles: Public read, owner update +create policy "Public profiles are viewable by everyone." on public.profiles for select using (true); +create policy "Users can update own profile." on public.profiles for update using (auth.uid() = user_id); + +-- Posts: Public read, Auth create, Owner delete +create policy "Posts are viewable by everyone." on public.posts for select using (true); +create policy "Authenticated users can create posts." on public.posts for insert with check (auth.role() = 'authenticated'); +create policy "Users can delete own posts." on public.posts for delete using (auth.uid() = user_id); + +-- Tracks: Public read, Auth create +create policy "Tracks are viewable by everyone." on public.tracks for select using (true); +create policy "Authenticated users can upload tracks." on public.tracks for insert with check (auth.role() = 'authenticated'); + +-- Likes: Authenticated management +create policy "Users can view likes." on public.post_likes for select using (true); +create policy "Users can manage own likes." on public.post_likes for all using (auth.uid() = user_id); + +-- 5. INDEXES for Performance +create index idx_posts_user_id on public.posts(user_id); +create index idx_posts_created_at on public.posts(created_at desc); +create index idx_tracks_plays on public.tracks(plays desc); +create index idx_comments_post_id on public.comments(post_id); diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..2fefddf --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,30 @@ +// 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_test/flutter_test.dart'; + +import 'package:yung_riotz/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // 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); + }); +} diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..9cea3bb --- /dev/null +++ b/web/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + yung_riotz + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..e386862 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "yung_riotz", + "short_name": "yung_riotz", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "n3w 3r4++", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 0000000..9347754 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(yung_riotz LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "yung_riotz") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..903f489 --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..bf6dc58 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,23 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + AppLinksPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("AppLinksPluginCApi")); + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); + FlutterSecureStorageWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..843e0e2 --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,28 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + app_links + file_selector_windows + flutter_secure_storage_windows + url_launcher_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 0000000..eed2266 --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "yung_riotz" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "yung_riotz" "\0" + VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "yung_riotz.exe" "\0" + VALUE "ProductName", "yung_riotz" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..955ee30 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 0000000..999787f --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"yung_riotz", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..153653e --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 0000000..3a0b465 --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + unsigned int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 0000000..60608d0 --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 0000000..e901dde --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_