diff --git a/.gitmodules b/.gitmodules index e68c961a..cce7dee2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,7 @@ path = swingmusic-webclient url = https://github.com/Dvorinka/swingmusic-extended-webclient branch = master +[submodule "swingmusic-mobile"] + path = swingmusic_mobile + url = https://github.com/Dvorinka/swingmusic-mobile.git + branch = master diff --git a/swingmusic_mobile/.gitignore b/swingmusic_mobile/.gitignore new file mode 100644 index 00000000..db984b4a --- /dev/null +++ b/swingmusic_mobile/.gitignore @@ -0,0 +1,157 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# VS Code related +.vscode/ +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release +/android/gradlew +/android/gradlew.bat +/android/local.properties +/android/.gradle/ +/android/captures/ +/android/gradlew +/android/gradlew.bat +/android/local.properties +/android/.gradle/ + +# iOS/Xcode related +/ios/Flutter/Flutter.framework +/ios/Flutter/Flutter.podspec +/ios/.symlinks/ +/ios/Pods/ +/ios/.symlinks/ +/ios/Pods/ +/ios/Flutter/App.framework +/ios/Flutter/Flutter.framework +/ios/Flutter/Flutter.podspec +/ios/Flutter/Generated.xcconfig +/ios/Flutter/ephemeral/ +/ios/app.flx +/ios/app.zip +/ios/app_flutter/ +/ios/flutter_assets/ +/ios/service_account.json + +# Web related +/web/ + +# Windows related +/windows/flutter/generated_plugin_registrant.cc +/windows/flutter/generated_plugin_registrant.h +/windows/flutter/generated_plugins.cmake + +# Linux related +/linux/flutter/generated_plugin_registrant.cc +/linux/flutter/generated_plugin_registrant.h +/linux/flutter/generated_plugins.cmake + +# macOS related +/macos/Flutter/Generated.xcconfig +/macos/Flutter/ephemeral/ +/macos/Flutter/flutter_assets/ +/macos/Flutter/App.framework +/macos/Flutter/Flutter.framework +/macos/Flutter/Flutter.podspec + +# Test coverage +/coverage/ + +# Environment files +.env +.env.local +.env.development +.env.test +.env.production + +# API keys and secrets +**/api_keys.dart +**/secrets.dart +**/config.dart + +# Temporary files +*.tmp +*.temp +*.bak +*.backup + +# Logs +logs/ +*.log + +# Database files +*.db +*.sqlite +*.sqlite3 + +# Generated files +*.g.dart +*.freezed.dart +*.mocks.dart + +# Node.js (if using for build tools) +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Firebase +google-services.json +GoogleService-Info.plist + +# Localization +*.arb + +# Assets that should be managed separately +/assets/audio/ +/assets/images/large/ +*.mp3 +*.flac +*.wav +*.aac +*.ogg +*.m4a diff --git a/swingmusic_mobile/.metadata b/swingmusic_mobile/.metadata new file mode 100644 index 00000000..83b34ebb --- /dev/null +++ b/swingmusic_mobile/.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: "f6ff1529fd6d8af5f706051d9251ac9231c83407" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: android + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: ios + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: linux + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: macos + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: web + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: windows + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + + # 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/swingmusic_mobile/README.md b/swingmusic_mobile/README.md new file mode 100644 index 00000000..49d435b1 --- /dev/null +++ b/swingmusic_mobile/README.md @@ -0,0 +1,16 @@ +# swingmusic_mobile + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/swingmusic_mobile/analysis_options.yaml b/swingmusic_mobile/analysis_options.yaml new file mode 100644 index 00000000..0d290213 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/android/.gitignore b/swingmusic_mobile/android/.gitignore new file mode 100644 index 00000000..be3943c9 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/android/app/build.gradle.kts b/swingmusic_mobile/android/app/build.gradle.kts new file mode 100644 index 00000000..4edb8304 --- /dev/null +++ b/swingmusic_mobile/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +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.dvorinka.swingmusic.swingmusic_mobile" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.dvorinka.swingmusic.swingmusic_mobile" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/swingmusic_mobile/android/app/src/debug/AndroidManifest.xml b/swingmusic_mobile/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/swingmusic_mobile/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/swingmusic_mobile/android/app/src/main/AndroidManifest.xml b/swingmusic_mobile/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2888c9fd --- /dev/null +++ b/swingmusic_mobile/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/swingmusic_mobile/android/app/src/main/kotlin/com/dvorinka/swingmusic/swingmusic_mobile/MainActivity.kt b/swingmusic_mobile/android/app/src/main/kotlin/com/dvorinka/swingmusic/swingmusic_mobile/MainActivity.kt new file mode 100644 index 00000000..cf523c39 --- /dev/null +++ b/swingmusic_mobile/android/app/src/main/kotlin/com/dvorinka/swingmusic/swingmusic_mobile/MainActivity.kt @@ -0,0 +1,5 @@ +package com.dvorinka.swingmusic.swingmusic_mobile + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/swingmusic_mobile/android/app/src/main/res/drawable-v21/launch_background.xml b/swingmusic_mobile/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/swingmusic_mobile/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/swingmusic_mobile/android/app/src/main/res/drawable/launch_background.xml b/swingmusic_mobile/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/swingmusic_mobile/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/swingmusic_mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/swingmusic_mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..db77bb4b Binary files /dev/null and b/swingmusic_mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/swingmusic_mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/swingmusic_mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..17987b79 Binary files /dev/null and b/swingmusic_mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/swingmusic_mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/swingmusic_mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..09d43914 Binary files /dev/null and b/swingmusic_mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/swingmusic_mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/swingmusic_mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..d5f1c8d3 Binary files /dev/null and b/swingmusic_mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/swingmusic_mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/swingmusic_mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..4d6372ee Binary files /dev/null and b/swingmusic_mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/swingmusic_mobile/android/app/src/main/res/values-night/styles.xml b/swingmusic_mobile/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/swingmusic_mobile/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/swingmusic_mobile/android/app/src/main/res/values/styles.xml b/swingmusic_mobile/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/swingmusic_mobile/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/swingmusic_mobile/android/app/src/profile/AndroidManifest.xml b/swingmusic_mobile/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/swingmusic_mobile/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/swingmusic_mobile/android/build.gradle.kts b/swingmusic_mobile/android/build.gradle.kts new file mode 100644 index 00000000..dbee657b --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/android/gradle.properties b/swingmusic_mobile/android/gradle.properties new file mode 100644 index 00000000..fbee1d8c --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/android/gradle/wrapper/gradle-wrapper.properties b/swingmusic_mobile/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..e4ef43fb --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/android/settings.gradle.kts b/swingmusic_mobile/android/settings.gradle.kts new file mode 100644 index 00000000..ca7fe065 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/ios/.gitignore b/swingmusic_mobile/ios/.gitignore new file mode 100644 index 00000000..7a7f9873 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/ios/Flutter/AppFrameworkInfo.plist b/swingmusic_mobile/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..1dc6cf76 --- /dev/null +++ b/swingmusic_mobile/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 13.0 + + diff --git a/swingmusic_mobile/ios/Flutter/Debug.xcconfig b/swingmusic_mobile/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..592ceee8 --- /dev/null +++ b/swingmusic_mobile/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/swingmusic_mobile/ios/Flutter/Release.xcconfig b/swingmusic_mobile/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..592ceee8 --- /dev/null +++ b/swingmusic_mobile/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/swingmusic_mobile/ios/Runner.xcodeproj/project.pbxproj b/swingmusic_mobile/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..de0d01fa --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,616 @@ +// !$*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 */; }; + 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 = ""; }; + 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 */, + 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 */, + ); + 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.dvorinka.swingmusic.swingmusicMobile; + 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.dvorinka.swingmusic.swingmusicMobile.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.dvorinka.swingmusic.swingmusicMobile.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.dvorinka.swingmusic.swingmusicMobile.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.dvorinka.swingmusic.swingmusicMobile; + 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.dvorinka.swingmusic.swingmusicMobile; + 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/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/swingmusic_mobile/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/swingmusic_mobile/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..e3773d42 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swingmusic_mobile/ios/Runner.xcworkspace/contents.xcworkspacedata b/swingmusic_mobile/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/swingmusic_mobile/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/swingmusic_mobile/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/swingmusic_mobile/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/swingmusic_mobile/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/swingmusic_mobile/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/swingmusic_mobile/ios/Runner/AppDelegate.swift b/swingmusic_mobile/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..62666446 --- /dev/null +++ b/swingmusic_mobile/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d36b1fab --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 00000000..dc9ada47 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 00000000..7353c41e Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 00000000..6ed2d933 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 00000000..4cd7b009 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 00000000..fe730945 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 00000000..321773cd Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 00000000..502f463a Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 00000000..e9f5fea2 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 00000000..84ac32ae Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 00000000..8953cba0 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 00000000..0467bf12 Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..0bedcf2f --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/swingmusic_mobile/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..89c2725b --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/ios/Runner/Base.lproj/LaunchScreen.storyboard b/swingmusic_mobile/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/swingmusic_mobile/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swingmusic_mobile/ios/Runner/Base.lproj/Main.storyboard b/swingmusic_mobile/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/swingmusic_mobile/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swingmusic_mobile/ios/Runner/Info.plist b/swingmusic_mobile/ios/Runner/Info.plist new file mode 100644 index 00000000..d8e1cf11 --- /dev/null +++ b/swingmusic_mobile/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Swingmusic Mobile + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + swingmusic_mobile + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/swingmusic_mobile/ios/Runner/Runner-Bridging-Header.h b/swingmusic_mobile/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/swingmusic_mobile/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/swingmusic_mobile/ios/RunnerTests/RunnerTests.swift b/swingmusic_mobile/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..86a7c3b1 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/lib/core/constants/app_constants.dart b/swingmusic_mobile/lib/core/constants/app_constants.dart new file mode 100644 index 00000000..b029087c --- /dev/null +++ b/swingmusic_mobile/lib/core/constants/app_constants.dart @@ -0,0 +1,71 @@ +class AppConstants { + // App Info + static const String appName = 'SwingMusic'; + static const String appVersion = '1.0.0'; + + // API Configuration + static const String defaultApiUrl = 'http://localhost:8181'; + static const Duration apiTimeout = Duration(seconds: 30); + static const int maxRetries = 3; + + // Audio Configuration + static const Duration audioFadeDuration = Duration(milliseconds: 500); + static const int maxAudioCacheSize = 100 * 1024 * 1024; // 100MB + static const String audioCacheKey = 'audio_cache'; + + // UI Configuration + static const double defaultPadding = 16.0; + static const double smallPadding = 8.0; + static const double largePadding = 24.0; + static const double borderRadius = 12.0; + static const double cardBorderRadius = 16.0; + + // Animation Durations + static const Duration fastAnimation = Duration(milliseconds: 200); + static const Duration mediumAnimation = Duration(milliseconds: 300); + static const Duration slowAnimation = Duration(milliseconds: 500); + + // Image Dimensions + static const double albumArtSize = 56.0; + static const double largeAlbumArtSize = 200.0; + static const double artistImageSize = 80.0; + + // Storage Keys + static const String themeKey = 'app_theme'; + static const String authTokenKey = 'auth_token'; + static const String userProfileKey = 'user_profile'; + static const String settingsKey = 'app_settings'; + static const String favoritesKey = 'favorites'; + static const String playlistsKey = 'playlists'; + + // Pagination + static const int defaultPageSize = 20; + static const int searchPageSize = 15; + + // Audio Quality + static const Map audioQualities = { + 'low': '96kbps', + 'medium': '192kbps', + 'high': '320kbps', + 'lossless': 'FLAC', + }; + + // Error Messages + static const String networkErrorMessage = 'Please check your internet connection'; + static const String serverErrorMessage = 'Server is temporarily unavailable'; + static const String authErrorMessage = 'Please login to continue'; + static const String genericErrorMessage = 'Something went wrong. Please try again'; + + // Routes + static const String homeRoute = '/home'; + static const String libraryRoute = '/library'; + static const String playerRoute = '/player'; + static const String searchRoute = '/search'; + static const String playlistsRoute = '/playlists'; + static const String settingsRoute = '/settings'; + static const String authRoute = '/auth'; + static const String qrRoute = '/qr'; + static const String offlineRoute = '/offline'; + static const String analyticsRoute = '/analytics'; + static const String profileRoute = '/profile'; +} diff --git a/swingmusic_mobile/lib/core/constants/app_icons.dart b/swingmusic_mobile/lib/core/constants/app_icons.dart new file mode 100644 index 00000000..58a53824 --- /dev/null +++ b/swingmusic_mobile/lib/core/constants/app_icons.dart @@ -0,0 +1,97 @@ +import 'package:flutter/material.dart'; + +/// Unified icon constants and sizes matching web client +class AppIcons { + // Navigation icons + static const IconData home = Icons.home_outlined; + static const IconData homeFilled = Icons.home; + static const IconData search = Icons.search_outlined; + static const IconData searchFilled = Icons.search; + static const IconData library = Icons.library_music_outlined; + static const IconData libraryFilled = Icons.library_music; + + // Media control icons + static const IconData play = Icons.play_arrow; + static const IconData pause = Icons.pause; + static const IconData skipBack = Icons.skip_previous; + static const IconData skipForward = Icons.skip_next; + static const IconData volume = Icons.volume_up_outlined; + static const IconData volumeMuted = Icons.volume_off_outlined; + + // Content icons + static const IconData album = Icons.album; + static const IconData artist = Icons.person; + static const IconData track = Icons.music_note; + static const IconData folder = Icons.folder; + static const IconData playlist = Icons.playlist_play; + static const IconData favorite = Icons.favorite_border; + static const IconData favoriteFilled = Icons.favorite; + + // Action icons + static const IconData more = Icons.more_vert; + static const IconData add = Icons.add; + static const IconData download = Icons.download; + static const IconData share = Icons.share; + static const IconData settings = Icons.settings; + static const IconData notifications = Icons.notifications_outlined; + static const IconData user = Icons.person; + + // Status icons + static const IconData playing = Icons.equalizer; + static const IconData success = Icons.check_circle; + static const IconData error = Icons.error; + static const IconData warning = Icons.warning; + static const IconData info = Icons.info; +} + +/// Unified icon sizes matching web client +class AppIconSizes { + static const double xs = 16.0; + static const double sm = 20.0; + static const double md = 24.0; + static const double lg = 32.0; + static const double xl = 48.0; + static const double xxl = 64.0; + + // Navigation icons + static const double navigationSize = sm; + + // Media control icons + static const double mediaControlSize = lg; + static const double mediaControlSmallSize = md; + + // Content icons + static const double contentIconSize = md; + static const double contentIconLargeSize = lg; + + // Action icons + static const double actionIconSize = sm; + static const double actionIconLargeSize = md; + + // Status icons + static const double statusIconSize = sm; + static const double statusIconLargeSize = md; +} + +/// Icon widget with consistent styling +class AppIcon extends StatelessWidget { + final IconData icon; + final double? size; + final Color? color; + + const AppIcon({ + super.key, + required this.icon, + this.size, + this.color, + }); + + @override + Widget build(BuildContext context) { + return Icon( + icon, + size: size ?? AppIconSizes.contentIconSize, + color: color ?? Theme.of(context).colorScheme.onSurface, + ); + } +} diff --git a/swingmusic_mobile/lib/core/constants/app_spacing.dart b/swingmusic_mobile/lib/core/constants/app_spacing.dart new file mode 100644 index 00000000..e73d2c9e --- /dev/null +++ b/swingmusic_mobile/lib/core/constants/app_spacing.dart @@ -0,0 +1,128 @@ +import 'package:flutter/material.dart'; + +/// Unified spacing constants matching web client design tokens exactly +class AppSpacing { + // Base spacing unit (4px) matching web client + static const double xs = 4.0; // 0.25rem = $smallest + static const double sm = 8.0; // 0.5rem = $smaller + static const double md = 12.0; // 0.75rem + static const double lg = 16.0; // 1rem = $small + static const double xl = 20.0; // 1.25rem + static const double xxl = 24.0; // 1.5rem = $medium + static const double xxxl = 32.0; // 2rem = $large + static const double larger = 32.0; // $larger = 2rem + + // Web client exact sizing from _variables.scss + static const double bannerHeight = 288.0; // $banner-height: 18rem + static const double songItemHeight = 64.0; // $song-item-height: 4rem + static const double contentPaddingBottom = 32.0; // $content-padding-bottom: 2rem + static const double navHeight = 72.0; // $navheight: 4.5rem + static const double cardWidth = 172.0; // $cardwidth: 10.75rem + static const double maxPadLeft = 80.0; // $maxpadleft: 5rem + static const double padBottom = 64.0; // $padbottom: 4rem + + // Web client specific component sizing + static const double buttonHeight = 36.0; // 2.25rem from basic.scss + static const double buttonMoreWidth = 40.0; // 2.5rem from basic.scss + static const double progressBarHeight = 4.8; // 0.3rem from ProgressBar.scss + static const double searchHeight = 36.0; // 2.25rem from inputs.scss + static const double tabHeight = 32.0; // 2rem from search-tabheaders.scss + static const double stateSize = 32.0; // 2rem from state.scss + static const double explicitIconWidth = 14.4; // 0.9rem from basic.scss + static const double spinnerSize = 20.0; // 1.25rem from basic.scss + + // Grid spacing matching web client album-grid.scss + static const double gridPadding = 16.0; // 1rem padding + static const double gridGap = 16.0; // 1rem gap + static const double gridGapVertical = 32.0; // 2rem vertical gap + static const double gridMinWidth = 144.0; // 9rem min-width + + // Consistent padding + static const EdgeInsets paddingXS = EdgeInsets.all(xs); + static const EdgeInsets paddingSM = EdgeInsets.all(sm); + static const EdgeInsets paddingMD = EdgeInsets.all(md); + static const EdgeInsets paddingLG = EdgeInsets.all(lg); + static const EdgeInsets paddingXL = EdgeInsets.all(xl); + + // Consistent margins + static const EdgeInsets marginXS = EdgeInsets.all(xs); + static const EdgeInsets marginSM = EdgeInsets.all(sm); + static const EdgeInsets marginMD = EdgeInsets.all(md); + static const EdgeInsets marginLG = EdgeInsets.all(lg); + static const EdgeInsets marginXL = EdgeInsets.all(xl); + + // Horizontal spacing + static const EdgeInsets horizontalXS = EdgeInsets.symmetric(horizontal: xs); + static const EdgeInsets horizontalSM = EdgeInsets.symmetric(horizontal: sm); + static const EdgeInsets horizontalMD = EdgeInsets.symmetric(horizontal: md); + static const EdgeInsets horizontalLG = EdgeInsets.symmetric(horizontal: lg); + static const EdgeInsets horizontalXL = EdgeInsets.symmetric(horizontal: xl); + + // Vertical spacing + static const EdgeInsets verticalXS = EdgeInsets.symmetric(vertical: xs); + static const EdgeInsets verticalSM = EdgeInsets.symmetric(vertical: sm); + static const EdgeInsets verticalMD = EdgeInsets.symmetric(vertical: md); + static const EdgeInsets verticalLG = EdgeInsets.symmetric(vertical: lg); + static const EdgeInsets verticalXL = EdgeInsets.symmetric(vertical: xl); + + // Card spacing matching web client album card + static const EdgeInsets cardPadding = EdgeInsets.all(lg); + static const EdgeInsets cardMargin = EdgeInsets.all(sm); + + // List spacing + static const EdgeInsets listPadding = EdgeInsets.symmetric(vertical: sm); + static const double listItemSpacing = sm; + + // Section spacing + static const double sectionSpacing = xxl; + static const EdgeInsets sectionPadding = EdgeInsets.all(lg); + + // Button spacing matching web client + static const EdgeInsets buttonPadding = EdgeInsets.symmetric(horizontal: lg, vertical: md); + + // Form spacing + static const double formFieldSpacing = md; + static const EdgeInsets formPadding = EdgeInsets.all(lg); + + // Animation and timing constants matching web client + static const Duration transitionFast = Duration(milliseconds: 200); // 0.2s ease-out + static const Duration transitionNormal = Duration(milliseconds: 250); // 0.25s ease + static const Duration transitionSlow = Duration(milliseconds: 300); // 0.3s ease + static const Duration spinnerDuration = Duration(milliseconds: 450); // 0.45s linear infinite + static const Duration pulseDuration = Duration(milliseconds: 600); // 0.6s infinite + static const Duration pulseDelay = Duration(milliseconds: 120); // $i * 0.12s + + // Z-index values matching web client + static const int dimmerZIndex = 1001; // From Global/index.scss +} + +/// Unified border radius constants matching web client exactly +class AppBorderRadius { + static const double xs = 4.0; // 0.25rem + static const double sm = 8.0; // 0.5rem = $small + static const double md = 12.0; // 0.75rem + static const double lg = 16.0; // 1rem = $rounded + static const double xl = 20.0; // 1.25rem = $rounded-lg + static const double xxl = 24.0; // 1.5rem = $rounded-md + static const double circular = 160.0; // 10rem = .circular + static const double full = 9999.0; + + // Web client specific border radius values + static const double progressBar = 5.0; // 5px from ProgressBar.scss + static const double input = 3.0; // 3px from inputs.scss + static const double scrollbar = 16.0; // 16px from scrollbars.scss + static const double searchInput = 3.0; // 3px from inputs.scss + static const double duration = 8.0; // 0.5rem from BottomBar.scss + static const double dragImage = 4.0; // $smaller from basic.scss + static const double badge = 4.0; // $smaller from basic.scss + static const double explicitIcon = 4.0; // $smaller from basic.scss + + static BorderRadius circularXS = BorderRadius.circular(xs); + static BorderRadius circularSM = BorderRadius.circular(sm); + static BorderRadius circularMD = BorderRadius.circular(md); + static BorderRadius circularLG = BorderRadius.circular(lg); + static BorderRadius circularXL = BorderRadius.circular(xl); + static BorderRadius circularXXL = BorderRadius.circular(xxl); + static BorderRadius circularFull = BorderRadius.circular(full); + static BorderRadius circularCircular = BorderRadius.circular(circular); +} diff --git a/swingmusic_mobile/lib/core/enums/auth_state.dart b/swingmusic_mobile/lib/core/enums/auth_state.dart new file mode 100644 index 00000000..9794eb12 --- /dev/null +++ b/swingmusic_mobile/lib/core/enums/auth_state.dart @@ -0,0 +1,24 @@ +enum AuthState { + loggedOut, + authenticating, + authenticated, + error; + + String get displayName { + switch (this) { + case AuthState.loggedOut: + return 'Logged Out'; + case AuthState.authenticating: + return 'Authenticating'; + case AuthState.authenticated: + return 'Authenticated'; + case AuthState.error: + return 'Error'; + } + } + + bool get isLoggedIn => this == AuthState.authenticated; + bool get isLoggedOut => this == AuthState.loggedOut; + bool get isAuthenticating => this == AuthState.authenticating; + bool get hasError => this == AuthState.error; +} diff --git a/swingmusic_mobile/lib/core/enums/playback_mode.dart b/swingmusic_mobile/lib/core/enums/playback_mode.dart new file mode 100644 index 00000000..f4bf8c7a --- /dev/null +++ b/swingmusic_mobile/lib/core/enums/playback_mode.dart @@ -0,0 +1,50 @@ +enum RepeatMode { + off, + one, + all; + + String get displayName { + switch (this) { + case RepeatMode.off: + return 'Off'; + case RepeatMode.one: + return 'Repeat One'; + case RepeatMode.all: + return 'Repeat All'; + } + } + + RepeatMode next() { + switch (this) { + case RepeatMode.off: + return RepeatMode.all; + case RepeatMode.all: + return RepeatMode.one; + case RepeatMode.one: + return RepeatMode.off; + } + } +} + +enum ShuffleMode { + off, + on; + + String get displayName { + switch (this) { + case ShuffleMode.off: + return 'Off'; + case ShuffleMode.on: + return 'On'; + } + } + + ShuffleMode toggle() { + switch (this) { + case ShuffleMode.off: + return ShuffleMode.on; + case ShuffleMode.on: + return ShuffleMode.off; + } + } +} diff --git a/swingmusic_mobile/lib/core/themes/app_theme.dart b/swingmusic_mobile/lib/core/themes/app_theme.dart new file mode 100644 index 00000000..dea7f7df --- /dev/null +++ b/swingmusic_mobile/lib/core/themes/app_theme.dart @@ -0,0 +1,237 @@ +import 'package:flutter/material.dart'; + +class AppTheme { + // Unified color scheme matching web client exactly + static const Color primaryColor = Color(0xFF006EFF); // $highlight-blue + static const Color secondaryColor = Color(0xFF8B5CF6); // --color-secondary + static const Color tertiaryColor = Color(0xFF10B981); // --color-accent + + // Web client exact colors + static const Color highlightBlue = Color(0xFF006EFF); // $highlight-blue + static const Color darkestBlue = Color(0xFF234ECE); // $darkestblue + static const Color darkBlue = Color(0xFF055EE2); // $darkblue + + // Apple human design guideline colors (exact match) + static const Color black = Color(0xFF181A1C); // $black + static const Color white = Color(0xFFFFFFDE); // $white (with alpha) + static const Color gray = Color(0xFF1A1919); // $gray + static const Color gray1 = Color(0xFF8E8E93); // $gray1 + static const Color gray2 = Color(0xFF636366); // $gray2 + static const Color gray3 = Color(0xFF48484A); // $gray3 + static const Color gray4 = Color(0xFF3A3A3C); // $gray4 + static const Color gray5 = Color(0xFF2C2C2E); // $gray5 + static const Color body = Color(0xFF000000); // $body + + // Semantic colors (exact match) + static const Color red = Color(0xFFF7635C); // $red + static const Color blue = Color(0xFF0A84FF); // $blue + static const Color green = Color(0xFF5EF784); // $green + static const Color yellow = Color(0xFFFFD60A); // $yellow + static const Color orange = Color(0xFFFF9F0A); // $orange + static const Color pink = Color(0xFFFF375F); // $pink + static const Color purple = Color(0xFFBF5AF2); // $purple + static const Color brown = Color(0xFFAC8E68); // $brown + static const Color indigo = Color(0xFF5E5CE6); // $indigo + static const Color teal = Color(0xFF40C8E0); // $teal + static const Color lightBrown = Color(0xFFEBCA89); // $lightbrown + + static const Color surfaceColor = Color(0xFFFAFAFA); // --color-surface + static const Color surfaceVariantColor = Color(0xFFF5F5F5); // --color-surface-variant + static const Color backgroundColor = Color(0xFFFFFFFF); // --color-background + + static const Color onPrimaryColor = Color(0xFFFFFFFF); // --color-on-primary + static const Color onSecondaryColor = Color(0xFFFFFFFF); // --color-on-secondary + static const Color onTertiaryColor = Color(0xFFFFFFFF); // --color-on-accent + static const Color onSurfaceColor = Color(0xFF1C1C1C); // --color-on-surface + static const Color onBackgroundColor = Color(0xFF1C1C1C); // --color-on-background + + static const Color outlineColor = Color(0xFFE5E7EB); // --color-border + static const Color outlineVariantColor = Color(0xFFF3F4F6); // --color-divider + + // Status colors + static const Color successColor = Color(0xFF10B981); + static const Color warningColor = Color(0xFFF59E0B); + static const Color errorColor = Color(0xFFEF4444); + static const Color infoColor = Color(0xFF3B82F6); + + static ThemeData lightTheme = ThemeData( + useMaterial3: true, + // Exact font family matching web client with fallbacks + fontFamily: 'SF Compact Display', + colorScheme: const ColorScheme.light( + primary: primaryColor, + secondary: secondaryColor, + tertiary: tertiaryColor, + surface: surfaceColor, + surfaceVariant: surfaceVariantColor, + background: backgroundColor, + onPrimary: onPrimaryColor, + onSecondary: onSecondaryColor, + onTertiary: onTertiaryColor, + onSurface: onSurfaceColor, + onBackground: onBackgroundColor, + outline: outlineColor, + outlineVariant: outlineVariantColor, + ), + // Consistent transitions matching web client + pageTransitionsTheme: const PageTransitionsTheme( + builders: { + TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), + TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.linux: FadeUpwardsPageTransitionsBuilder(), + TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(), + }, + ), + appBarTheme: const AppBarTheme( + centerTitle: true, + elevation: 0, + backgroundColor: Colors.transparent, + foregroundColor: onSurfaceColor, + ), + cardTheme: CardThemeData( + elevation: 0, // Match web client flat design + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), // Match web client rounded-sm ($small) + ), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), // Consistent padding + elevation: 0, // Match web client flat design + backgroundColor: primaryColor, + foregroundColor: onPrimaryColor, + textStyle: const TextStyle( + fontFamily: 'SF Compact Display', + fontWeight: FontWeight.w700, // Match web client font-weight + fontSize: 14, // Match web client font-size (0.9rem) + ), + ), + ), + textTheme: const TextTheme( + headlineLarge: TextStyle( + fontSize: 36, // Match web client larger headings + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0, + height: 1.2, + ), + headlineMedium: TextStyle( + fontSize: 28, + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0, + height: 1.2, + ), + headlineSmall: TextStyle( + fontSize: 24, + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0, + height: 1.2, + ), + titleLarge: TextStyle( + fontSize: 20, // Match web client title size + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0, + height: 1.3, + ), + titleMedium: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, // Match web client font-weight + letterSpacing: 0.15, + height: 1.3, + ), + titleSmall: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0.1, + height: 1.3, + ), + bodyLarge: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, // Match web client font-weight + letterSpacing: 0.5, + height: 1.4, + ), + bodyMedium: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, // Match web client font-weight + letterSpacing: 0.25, + height: 1.4, + ), + bodySmall: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w400, // Match web client font-weight + letterSpacing: 0.4, + height: 1.4, + ), + labelLarge: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0.1, + height: 1.2, + ), + labelMedium: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0.5, + height: 1.2, + ), + labelSmall: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w700, // Match web client font-weight + letterSpacing: 0.5, + height: 1.2, + ), + ), + ); + + static ThemeData darkTheme = ThemeData( + useMaterial3: true, + // Exact font family matching web client with fallbacks + fontFamily: 'SF Compact Display', + colorScheme: const ColorScheme.dark( + primary: Color(0xFF4A90E2), // Lighter version of $highlight-blue for dark mode + secondary: Color(0xFFA78BFA), // Lighter secondary for dark mode + tertiary: Color(0xFF34D399), // Lighter accent for dark mode + surface: gray4, // Match web client $gray4 exactly + surfaceVariant: gray5, // Match web client $gray5 exactly + background: body, // Match web client $body exactly + onPrimary: Color(0xFF1C1C1C), // Dark text on light primary + onSecondary: Color(0xFF1C1C1C), // Dark text on light secondary + onTertiary: Color(0xFF1C1C1C), // Dark text on light accent + onSurface: white, // Match web client $white + onBackground: white, // Match web client $white + outline: gray3, // Match web client $gray4 + outlineVariant: gray4, // Match web client $gray5 + ), + appBarTheme: const AppBarTheme( + centerTitle: true, + elevation: 0, + backgroundColor: Colors.transparent, + foregroundColor: white, + ), + cardTheme: CardThemeData( + elevation: 0, // Match web client flat design + color: gray4, // Match web client card background + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), // Match web client rounded-sm ($small) + ), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), // Consistent padding + elevation: 0, // Match web client flat design + backgroundColor: const Color(0xFF4A90E2), // Updated primary color for dark mode + foregroundColor: const Color(0xFF1C1C1C), // Dark text on light primary + textStyle: const TextStyle( + fontFamily: 'SF Compact Display', + fontWeight: FontWeight.w700, // Match web client font-weight + fontSize: 14, // Match web client font-size (0.9rem) + ), + ), + ), + ); +} diff --git a/swingmusic_mobile/lib/core/widgets/album_card.dart b/swingmusic_mobile/lib/core/widgets/album_card.dart new file mode 100644 index 00000000..b4351947 --- /dev/null +++ b/swingmusic_mobile/lib/core/widgets/album_card.dart @@ -0,0 +1,201 @@ +import 'package:flutter/material.dart'; +import '../../data/models/album_model.dart'; +import '../../core/constants/app_spacing.dart'; +import '../../core/themes/app_theme.dart'; + +class AlbumCard extends StatefulWidget { + final AlbumModel album; + final VoidCallback? onTap; + final double? width; + final double? height; + + const AlbumCard({ + super.key, + required this.album, + this.onTap, + this.width, + this.height, + }); + + @override + State createState() => _AlbumCardState(); +} + +class _AlbumCardState extends State { + bool _isHovered = false; + + @override + Widget build(BuildContext context) { + return MouseRegion( + onEnter: (_) => setState(() => _isHovered = true), + onExit: (_) => setState(() => _isHovered = false), + child: Card( + clipBehavior: Clip.antiAlias, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: AppBorderRadius.circularLG, + ), + color: _isHovered ? AppTheme.gray5 : null, // Match web client hover background + child: InkWell( + onTap: onTap, + borderRadius: AppBorderRadius.circularLG, + child: Container( + width: width ?? 160, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Album Art + Expanded( + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceVariant, + borderRadius: AppBorderRadius.circularLG, + ), + child: ClipRRect( + borderRadius: AppBorderRadius.circularLG, + child: Stack( + children: [ + if (album.image.isNotEmpty) + Image.network( + album.image, + fit: BoxFit.cover, + width: double.infinity, + height: double.infinity, + errorBuilder: (context, error, stackTrace) { + return _buildDefaultAlbumArt(context); + }, + ) + else + _buildDefaultAlbumArt(context), + // Gradient overlay matching web client + Positioned.fill( + child: AnimatedOpacity( + opacity: _isHovered ? 1.0 : 0.0, + duration: AppSpacing.transitionNormal, // 0.25s ease from web client + child: DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + colors: [ + Colors.black.withValues(alpha: 0.6), + Colors.transparent, + ], + stops: const [0.0, 0.8], + ), + ), + ), + ), + ), + // Play button overlay matching web client PlayBtn.vue exactly + Positioned( + bottom: 12, + right: 12, + child: AnimatedContainer( + duration: AppSpacing.transitionNormal, + transform: Matrix4.translationValues( + 0, + _isHovered ? 0 : 16, // translateY(1rem) = 16px + 0, + ), + child: AnimatedOpacity( + opacity: _isHovered ? 1.0 : 0.0, + duration: AppSpacing.transitionNormal, + child: Container( + width: 40, // 2.5rem = 40px + height: 40, + decoration: BoxDecoration( + color: AppTheme.darkBlue, // $darkblue exact match + shape: BoxShape.circle, + boxShadow: [ + // Match web client shadow effects + BoxShadow( + color: Colors.black.withValues(alpha: 0.3), + blurRadius: 8, + offset: const Offset(0, 2), + ), + ], + ), + child: Icon( + Icons.play_arrow, + color: AppTheme.onPrimaryColor, + size: 28, // 1.75rem = 28px + ), + ), + ), + ), + ), + ], + ), + ), + ), + ), + + // Album Info + Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + album.displayTitle, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w700, + fontSize: 15, // 0.95rem from web client + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + album.artistNames, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.75), + fontWeight: FontWeight.w700, + fontSize: 13, // 0.8rem from web client + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + if (album.year.isNotEmpty) ...[ + const SizedBox(height: 2), + Text( + album.year, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.6), + fontSize: 12, + ), + ), + ], + ], + ), + ), + ], + ), + ), + ), + ), + ); + } + + Widget _buildDefaultAlbumArt(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.7), + Theme.of(context).colorScheme.secondary.withOpacity(0.7), + ], + ), + ), + child: Icon( + Icons.album, + size: 48, + color: Theme.of(context).colorScheme.onPrimary, + ), + ); + } +} diff --git a/swingmusic_mobile/lib/core/widgets/mini_player.dart b/swingmusic_mobile/lib/core/widgets/mini_player.dart new file mode 100644 index 00000000..6be5fd5a --- /dev/null +++ b/swingmusic_mobile/lib/core/widgets/mini_player.dart @@ -0,0 +1,169 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; + +class MiniPlayer extends StatelessWidget { + const MiniPlayer({super.key}); + + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, audioProvider, child) { + final currentTrack = audioProvider.currentTrack; + + if (currentTrack == null) { + return const SizedBox.shrink(); + } + + return Container( + height: 80, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 8, + offset: const Offset(0, -2), + ), + ], + ), + child: InkWell( + onTap: () { + // Navigate to full player + Navigator.pushNamed(context, '/player'); + }, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Row( + children: [ + // Album Art + ClipRRect( + borderRadius: BorderRadius.circular(4), + child: Container( + width: 56, + height: 56, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceVariant, + ), + child: currentTrack.image.isNotEmpty + ? Image.network( + currentTrack.image, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return _buildDefaultArt(context); + }, + ) + : _buildDefaultArt(context), + ), + ), + + const SizedBox(width: 12), + + // Track Info + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + currentTrack.displayTitle, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w500, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 2), + Text( + currentTrack.artistNames, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ), + + // Progress Indicator + if (audioProvider.duration.inMilliseconds > 0) + SizedBox( + width: 40, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '${audioProvider.positionFormatted} / ${audioProvider.durationFormatted}', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + fontSize: 10, + ), + ), + const SizedBox(height: 4), + LinearProgressIndicator( + value: audioProvider.progress, + backgroundColor: Theme.of(context).colorScheme.surfaceVariant, + valueColor: AlwaysStoppedAnimation( + Theme.of(context).colorScheme.primary, + ), + ), + ], + ), + ), + + const SizedBox(width: 8), + + // Play/Pause Button + IconButton( + onPressed: () { + if (audioProvider.isPlaying) { + audioProvider.pause(); + } else { + audioProvider.play(); + } + }, + icon: audioProvider.isLoading + ? SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation( + Theme.of(context).colorScheme.primary, + ), + ), + ) + : Icon( + audioProvider.isPlaying ? Icons.pause : Icons.play_arrow, + color: Theme.of(context).colorScheme.primary, + ), + ), + ], + ), + ), + ), + ); + }, + ); + } + + Widget _buildDefaultArt(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.7), + Theme.of(context).colorScheme.secondary.withOpacity(0.7), + ], + ), + ), + child: Icon( + Icons.music_note, + size: 24, + color: Theme.of(context).colorScheme.onPrimary, + ), + ); + } +} diff --git a/swingmusic_mobile/lib/core/widgets/track_list_tile.dart b/swingmusic_mobile/lib/core/widgets/track_list_tile.dart new file mode 100644 index 00000000..0a6fbb28 --- /dev/null +++ b/swingmusic_mobile/lib/core/widgets/track_list_tile.dart @@ -0,0 +1,141 @@ +import 'package:flutter/material.dart'; +import '../../data/models/track_model.dart'; + +class TrackListTile extends StatelessWidget { + final TrackModel track; + final VoidCallback? onTap; + final VoidCallback? onPlay; + final bool isPlaying; + final bool showAlbumArt; + final Widget? trailing; + + const TrackListTile({ + super.key, + required this.track, + this.onTap, + this.onPlay, + this.isPlaying = false, + this.showAlbumArt = true, + this.trailing, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + onTap: onTap, + dense: true, + leading: showAlbumArt + ? ClipRRect( + borderRadius: BorderRadius.circular(4), + child: Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceVariant, + ), + child: track.image.isNotEmpty + ? Image.network( + track.image, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return _buildDefaultArt(context); + }, + ) + : _buildDefaultArt(context), + ), + ) + : SizedBox( + width: 24, + child: Center( + child: isPlaying + ? Icon( + Icons.equalizer, + size: 16, + color: Theme.of(context).colorScheme.primary, + ) + : Text( + '${track.track}', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ), + ), + title: Text( + track.displayTitle, + style: TextStyle( + fontWeight: isPlaying ? FontWeight.w600 : FontWeight.normal, + color: isPlaying + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + track.artistNames, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + if (track.displayAlbum.isNotEmpty) + Text( + track.displayAlbum, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ), + trailing: trailing ?? + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + track.durationFormatted, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(width: 8), + if (onPlay != null) + IconButton( + icon: Icon( + isPlaying ? Icons.pause : Icons.play_arrow, + color: Theme.of(context).colorScheme.primary, + ), + onPressed: onPlay, + visualDensity: VisualDensity.compact, + ), + ], + ), + ); + } + + Widget _buildDefaultArt(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.7), + Theme.of(context).colorScheme.secondary.withOpacity(0.7), + ], + ), + ), + child: Icon( + Icons.music_note, + size: 24, + color: Theme.of(context).colorScheme.onPrimary, + ), + ); + } +} diff --git a/swingmusic_mobile/lib/data/models/album_model.dart b/swingmusic_mobile/lib/data/models/album_model.dart new file mode 100644 index 00000000..cde6d033 --- /dev/null +++ b/swingmusic_mobile/lib/data/models/album_model.dart @@ -0,0 +1,236 @@ +import 'package:equatable/equatable.dart'; +import 'track_model.dart'; + +class AlbumModel extends Equatable { + final List albumartists; + final String albumhash; + final List artisthashes; + final String baseTitle; + final String color; + final int createdDate; + final int date; + final int duration; + final List genres; + final List genrehashes; + final String originalTitle; + final String title; + final int trackcount; + final int lastplayed; + final int playcount; + final int playduration; + final Map extra; + final String pathhash; + final int id; + final String type; + final String image; + final double score; + final List versions; + final List favUserids; + final String weakHash; + final bool isFavorite; + + const AlbumModel({ + required this.albumartists, + required this.albumhash, + required this.artisthashes, + required this.baseTitle, + this.color = '#6750A4', + required this.createdDate, + required this.date, + required this.duration, + required this.genres, + required this.genrehashes, + this.originalTitle = '', + required this.title, + required this.trackcount, + this.lastplayed = 0, + this.playcount = 0, + this.playduration = 0, + this.extra = const {}, + this.pathhash = '', + this.id = -1, + this.type = 'album', + this.image = '', + this.score = 0.0, + this.versions = const [], + this.favUserids = const [], + this.weakHash = '', + this.isFavorite = false, + }); + + AlbumModel copyWith({ + List? albumartists, + String? albumhash, + List? artisthashes, + String? baseTitle, + String? color, + int? createdDate, + int? date, + int? duration, + List? genres, + List? genrehashes, + String? originalTitle, + String? title, + int? trackcount, + int? lastplayed, + int? playcount, + int? playduration, + Map? extra, + String? pathhash, + int? id, + String? type, + String? image, + double? score, + List? versions, + List? favUserids, + String? weakHash, + bool? isFavorite, + }) { + return AlbumModel( + albumartists: albumartists ?? this.albumartists, + albumhash: albumhash ?? this.albumhash, + artisthashes: artisthashes ?? this.artisthashes, + baseTitle: baseTitle ?? this.baseTitle, + color: color ?? this.color, + createdDate: createdDate ?? this.createdDate, + date: date ?? this.date, + duration: duration ?? this.duration, + genres: genres ?? this.genres, + genrehashes: genrehashes ?? this.genrehashes, + originalTitle: originalTitle ?? this.originalTitle, + title: title ?? this.title, + trackcount: trackcount ?? this.trackcount, + lastplayed: lastplayed ?? this.lastplayed, + playcount: playcount ?? this.playcount, + playduration: playduration ?? this.playduration, + extra: extra ?? this.extra, + pathhash: pathhash ?? this.pathhash, + id: id ?? this.id, + type: type ?? this.type, + image: image ?? this.image, + score: score ?? this.score, + versions: versions ?? this.versions, + favUserids: favUserids ?? this.favUserids, + weakHash: weakHash ?? this.weakHash, + isFavorite: isFavorite ?? this.isFavorite, + ); + } + + @override + List get props => [ + albumartists, + albumhash, + artisthashes, + baseTitle, + color, + createdDate, + date, + duration, + genres, + genrehashes, + originalTitle, + title, + trackcount, + lastplayed, + playcount, + playduration, + extra, + pathhash, + id, + type, + image, + score, + versions, + favUserids, + weakHash, + isFavorite, + ]; + + String get displayTitle => originalTitle.isNotEmpty ? originalTitle : title; + + String get artistNames => albumartists.map((artist) => artist.name).join(', '); + + String get durationFormatted { + final hours = duration ~/ 3600; + final minutes = (duration % 3600) ~/ 60; + final seconds = duration % 60; + + if (hours > 0) { + return '${hours}:${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } else { + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + } + + String get year { + if (date == 0) return ''; + final dateTime = DateTime.fromMillisecondsSinceEpoch(date * 1000); + return dateTime.year.toString(); + } + + factory AlbumModel.fromJson(Map json) { + return AlbumModel( + albumartists: (json['albumartists'] as List?) + ?.map((artist) => ArtistModel.fromJson(artist)) + .toList() ?? [], + albumhash: json['albumhash'] ?? '', + artisthashes: List.from(json['artisthashes'] ?? []), + baseTitle: json['base_title'] ?? '', + color: json['color'] ?? '#6750A4', + createdDate: json['created_date'] ?? 0, + date: json['date'] ?? 0, + duration: json['duration'] ?? 0, + genres: (json['genres'] as List?) + ?.map((genre) => GenreModel.fromJson(genre)) + .toList() ?? [], + genrehashes: List.from(json['genrehashes'] ?? []), + originalTitle: json['original_title'] ?? '', + title: json['title'] ?? '', + trackcount: json['trackcount'] ?? 0, + lastplayed: json['lastplayed'] ?? 0, + playcount: json['playcount'] ?? 0, + playduration: json['playduration'] ?? 0, + extra: json['extra'] ?? {}, + pathhash: json['pathhash'] ?? '', + id: json['id'] ?? -1, + type: json['type'] ?? 'album', + image: json['image'] ?? '', + score: (json['score'] ?? 0).toDouble(), + versions: List.from(json['versions'] ?? []), + favUserids: List.from(json['fav_userids'] ?? []), + weakHash: json['weak_hash'] ?? '', + isFavorite: json['is_favorite'] ?? false, + ); + } + + Map toJson() { + return { + 'albumartists': albumartists.map((artist) => artist.toJson()).toList(), + 'albumhash': albumhash, + 'artisthashes': artisthashes, + 'base_title': baseTitle, + 'color': color, + 'created_date': createdDate, + 'date': date, + 'duration': duration, + 'genres': genres.map((genre) => genre.toJson()).toList(), + 'genrehashes': genrehashes, + 'original_title': originalTitle, + 'title': title, + 'trackcount': trackcount, + 'lastplayed': lastplayed, + 'playcount': playcount, + 'playduration': playduration, + 'extra': extra, + 'pathhash': pathhash, + 'id': id, + 'type': type, + 'image': image, + 'score': score, + 'versions': versions, + 'fav_userids': favUserids, + 'weak_hash': weakHash, + 'is_favorite': isFavorite, + }; + } +} diff --git a/swingmusic_mobile/lib/data/models/artist_model.dart b/swingmusic_mobile/lib/data/models/artist_model.dart new file mode 100644 index 00000000..038c9255 --- /dev/null +++ b/swingmusic_mobile/lib/data/models/artist_model.dart @@ -0,0 +1,96 @@ +import 'package:equatable/equatable.dart'; +import 'album_model.dart'; +import 'track_model.dart'; + +class ArtistModel extends Equatable { + final String name; + final String artisthash; + final String image; + final int trackcount; + final int albumcount; + final int duration; + final int lastplayed; + final int playcount; + final int playduration; + final List favUserids; + final bool isFavorite; + final List albums; + final List tracks; + + const ArtistModel({ + required this.name, + required this.artisthash, + this.image = '', + this.trackcount = 0, + this.albumcount = 0, + this.duration = 0, + this.lastplayed = 0, + this.playcount = 0, + this.playduration = 0, + this.favUserids = const [], + this.isFavorite = false, + this.albums = const [], + this.tracks = const [], + }); + + ArtistModel copyWith({ + String? name, + String? artisthash, + String? image, + int? trackcount, + int? albumcount, + int? duration, + int? lastplayed, + int? playcount, + int? playduration, + List? favUserids, + bool? isFavorite, + List? albums, + List? tracks, + }) { + return ArtistModel( + name: name ?? this.name, + artisthash: artisthash ?? this.artisthash, + image: image ?? this.image, + trackcount: trackcount ?? this.trackcount, + albumcount: albumcount ?? this.albumcount, + duration: duration ?? this.duration, + lastplayed: lastplayed ?? this.lastplayed, + playcount: playcount ?? this.playcount, + playduration: playduration ?? this.playduration, + favUserids: favUserids ?? this.favUserids, + isFavorite: isFavorite ?? this.isFavorite, + albums: albums ?? this.albums, + tracks: tracks ?? this.tracks, + ); + } + + @override + List get props => [ + name, + artisthash, + image, + trackcount, + albumcount, + duration, + lastplayed, + playcount, + playduration, + favUserids, + isFavorite, + albums, + tracks, + ]; + + String get durationFormatted { + final hours = duration ~/ 3600; + final minutes = (duration % 3600) ~/ 60; + final seconds = duration % 60; + + if (hours > 0) { + return '${hours}:${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } else { + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + } +} diff --git a/swingmusic_mobile/lib/data/models/folder_model.dart b/swingmusic_mobile/lib/data/models/folder_model.dart new file mode 100644 index 00000000..fa447229 --- /dev/null +++ b/swingmusic_mobile/lib/data/models/folder_model.dart @@ -0,0 +1,123 @@ +import 'package:equatable/equatable.dart'; +import 'track_model.dart'; + +class FolderModel extends Equatable { + final String name; + final String path; + final String? parent; + final int trackcount; + final List subfolders; + final List tracks; + final String? image; + final bool isFavorite; + + const FolderModel({ + required this.name, + required this.path, + this.parent, + this.trackcount = 0, + this.subfolders = const [], + this.tracks = const [], + this.image, + this.isFavorite = false, + }); + + FolderModel copyWith({ + String? name, + String? path, + String? parent, + int? trackcount, + List? subfolders, + List? tracks, + String? image, + bool? isFavorite, + }) { + return FolderModel( + name: name ?? this.name, + path: path ?? this.path, + parent: parent ?? this.parent, + trackcount: trackcount ?? this.trackcount, + subfolders: subfolders ?? this.subfolders, + tracks: tracks ?? this.tracks, + image: image ?? this.image, + isFavorite: isFavorite ?? this.isFavorite, + ); + } + + factory FolderModel.fromJson(Map json) { + return FolderModel( + name: json['name'] ?? '', + path: json['path'] ?? '', + parent: json['parent'], + trackcount: json['trackcount'] ?? 0, + subfolders: (json['subfolders'] as List?) + ?.map((folder) => FolderModel.fromJson(folder)) + .toList() ?? [], + tracks: (json['tracks'] as List?) + ?.map((track) => TrackModel.fromJson(track)) + .toList() ?? [], + image: json['image'], + isFavorite: json['is_favorite'] ?? false, + ); + } + + Map toJson() { + return { + 'name': name, + 'path': path, + 'parent': parent, + 'trackcount': trackcount, + 'subfolders': subfolders.map((folder) => folder.toJson()).toList(), + 'tracks': tracks.map((track) => track.toJson()).toList(), + 'image': image, + 'is_favorite': isFavorite, + }; + } + + @override + List get props => [ + name, + path, + parent, + trackcount, + subfolders, + tracks, + image, + isFavorite, + ]; +} + +class FoldersAndTracksModel extends Equatable { + final List folders; + final List tracks; + final String currentPath; + + const FoldersAndTracksModel({ + required this.folders, + required this.tracks, + required this.currentPath, + }); + + factory FoldersAndTracksModel.fromJson(Map json) { + return FoldersAndTracksModel( + folders: (json['folders'] as List?) + ?.map((folder) => FolderModel.fromJson(folder)) + .toList() ?? [], + tracks: (json['tracks'] as List?) + ?.map((track) => TrackModel.fromJson(track)) + .toList() ?? [], + currentPath: json['current_path'] ?? '', + ); + } + + Map toJson() { + return { + 'folders': folders.map((folder) => folder.toJson()).toList(), + 'tracks': tracks.map((track) => track.toJson()).toList(), + 'current_path': currentPath, + }; + } + + @override + List get props => [folders, tracks, currentPath]; +} diff --git a/swingmusic_mobile/lib/data/models/playlist_model.dart b/swingmusic_mobile/lib/data/models/playlist_model.dart new file mode 100644 index 00000000..06a2d636 --- /dev/null +++ b/swingmusic_mobile/lib/data/models/playlist_model.dart @@ -0,0 +1,152 @@ +import 'package:equatable/equatable.dart'; +import 'track_model.dart'; + +class PlaylistModel extends Equatable { + final String id; + final String name; + final String description; + final String image; + final List tracks; + final int trackcount; + final int duration; + final DateTime createdDate; + final DateTime lastModified; + final bool isPublic; + final bool isCollaborative; + final String owner; + final List collaboratorIds; + final Map extra; + + const PlaylistModel({ + required this.id, + required this.name, + this.description = '', + this.image = '', + this.tracks = const [], + this.trackcount = 0, + this.duration = 0, + required this.createdDate, + required this.lastModified, + this.isPublic = false, + this.isCollaborative = false, + this.owner = '', + this.collaboratorIds = const [], + this.extra = const {}, + }); + + PlaylistModel copyWith({ + String? id, + String? name, + String? description, + String? image, + List? tracks, + int? trackcount, + int? duration, + DateTime? createdDate, + DateTime? lastModified, + bool? isPublic, + bool? isCollaborative, + String? owner, + List? collaboratorIds, + Map? extra, + }) { + return PlaylistModel( + id: id ?? this.id, + name: name ?? this.name, + description: description ?? this.description, + image: image ?? this.image, + tracks: tracks ?? this.tracks, + trackcount: trackcount ?? this.trackcount, + duration: duration ?? this.duration, + createdDate: createdDate ?? this.createdDate, + lastModified: lastModified ?? this.lastModified, + isPublic: isPublic ?? this.isPublic, + isCollaborative: isCollaborative ?? this.isCollaborative, + owner: owner ?? this.owner, + collaboratorIds: collaboratorIds ?? this.collaboratorIds, + extra: extra ?? this.extra, + ); + } + + @override + List get props => [ + id, + name, + description, + image, + tracks, + trackcount, + duration, + createdDate, + lastModified, + isPublic, + isCollaborative, + owner, + collaboratorIds, + extra, + ]; + + String get durationFormatted { + final hours = duration ~/ 3600; + final minutes = (duration % 3600) ~/ 60; + final seconds = duration % 60; + + if (hours > 0) { + return '${hours}:${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } else { + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + } + + String get createdDateFormatted { + return '${createdDate.day.toString().padLeft(2, '0')}/${createdDate.month.toString().padLeft(2, '0')}/${createdDate.year}'; + } + + String get lastModifiedFormatted { + return '${lastModified.day.toString().padLeft(2, '0')}/${lastModified.month.toString().padLeft(2, '0')}/${lastModified.year}'; + } + + factory PlaylistModel.fromJson(Map json) { + return PlaylistModel( + id: json['id'] ?? '', + name: json['name'] ?? '', + description: json['description'] ?? '', + image: json['image'] ?? '', + tracks: (json['tracks'] as List?) + ?.map((track) => TrackModel.fromJson(track)) + .toList() ?? [], + trackcount: json['trackcount'] ?? 0, + duration: json['duration'] ?? 0, + createdDate: json['created_date'] != null + ? DateTime.parse(json['created_date']) + : DateTime.now(), + lastModified: json['last_modified'] != null + ? DateTime.parse(json['last_modified']) + : DateTime.now(), + isPublic: json['is_public'] ?? false, + isCollaborative: json['is_collaborative'] ?? false, + owner: json['owner'] ?? '', + collaboratorIds: List.from(json['collaborator_ids'] ?? []), + extra: json['extra'] ?? {}, + ); + } + + Map toJson() { + return { + 'id': id, + 'name': name, + 'description': description, + 'image': image, + 'tracks': tracks.map((track) => track.toJson()).toList(), + 'trackcount': trackcount, + 'duration': duration, + 'created_date': createdDate.toIso8601String(), + 'last_modified': lastModified.toIso8601String(), + 'is_public': isPublic, + 'is_collaborative': isCollaborative, + 'owner': owner, + 'collaborator_ids': collaboratorIds, + 'extra': extra, + }; + } +} diff --git a/swingmusic_mobile/lib/data/models/search_results_model.dart b/swingmusic_mobile/lib/data/models/search_results_model.dart new file mode 100644 index 00000000..9993caca --- /dev/null +++ b/swingmusic_mobile/lib/data/models/search_results_model.dart @@ -0,0 +1,153 @@ +import 'package:equatable/equatable.dart'; +import 'album_model.dart'; +import 'folder_model.dart'; +import 'playlist_model.dart'; +import 'track_model.dart'; + +class SearchResultsModel extends Equatable { + final List tracks; + final List albums; + final List artists; + final List folders; + final List playlists; + + const SearchResultsModel({ + this.tracks = const [], + this.albums = const [], + this.artists = const [], + this.folders = const [], + this.playlists = const [], + }); + + SearchResultsModel copyWith({ + List? tracks, + List? albums, + List? artists, + List? folders, + List? playlists, + }) { + return SearchResultsModel( + tracks: tracks ?? this.tracks, + albums: albums ?? this.albums, + artists: artists ?? this.artists, + folders: folders ?? this.folders, + playlists: playlists ?? this.playlists, + ); + } + + factory SearchResultsModel.fromJson(Map json) { + return SearchResultsModel( + tracks: (json['tracks'] as List?) + ?.map((track) => TrackModel.fromJson(track)) + .toList() ?? [], + albums: (json['albums'] as List?) + ?.map((album) => AlbumModel.fromJson(album)) + .toList() ?? [], + artists: (json['artists'] as List?) + ?.map((artist) => ArtistModel.fromJson(artist)) + .toList() ?? [], + folders: (json['folders'] as List?) + ?.map((folder) => FolderModel.fromJson(folder)) + .toList() ?? [], + playlists: (json['playlists'] as List?) + ?.map((playlist) => PlaylistModel.fromJson(playlist)) + .toList() ?? [], + ); + } + + Map toJson() { + return { + 'tracks': tracks.map((track) => track.toJson()).toList(), + 'albums': albums.map((album) => album.toJson()).toList(), + 'artists': artists.map((artist) => artist.toJson()).toList(), + 'folders': folders.map((folder) => folder.toJson()).toList(), + 'playlists': playlists.map((playlist) => playlist.toJson()).toList(), + }; + } + + bool get isEmpty => + tracks.isEmpty && + albums.isEmpty && + artists.isEmpty && + folders.isEmpty && + playlists.isEmpty; + + bool get isNotEmpty => !isEmpty; + + @override + List get props => [ + tracks, + albums, + artists, + folders, + playlists, + ]; +} + +class TopSearchResultsModel extends Equatable { + final List topResults; + final SearchResultsModel allResults; + + const TopSearchResultsModel({ + required this.topResults, + required this.allResults, + }); + + factory TopSearchResultsModel.fromJson(Map json) { + return TopSearchResultsModel( + topResults: (json['top_results'] as List?) + ?.map((item) => TopResultItemModel.fromJson(item)) + .toList() ?? [], + allResults: SearchResultsModel.fromJson(json['all_results'] ?? {}), + ); + } + + Map toJson() { + return { + 'top_results': topResults.map((item) => item.toJson()).toList(), + 'all_results': allResults.toJson(), + }; + } + + @override + List get props => [topResults, allResults]; +} + +class TopResultItemModel extends Equatable { + final String type; // 'track', 'album', 'artist', 'folder', 'playlist' + final String title; + final String subtitle; + final String? image; + final dynamic data; // The actual model object + + const TopResultItemModel({ + required this.type, + required this.title, + required this.subtitle, + this.image, + this.data, + }); + + factory TopResultItemModel.fromJson(Map json) { + return TopResultItemModel( + type: json['type'] ?? '', + title: json['title'] ?? '', + subtitle: json['subtitle'] ?? '', + image: json['image'], + data: json['data'], + ); + } + + Map toJson() { + return { + 'type': type, + 'title': title, + 'subtitle': subtitle, + 'image': image, + 'data': data, + }; + } + + @override + List get props => [type, title, subtitle, image, data]; +} diff --git a/swingmusic_mobile/lib/data/models/search_suggestion_model.dart b/swingmusic_mobile/lib/data/models/search_suggestion_model.dart new file mode 100644 index 00000000..5160957e --- /dev/null +++ b/swingmusic_mobile/lib/data/models/search_suggestion_model.dart @@ -0,0 +1,15 @@ +class SearchSuggestion { + final String id; + final String title; + final String? imageUrl; + final String type; // 'track', 'album', 'artist', 'playlist' + final dynamic data; + + SearchSuggestion({ + required this.id, + required this.title, + this.imageUrl, + required this.type, + this.data, + }); +} diff --git a/swingmusic_mobile/lib/data/models/track_model.dart b/swingmusic_mobile/lib/data/models/track_model.dart new file mode 100644 index 00000000..b477d3ba --- /dev/null +++ b/swingmusic_mobile/lib/data/models/track_model.dart @@ -0,0 +1,316 @@ +import 'package:equatable/equatable.dart'; + +class TrackModel extends Equatable { + final int id; + final String title; + final String album; + final String originalTitle; + final String albumhash; + final String originalAlbum; + final List artists; + final List albumartists; + final List artisthashes; + final int track; + final int disc; + final int duration; + final int bitrate; + final String filepath; + final String folder; + final List genres; + final List genrehashes; + final String copyright; + final int date; + final int lastModified; + final String trackhash; + final String image; + final String weakHash; + final Map extra; + final int lastplayed; + final int playcount; + final int playduration; + final bool explicit; + final List favUserids; + final bool isFavorite; + final double score; + + const TrackModel({ + required this.id, + required this.title, + required this.album, + this.originalTitle = '', + required this.albumhash, + this.originalAlbum = '', + required this.artists, + required this.albumartists, + required this.artisthashes, + required this.track, + required this.disc, + required this.duration, + required this.bitrate, + required this.filepath, + required this.folder, + required this.genres, + required this.genrehashes, + this.copyright = '', + required this.date, + required this.lastModified, + required this.trackhash, + this.image = '', + this.weakHash = '', + required this.extra, + this.lastplayed = 0, + this.playcount = 0, + this.playduration = 0, + this.explicit = false, + this.favUserids = const [], + this.isFavorite = false, + this.score = 0.0, + }); + + TrackModel copyWith({ + int? id, + String? title, + String? album, + String? originalTitle, + String? albumhash, + String? originalAlbum, + List? artists, + List? albumartists, + List? artisthashes, + int? track, + int? disc, + int? duration, + int? bitrate, + String? filepath, + String? folder, + List? genres, + List? genrehashes, + String? copyright, + int? date, + int? lastModified, + String? trackhash, + String? image, + String? weakHash, + Map? extra, + int? lastplayed, + int? playcount, + int? playduration, + bool? explicit, + List? favUserids, + bool? isFavorite, + double? score, + }) { + return TrackModel( + id: id ?? this.id, + title: title ?? this.title, + album: album ?? this.album, + originalTitle: originalTitle ?? this.originalTitle, + albumhash: albumhash ?? this.albumhash, + originalAlbum: originalAlbum ?? this.originalAlbum, + artists: artists ?? this.artists, + albumartists: albumartists ?? this.albumartists, + artisthashes: artisthashes ?? this.artisthashes, + track: track ?? this.track, + disc: disc ?? this.disc, + duration: duration ?? this.duration, + bitrate: bitrate ?? this.bitrate, + filepath: filepath ?? this.filepath, + folder: folder ?? this.folder, + genres: genres ?? this.genres, + genrehashes: genrehashes ?? this.genrehashes, + copyright: copyright ?? this.copyright, + date: date ?? this.date, + lastModified: lastModified ?? this.lastModified, + trackhash: trackhash ?? this.trackhash, + image: image ?? this.image, + weakHash: weakHash ?? this.weakHash, + extra: extra ?? this.extra, + lastplayed: lastplayed ?? this.lastplayed, + playcount: playcount ?? this.playcount, + playduration: playduration ?? this.playduration, + explicit: explicit ?? this.explicit, + favUserids: favUserids ?? this.favUserids, + isFavorite: isFavorite ?? this.isFavorite, + score: score ?? this.score, + ); + } + + @override + List get props => [ + id, + title, + album, + originalTitle, + albumhash, + originalAlbum, + artists, + albumartists, + artisthashes, + track, + disc, + duration, + bitrate, + filepath, + folder, + genres, + genrehashes, + copyright, + date, + lastModified, + trackhash, + image, + weakHash, + extra, + lastplayed, + playcount, + playduration, + explicit, + favUserids, + isFavorite, + score, + ]; + + String get displayTitle => originalTitle.isNotEmpty ? originalTitle : title; + + String get displayAlbum => originalAlbum.isNotEmpty ? originalAlbum : album; + + String get artistNames => artists.map((artist) => artist.name).join(', '); + + String get durationFormatted { + final minutes = duration ~/ 60; + final seconds = duration % 60; + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + + factory TrackModel.fromJson(Map json) { + return TrackModel( + id: json['id'] ?? 0, + title: json['title'] ?? '', + album: json['album'] ?? '', + originalTitle: json['original_title'] ?? '', + albumhash: json['albumhash'] ?? '', + originalAlbum: json['original_album'] ?? '', + artists: (json['artists'] as List?) + ?.map((artist) => ArtistModel.fromJson(artist)) + .toList() ?? [], + albumartists: (json['albumartists'] as List?) + ?.map((artist) => ArtistModel.fromJson(artist)) + .toList() ?? [], + artisthashes: List.from(json['artisthashes'] ?? []), + track: json['track'] ?? 0, + disc: json['disc'] ?? 1, + duration: json['duration'] ?? 0, + bitrate: json['bitrate'] ?? 0, + filepath: json['filepath'] ?? '', + folder: json['folder'] ?? '', + genres: (json['genres'] as List?) + ?.map((genre) => GenreModel.fromJson(genre)) + .toList() ?? [], + genrehashes: List.from(json['genrehashes'] ?? []), + copyright: json['copyright'] ?? '', + date: json['date'] ?? 0, + lastModified: json['last_modified'] ?? 0, + trackhash: json['trackhash'] ?? '', + image: json['image'] ?? '', + weakHash: json['weak_hash'] ?? '', + extra: json['extra'] ?? {}, + lastplayed: json['lastplayed'] ?? 0, + playcount: json['playcount'] ?? 0, + playduration: json['playduration'] ?? 0, + explicit: json['explicit'] ?? false, + favUserids: List.from(json['fav_userids'] ?? []), + isFavorite: json['is_favorite'] ?? false, + score: (json['score'] ?? 0).toDouble(), + ); + } + + Map toJson() { + return { + 'id': id, + 'title': title, + 'album': album, + 'original_title': originalTitle, + 'albumhash': albumhash, + 'original_album': originalAlbum, + 'artists': artists.map((artist) => artist.toJson()).toList(), + 'albumartists': albumartists.map((artist) => artist.toJson()).toList(), + 'artisthashes': artisthashes, + 'track': track, + 'disc': disc, + 'duration': duration, + 'bitrate': bitrate, + 'filepath': filepath, + 'folder': folder, + 'genres': genres.map((genre) => genre.toJson()).toList(), + 'genrehashes': genrehashes, + 'copyright': copyright, + 'date': date, + 'last_modified': lastModified, + 'trackhash': trackhash, + 'image': image, + 'weak_hash': weakHash, + 'extra': extra, + 'lastplayed': lastplayed, + 'playcount': playcount, + 'playduration': playduration, + 'explicit': explicit, + 'fav_userids': favUserids, + 'is_favorite': isFavorite, + 'score': score, + }; + } +} + +class ArtistModel extends Equatable { + final String name; + final String artisthash; + + const ArtistModel({ + required this.name, + required this.artisthash, + }); + + factory ArtistModel.fromJson(Map json) { + return ArtistModel( + name: json['name'] ?? '', + artisthash: json['artisthash'] ?? '', + ); + } + + Map toJson() { + return { + 'name': name, + 'artisthash': artisthash, + }; + } + + @override + List get props => [name, artisthash]; +} + +class GenreModel extends Equatable { + final String name; + final String genrehash; + + const GenreModel({ + required this.name, + required this.genrehash, + }); + + factory GenreModel.fromJson(Map json) { + return GenreModel( + name: json['name'] ?? '', + genrehash: json['genrehash'] ?? '', + ); + } + + Map toJson() { + return { + 'name': name, + 'genrehash': genrehash, + }; + } + + @override + List get props => [name, genrehash]; +} diff --git a/swingmusic_mobile/lib/data/services/api_service.dart b/swingmusic_mobile/lib/data/services/api_service.dart new file mode 100644 index 00000000..e33f15f0 --- /dev/null +++ b/swingmusic_mobile/lib/data/services/api_service.dart @@ -0,0 +1,283 @@ +import 'package:dio/dio.dart'; +import '../../core/constants/app_constants.dart'; + +class ApiService { + late Dio _dio; + final String baseUrl; + + ApiService({String? baseUrl}) : baseUrl = baseUrl ?? AppConstants.defaultApiUrl { + _dio = Dio(BaseOptions( + baseUrl: baseUrl ?? AppConstants.defaultApiUrl, + connectTimeout: AppConstants.apiTimeout, + receiveTimeout: AppConstants.apiTimeout, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + )); + + _dio.interceptors.add(LogInterceptor( + requestBody: true, + responseBody: true, + logPrint: (obj) { + // print(obj); // Enable for debugging + }, + )); + + _dio.interceptors.add(InterceptorsWrapper( + onError: (error, handler) { + // Handle common errors + String errorMessage = AppConstants.genericErrorMessage; + + if (error.type == DioExceptionType.connectionTimeout || + error.type == DioExceptionType.receiveTimeout) { + errorMessage = AppConstants.networkErrorMessage; + } else if (error.response?.statusCode == 500) { + errorMessage = AppConstants.serverErrorMessage; + } else if (error.response?.statusCode == 401) { + errorMessage = AppConstants.authErrorMessage; + } + + // You could emit this through a state management solution + // For now, just log it + print('API Error: $errorMessage'); + + handler.next(error); + }, + )); + } + + void setAuthToken(String token) { + _dio.options.headers['Authorization'] = 'Bearer $token'; + } + + void clearAuthToken() { + _dio.options.headers.remove('Authorization'); + } + + // Tracks API + Future> getTracks({int limit = 20, int offset = 0}) async { + try { + final response = await _dio.get('/tracks', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + + return response.data['tracks'] ?? []; + } catch (e) { + throw Exception('Failed to load tracks: $e'); + } + } + + Future getTrack(String trackhash) async { + try { + final response = await _dio.get('/track/$trackhash'); + return response.data['track']; + } catch (e) { + throw Exception('Failed to load track: $e'); + } + } + + Future> searchTracks(String query, {int limit = 15}) async { + try { + final response = await _dio.get('/search/tracks', queryParameters: { + 'q': query, + 'limit': limit, + }); + + return response.data['tracks'] ?? []; + } catch (e) { + throw Exception('Failed to search tracks: $e'); + } + } + + // Albums API + Future> getAlbums({int limit = 20, int offset = 0}) async { + try { + final response = await _dio.get('/albums', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + + return response.data['albums'] ?? []; + } catch (e) { + throw Exception('Failed to load albums: $e'); + } + } + + Future getAlbum(String albumhash) async { + try { + final response = await _dio.get('/album/$albumhash'); + return response.data['album']; + } catch (e) { + throw Exception('Failed to load album: $e'); + } + } + + Future> getAlbumTracks(String albumhash) async { + try { + final response = await _dio.get('/album/$albumhash/tracks'); + + return response.data['tracks'] ?? []; + } catch (e) { + throw Exception('Failed to load album tracks: $e'); + } + } + + // Artists API + Future> getArtists({int limit = 20, int offset = 0}) async { + try { + final response = await _dio.get('/artists', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + + return response.data['artists'] ?? []; + } catch (e) { + throw Exception('Failed to load artists: $e'); + } + } + + Future getArtist(String artisthash) async { + try { + final response = await _dio.get('/artist/$artisthash'); + return response.data['artist']; + } catch (e) { + throw Exception('Failed to load artist: $e'); + } + } + + Future> getArtistAlbums(String artisthash) async { + try { + final response = await _dio.get('/artist/$artisthash/albums'); + + return response.data['albums'] ?? []; + } catch (e) { + throw Exception('Failed to load artist albums: $e'); + } + } + + Future> getArtistTracks(String artisthash) async { + try { + final response = await _dio.get('/artist/$artisthash/tracks'); + + return response.data['tracks'] ?? []; + } catch (e) { + throw Exception('Failed to load artist tracks: $e'); + } + } + + // Playlists API + Future> getPlaylists() async { + try { + final response = await _dio.get('/playlists'); + + return response.data['playlists'] ?? []; + } catch (e) { + throw Exception('Failed to load playlists: $e'); + } + } + + Future getPlaylist(String playlistId) async { + try { + final response = await _dio.get('/playlist/$playlistId'); + return response.data['playlist']; + } catch (e) { + throw Exception('Failed to load playlist: $e'); + } + } + + Future createPlaylist(String name, {String description = ''}) async { + try { + final response = await _dio.post('/playlists', data: { + 'name': name, + 'description': description, + }); + + return response.data['playlist']; + } catch (e) { + throw Exception('Failed to create playlist: $e'); + } + } + + Future addToPlaylist(String playlistId, String trackhash) async { + try { + await _dio.post('/playlist/$playlistId/add', data: { + 'trackhash': trackhash, + }); + } catch (e) { + throw Exception('Failed to add to playlist: $e'); + } + } + + Future removeFromPlaylist(String playlistId, String trackhash) async { + try { + await _dio.delete('/playlist/$playlistId/remove', data: { + 'trackhash': trackhash, + }); + } catch (e) { + throw Exception('Failed to remove from playlist: $e'); + } + } + + // Favorites API + Future toggleFavoriteTrack(String trackhash) async { + try { + await _dio.post('/favorites/track/toggle', data: { + 'trackhash': trackhash, + }); + } catch (e) { + throw Exception('Failed to toggle favorite track: $e'); + } + } + + Future toggleFavoriteAlbum(String albumhash) async { + try { + await _dio.post('/favorites/album/toggle', data: { + 'albumhash': albumhash, + }); + } catch (e) { + throw Exception('Failed to toggle favorite album: $e'); + } + } + + Future toggleFavoriteArtist(String artisthash) async { + try { + await _dio.post('/favorites/artist/toggle', data: { + 'artisthash': artisthash, + }); + } catch (e) { + throw Exception('Failed to toggle favorite artist: $e'); + } + } + + Future> getFavoriteTracks() async { + try { + final response = await _dio.get('/favorites/tracks'); + + return response.data['tracks'] ?? []; + } catch (e) { + throw Exception('Failed to load favorite tracks: $e'); + } + } + + Future> getFavoriteAlbums() async { + try { + final response = await _dio.get('/favorites/albums'); + + return response.data['albums'] ?? []; + } catch (e) { + throw Exception('Failed to load favorite albums: $e'); + } + } + + Future> getFavoriteArtists() async { + try { + final response = await _dio.get('/favorites/artists'); + + return response.data['artists'] ?? []; + } catch (e) { + throw Exception('Failed to load favorite artists: $e'); + } + } +} diff --git a/swingmusic_mobile/lib/data/services/audio_service.dart b/swingmusic_mobile/lib/data/services/audio_service.dart new file mode 100644 index 00000000..75dadbfd --- /dev/null +++ b/swingmusic_mobile/lib/data/services/audio_service.dart @@ -0,0 +1,403 @@ +import 'dart:async'; +import 'package:just_audio/just_audio.dart'; +import 'package:audio_session/audio_session.dart'; +import '../models/track_model.dart'; +import '../../core/enums/playback_mode.dart'; + +class AudioService { + static final AudioService _instance = AudioService._internal(); + factory AudioService() => _instance; + AudioService._internal(); + + late AudioPlayer _audioPlayer; + late AudioSession _audioSession; + + // Playback state + TrackModel? _currentTrack; + bool _isPlaying = false; + bool _isLoading = false; + bool _isBuffering = false; + Duration _position = Duration.zero; + Duration _duration = Duration.zero; + double _volume = 1.0; + + // Playback modes + RepeatMode _repeatMode = RepeatMode.off; + ShuffleMode _shuffleMode = ShuffleMode.off; + double _playbackSpeed = 1.0; + + // Playlist + List _queue = []; + int _currentIndex = 0; + bool _isShuffleMode = false; + bool _isRepeatMode = false; + + // Error handling + String? _errorMessage; + + void _setError(String error) { + _errorMessage = error; + _errorController.add(_errorMessage); + print('Audio Error: $error'); + } + + void _clearError() { + if (_errorMessage != null) { + _errorMessage = null; + _errorController.add(_errorMessage); + } + } + + // Stream controllers + final _positionController = StreamController.broadcast(); + final _durationController = StreamController.broadcast(); + final _playingStateController = StreamController.broadcast(); + final _currentTrackController = StreamController.broadcast(); + final _queueController = StreamController>.broadcast(); + final _bufferingController = StreamController.broadcast(); + final _errorController = StreamController.broadcast(); + final _repeatModeController = StreamController.broadcast(); + final _shuffleModeController = StreamController.broadcast(); + + // Getters + TrackModel? get currentTrack => _currentTrack; + bool get isPlaying => _isPlaying; + bool get isPaused => !_isPlaying && _currentTrack != null; + bool get isLoading => _isLoading; + bool get isBuffering => _isBuffering; + Duration get position => _position; + Duration get duration => _duration; + double get volume => _volume; + List get queue => _queue; + int get currentIndex => _currentIndex; + bool get isShuffleMode => _isShuffleMode; + bool get isRepeatMode => _isRepeatMode; + RepeatMode get repeatMode => _repeatMode; + ShuffleMode get shuffleMode => _shuffleMode; + double get playbackSpeed => _playbackSpeed; + String? get errorMessage => _errorMessage; + + // Playback state helpers + bool get hasError => _errorMessage != null; + bool get canPlay => _currentTrack != null && !hasError; + bool get canPause => _isPlaying && !hasError; + bool get canGoNext => _queue.isNotEmpty && _currentIndex < _queue.length - 1; + bool get canGoPrevious => _queue.isNotEmpty && _currentIndex > 0; + + // Streams + Stream get positionStream => _positionController.stream; + Stream get durationStream => _durationController.stream; + Stream get playingStateStream => _playingStateController.stream; + Stream get currentTrackStream => _currentTrackController.stream; + Stream> get queueStream => _queueController.stream; + Stream get bufferingStream => _bufferingController.stream; + Stream get errorStream => _errorController.stream; + Stream get repeatModeStream => _repeatModeController.stream; + Stream get shuffleModeStream => _shuffleModeController.stream; + + Future initialize() async { + try { + _audioPlayer = AudioPlayer(); + _audioSession = await AudioSession.instance; + + // Configure audio session + await _audioSession.configure(const AudioSessionConfiguration.music()); + + // Set up listeners + _audioPlayer.positionStream.listen((position) { + _position = position; + _positionController.add(position); + }); + + _audioPlayer.durationStream.listen((duration) { + _duration = duration ?? Duration.zero; + _durationController.add(_duration); + }); + + _audioPlayer.playerStateStream.listen((state) { + _isPlaying = state.playing; + _playingStateController.add(_isPlaying); + }); + + // Handle player completion + _audioPlayer.playerStateStream.listen((state) { + if (state.processingState == ProcessingState.completed) { + _playNext(); + } + + // Handle buffering state + _isBuffering = state.processingState == ProcessingState.buffering || + state.processingState == ProcessingState.loading; + _bufferingController.add(_isBuffering); + }); + + // Handle player errors + _audioPlayer.playerStateStream.listen((state) { + if (state.playing && _errorMessage != null) { + _clearError(); + } + }); + + print('Audio service initialized successfully'); + } catch (e) { + throw Exception('Failed to initialize audio service: $e'); + } + } + + Future loadTrack(TrackModel track) async { + try { + _clearError(); + _isLoading = true; + _isBuffering = true; + _currentTrack = track; + _currentTrackController.add(_currentTrack); + _bufferingController.add(_isBuffering); + + // Create audio source from track filepath + final uri = Uri.parse(track.filepath); + await _audioPlayer.setAudioSource(AudioSource.uri(uri)); + + _isLoading = false; + _isBuffering = false; + _bufferingController.add(_isBuffering); + print('Track loaded: ${track.title}'); + } catch (e) { + _isLoading = false; + _isBuffering = false; + _bufferingController.add(_isBuffering); + _setError('Failed to load track: $e'); + throw Exception('Failed to load track: $e'); + } + } + + Future play() async { + try { + _clearError(); + if (_currentTrack != null && !hasError) { + await _audioPlayer.play(); + _isPlaying = true; + _playingStateController.add(_isPlaying); + print('Playing: ${_currentTrack?.title}'); + } + } catch (e) { + _setError('Failed to play: $e'); + throw Exception('Failed to play: $e'); + } + } + + Future pause() async { + try { + await _audioPlayer.pause(); + _isPlaying = false; + _playingStateController.add(_isPlaying); + print('Paused: ${_currentTrack?.title}'); + } catch (e) { + _setError('Failed to pause: $e'); + throw Exception('Failed to pause: $e'); + } + } + + Future stop() async { + try { + await _audioPlayer.stop(); + _isPlaying = false; + _position = Duration.zero; + _playingStateController.add(_isPlaying); + _positionController.add(_position); + _clearError(); + print('Stopped: ${_currentTrack?.title}'); + } catch (e) { + _setError('Failed to stop: $e'); + throw Exception('Failed to stop: $e'); + } + } + + Future seekTo(Duration position) async { + try { + await _audioPlayer.seek(position); + _position = position; + _positionController.add(_position); + } catch (e) { + throw Exception('Failed to seek: $e'); + } + } + + Future setVolume(double volume) async { + try { + await _audioPlayer.setVolume(volume); + } catch (e) { + throw Exception('Failed to set volume: $e'); + } + } + + Future setSpeed(double speed) async { + try { + await _audioPlayer.setSpeed(speed); + } catch (e) { + throw Exception('Failed to set speed: $e'); + } + } + + // Queue management + void setQueue(List tracks) { + _queue = List.from(tracks); + _currentIndex = 0; + _queueController.add(_queue); + + if (_queue.isNotEmpty && _currentTrack == null) { + loadTrack(_queue[_currentIndex]); + } + } + + void addToQueue(TrackModel track) { + _queue.add(track); + _queueController.add(_queue); + } + + void removeFromQueue(int index) { + if (index < _queue.length) { + _queue.removeAt(index); + if (index < _currentIndex) { + _currentIndex--; + } else if (index == _currentIndex) { + if (_currentIndex >= _queue.length) { + _currentIndex = _queue.length - 1; + } + loadTrack(_queue[_currentIndex]); + } + _queueController.add(_queue); + } + } + + void clearQueue() { + _queue.clear(); + _currentIndex = 0; + _queueController.add(_queue); + } + + Future playNext() async { + if (_queue.isNotEmpty) { + _playNext(); + } + } + + Future playPrevious() async { + if (_queue.isNotEmpty) { + if (_currentIndex > 0) { + _currentIndex--; + await loadTrack(_queue[_currentIndex]); + await play(); + } else if (_repeatMode == RepeatMode.all) { + // Loop to last track + _currentIndex = _queue.length - 1; + await loadTrack(_queue[_currentIndex]); + await play(); + } else { + // Restart current track if at beginning + await seekTo(Duration.zero); + await play(); + } + } + } + + void _playNext() { + if (_repeatMode == RepeatMode.one) { + // Repeat current track + loadTrack(_queue[_currentIndex]); + play(); + } else if (_shuffleMode == ShuffleMode.on) { + // Play random track + if (_queue.isNotEmpty) { + _currentIndex = (_currentIndex + 1) % _queue.length; + loadTrack(_queue[_currentIndex]); + play(); + } + } else { + // Play next track in order + if (_currentIndex < _queue.length - 1) { + _currentIndex++; + loadTrack(_queue[_currentIndex]); + play(); + } else if (_repeatMode == RepeatMode.all) { + // Loop back to first track + _currentIndex = 0; + loadTrack(_queue[_currentIndex]); + play(); + } else { + // End of queue + stop(); + } + } + } + + void jumpToIndex(int index) { + if (index >= 0 && index < _queue.length) { + _currentIndex = index; + loadTrack(_queue[_currentIndex]); + } + } + + // Playback modes + void toggleShuffle() { + _shuffleMode = _shuffleMode.toggle(); + _shuffleModeController.add(_shuffleMode); + + if (_shuffleMode == ShuffleMode.on && _queue.isNotEmpty) { + // Shuffle the queue while maintaining current track + final currentTrack = _queue[_currentIndex]; + _queue.shuffle(); + _currentIndex = _queue.indexOf(currentTrack); + _queueController.add(_queue); + } + } + + void toggleRepeat() { + _repeatMode = _repeatMode.next(); + _repeatModeController.add(_repeatMode); + } + + void setShuffleMode(bool enabled) { + _shuffleMode = enabled ? ShuffleMode.on : ShuffleMode.off; + _shuffleModeController.add(_shuffleMode); + + if (_shuffleMode == ShuffleMode.on && _queue.isNotEmpty) { + // Shuffle the queue while maintaining current track + final currentTrack = _queue[_currentIndex]; + _queue.shuffle(); + _currentIndex = _queue.indexOf(currentTrack); + _queueController.add(_queue); + } + } + + void setRepeatMode(RepeatMode mode) { + _repeatMode = mode; + _repeatModeController.add(_repeatMode); + } + + // Utility methods + String get positionFormatted { + final minutes = _position.inMinutes; + final seconds = _position.inSeconds % 60; + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + + String get durationFormatted { + final minutes = _duration.inMinutes; + final seconds = _duration.inSeconds % 60; + return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}'; + } + + double get progress { + if (_duration.inMilliseconds == 0) return 0.0; + return _position.inMilliseconds / _duration.inMilliseconds; + } + + Future dispose() async { + await _positionController.close(); + await _durationController.close(); + await _playingStateController.close(); + await _currentTrackController.close(); + await _queueController.close(); + await _audioPlayer.dispose(); + } +} diff --git a/swingmusic_mobile/lib/data/services/download_service.dart b/swingmusic_mobile/lib/data/services/download_service.dart new file mode 100644 index 00000000..39f7f7f8 --- /dev/null +++ b/swingmusic_mobile/lib/data/services/download_service.dart @@ -0,0 +1,294 @@ +import 'package:dio/dio.dart'; +import 'package:path/path.dart'; + +class DownloadService { + late Dio _dio; + final String baseUrl; + final String _downloadPath; + + DownloadService({String? baseUrl, String? downloadPath}) + : baseUrl = baseUrl ?? 'https://your-server.com', + _downloadPath = downloadPath ?? '/storage/emulated/0/Android/data/com.example.swingmusic/files/Downloads'; + + DownloadService() { + _dio = Dio(BaseOptions( + baseUrl: baseUrl, + connectTimeout: const Duration(seconds: 30), + receiveTimeout: const Duration(seconds: 30), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + )); + + _dio.interceptors.add(LogInterceptor( + requestBody: true, + responseBody: true, + logPrint: (obj) { + print('Download API: $obj'); + }, + )); + + _dio.interceptors.add(InterceptorsWrapper( + onError: (error, handler) { + String errorMessage = 'Download failed'; + + if (error.type == DioExceptionType.connectionTimeout || + error.type == DioExceptionType.receiveTimeout) { + errorMessage = 'Network timeout - please check your connection'; + } else if (error.response?.statusCode == 404) { + errorMessage = 'Download not found'; + } else if (error.response?.statusCode == 500) { + errorMessage = 'Server error - please try again later'; + } else if (error.response?.statusCode == 503) { + errorMessage = 'Service unavailable - downloads are disabled'; + } + + print('Download Error: $errorMessage'); + handler.next(error); + }, + )); + } + + void setAuthToken(String token) { + _dio.options.headers['Authorization'] = 'Bearer $token'; + } + + Future> getDownloads() async { + try { + final response = await _dio.get('/downloads'); + + if (response.statusCode == 200) { + return response.data as Map? ?? {}; + } else { + return {}; + } + } catch (e) { + print('Error fetching downloads: $e'); + return {}; + } + } + + Future?> getDownload(String downloadId) async { + try { + final response = await _dio.get('/download/$downloadId'); + + if (response.statusCode == 200) { + return response.data as Map?; + } else { + return null; + } + } catch (e) { + print('Error fetching download: $e'); + return null; + } + } + + Future downloadTrack(String trackHash, { + String quality = '320kbps', + bool wifiOnly = false, + }) async { + try { + final response = await _dio.post('/download/track', data: { + 'trackHash': trackHash, + 'quality': quality, + 'wifiOnly': wifiOnly, + }); + + if (response.statusCode == 200) { + final data = response.data; + return data['downloadId'] as String? ?? ''; + } else { + throw Exception('Failed to start download'); + } + } catch (e) { + throw Exception('Failed to start download: $e'); + } + } + + Future downloadAlbum(String albumHash, { + String quality = '320kbps', + bool wifiOnly = false, + }) async { + try { + final response = await _dio.post('/download/album', data: { + 'albumHash': albumHash, + 'quality': quality, + 'wifiOnly': wifiOnly, + }); + + if (response.statusCode == 200) { + final data = response.data; + return data['downloadId'] as String? ?? ''; + } else { + throw Exception('Failed to start download'); + } + } catch (e) { + throw Exception('Failed to start download: $e'); + } + } + + Future downloadArtist(String artistHash, { + String quality = '320kbps', + bool wifiOnly = false, + }) async { + try { + final response = await _dio.post('/download/artist', data: { + 'artistHash': artistHash, + 'quality': quality, + 'wifiOnly': wifiOnly, + }); + + if (response.statusCode == 200) { + final data = response.data; + return data['downloadId'] as String? ?? ''; + } else { + throw Exception('Failed to start download'); + } + } catch (e) { + throw Exception('Failed to start download: $e'); + } + } + + Future downloadPlaylist(String playlistId, { + String quality = '320kbps', + bool wifiOnly = false, + }) async { + try { + final response = await _dio.post('/download/playlist', data: { + 'playlistId': playlistId, + 'quality': quality, + 'wifiOnly': wifiOnly, + }); + + if (response.statusCode == 200) { + final data = response.data; + return data['downloadId'] as String? ?? ''; + } else { + throw Exception('Failed to start download'); + } + } catch (e) { + throw Exception('Failed to start download: $e'); + } + } + + Future pauseDownload(String downloadId) async { + try { + final response = await _dio.post('/download/$downloadId/pause'); + + return response.statusCode == 200; + } catch (e) { + print('Error pausing download: $e'); + return false; + } + } + + Future resumeDownload(String downloadId) async { + try { + final response = await _dio.post('/download/$downloadId/resume'); + + return response.statusCode == 200; + } catch (e) { + print('Error resuming download: $e'); + return false; + } + } + + Future cancelDownload(String downloadId) async { + try { + final response = await _dio.post('/download/$downloadId/cancel'); + + return response.statusCode == 200; + } catch (e) { + print('Error canceling download: $e'); + return false; + } + } + + Future deleteDownload(String downloadId) async { + try { + final response = await _dio.delete('/download/$downloadId'); + + return response.statusCode == 200; + } catch (e) { + print('Error deleting download: $e'); + return false; + } + } + + Future> getDownloadStats() async { + try { + final response = await _dio.get('/download/stats'); + + if (response.statusCode == 200) { + return response.data as Map? ?? {}; + } else { + return {}; + } + } catch (e) { + print('Error fetching download stats: $e'); + return {}; + } + } + + Future getDownloadPath() async { + // TODO: Implement actual path resolution + return _downloadPath; + } + + Future updateDownloadSettings({ + String? downloadPath, + String? defaultQuality, + bool? wifiOnly, + int? maxConcurrentDownloads, + }) async { + try { + final response = await _dio.post('/download/settings', data: { + if (downloadPath != null) 'downloadPath': downloadPath, + if (defaultQuality != null) 'defaultQuality': defaultQuality, + if (wifiOnly != null) 'wifiOnly': wifiOnly, + if (maxConcurrentDownloads != null) 'maxConcurrentDownloads': maxConcurrentDownloads, + }); + + return response.statusCode == 200; + } catch (e) { + print('Error updating download settings: $e'); + return false; + } + } + + Future> getDownloadSettings() async { + try { + final response = await _dio.get('/download/settings'); + + if (response.statusCode == 200) { + return response.data as Map? ?? {}; + } else { + return {}; + } + } catch (e) { + print('Error fetching download settings: $e'); + return {}; + } + } + + Stream> watchDownloadProgress(String downloadId) { + // TODO: Implement WebSocket or SSE for real-time progress updates + // For now, return periodic polling + return Stream.periodic(const Duration(seconds: 1), (count) async { + final download = await getDownload(downloadId); + + if (download != null) { + return { + 'downloadId': downloadId, + 'progress': download['progress'] ?? 0.0, + 'status': download['status'] ?? 'unknown', + 'speed': download['speed'] ?? 0.0, + 'eta': download['eta'] ?? 0, + }; + } + + return {}; + }); + } +} diff --git a/swingmusic_mobile/lib/data/services/enhanced_api_service.dart b/swingmusic_mobile/lib/data/services/enhanced_api_service.dart new file mode 100644 index 00000000..b5476b33 --- /dev/null +++ b/swingmusic_mobile/lib/data/services/enhanced_api_service.dart @@ -0,0 +1,545 @@ +import 'package:dio/dio.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../models/track_model.dart'; +import '../models/album_model.dart'; +import '../models/artist_model.dart'; +import '../models/playlist_model.dart'; +import '../models/search_suggestion_model.dart'; +import '../../core/constants/app_constants.dart'; + +class EnhancedApiService { + late Dio _dio; + final String baseUrl; + final SharedPreferences _prefs; + + EnhancedApiService({String? baseUrl}) : baseUrl = baseUrl ?? AppConstants.defaultApiUrl { + _dio = Dio(BaseOptions( + baseUrl: baseUrl, + connectTimeout: AppConstants.apiTimeout, + receiveTimeout: AppConstants.apiTimeout, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + )); + + _prefs = SharedPreferences.getInstance() as Future; + + _dio.interceptors.add(LogInterceptor( + requestBody: true, + responseBody: true, + logPrint: (obj) { + print('API: $obj'); + }, + )); + + _dio.interceptors.add(InterceptorsWrapper( + onError: (error, handler) { + String errorMessage = AppConstants.genericErrorMessage; + + if (error.type == DioExceptionType.connectionTimeout || + error.type == DioExceptionType.receiveTimeout) { + errorMessage = AppConstants.networkErrorMessage; + } else if (error.response?.statusCode == 500) { + errorMessage = AppConstants.serverErrorMessage; + } else if (error.response?.statusCode == 401) { + errorMessage = AppConstants.authErrorMessage; + } else if (error.response?.statusCode == 404) { + errorMessage = 'Resource not found'; + } + + print('API Error: $errorMessage'); + handler.next(error); + }, + )); + } + + // Authentication methods + void setAuthToken(String token) { + _dio.options.headers['Authorization'] = 'Bearer $token'; + } + + void clearAuthToken() { + _dio.options.headers.remove('Authorization'); + } + + // Track methods + Future> getTracks({ + int limit = 20, + int offset = 0, + String? search, + String? genre, + String? artist, + String? album, + String? folder, + }) async { + try { + Map queryParams = { + 'limit': limit, + 'offset': offset, + }; + + if (search != null && search.isNotEmpty) { + queryParams['search'] = search; + } + if (genre != null && genre.isNotEmpty) { + queryParams['genre'] = genre; + } + if (artist != null && artist.isNotEmpty) { + queryParams['artist'] = artist; + } + if (album != null && album.isNotEmpty) { + queryParams['album'] = album; + } + if (folder != null && folder.isNotEmpty) { + queryParams['folder'] = folder; + } + + final response = await _dio.get('/tracks', queryParameters: queryParams); + final tracksData = response.data['tracks'] as List? ?? []; + + return tracksData.map((trackData) => TrackModel.fromJson(trackData)).toList(); + } catch (e) { + throw Exception('Failed to load tracks: $e'); + } + } + + Future getTrack(String trackHash) async { + try { + final response = await _dio.get('/track/$trackHash'); + final trackData = response.data['track']; + return trackData != null ? TrackModel.fromJson(trackData) : null; + } catch (e) { + throw Exception('Failed to load track: $e'); + } + } + + // Album methods + Future> getAlbums({ + int limit = 20, + int offset = 0, + String? search, + String? artist, + }) async { + try { + Map queryParams = { + 'limit': limit, + 'offset': offset, + }; + + if (search != null && search.isNotEmpty) { + queryParams['search'] = search; + } + if (artist != null && artist.isNotEmpty) { + queryParams['artist'] = artist; + } + + final response = await _dio.get('/albums', queryParameters: queryParams); + final albumsData = response.data['albums'] as List? ?? []; + + return albumsData.map((albumData) => AlbumModel.fromJson(albumData)).toList(); + } catch (e) { + throw Exception('Failed to load albums: $e'); + } + } + + Future getAlbum(String albumHash) async { + try { + final response = await _dio.get('/album/$albumHash'); + final albumData = response.data['album']; + return albumData != null ? AlbumModel.fromJson(albumData) : null; + } catch (e) { + throw Exception('Failed to load album: $e'); + } + } + + Future> getAlbumTracks(String albumHash, { + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/album/$albumHash/tracks', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final tracksData = response.data['tracks'] as List? ?? []; + + return tracksData.map((trackData) => TrackModel.fromJson(trackData)).toList(); + } catch (e) { + throw Exception('Failed to load album tracks: $e'); + } + } + + // Artist methods + Future> getArtists({ + int limit = 20, + int offset = 0, + String? search, + }) async { + try { + Map queryParams = { + 'limit': limit, + 'offset': offset, + }; + + if (search != null && search.isNotEmpty) { + queryParams['search'] = search; + } + + final response = await _dio.get('/artists', queryParameters: queryParams); + final artistsData = response.data['artists'] as List? ?? []; + + return artistsData.map((artistData) => ArtistModel.fromJson(artistData)).toList(); + } catch (e) { + throw Exception('Failed to load artists: $e'); + } + } + + Future getArtist(String artistHash) async { + try { + final response = await _dio.get('/artist/$artistHash'); + final artistData = response.data['artist']; + return artistData != null ? ArtistModel.fromJson(artistData) : null; + } catch (e) { + throw Exception('Failed to load artist: $e'); + } + } + + Future> getArtistAlbums(String artistHash, { + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/artist/$artistHash/albums', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final albumsData = response.data['albums'] as List? ?? []; + + return albumsData.map((albumData) => AlbumModel.fromJson(albumData)).toList(); + } catch (e) { + throw Exception('Failed to load artist albums: $e'); + } + } + + Future> getArtistTracks(String artistHash, { + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/artist/$artistHash/tracks', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final tracksData = response.data['tracks'] as List? ?? []; + + return tracksData.map((trackData) => TrackModel.fromJson(trackData)).toList(); + } catch (e) { + throw Exception('Failed to load artist tracks: $e'); + } + } + + // Playlist methods + Future> getPlaylists() async { + try { + final response = await _dio.get('/playlists'); + final playlistsData = response.data['playlists'] as List? ?? []; + + return playlistsData.map((playlistData) => PlaylistModel.fromJson(playlistData)).toList(); + } catch (e) { + throw Exception('Failed to load playlists: $e'); + } + } + + Future getPlaylist(String playlistId) async { + try { + final response = await _dio.get('/playlist/$playlistId'); + final playlistData = response.data['playlist']; + return playlistData != null ? PlaylistModel.fromJson(playlistData) : null; + } catch (e) { + throw Exception('Failed to load playlist: $e'); + } + } + + Future createPlaylist(String name, String description) async { + try { + final response = await _dio.post('/playlists', data: { + 'name': name, + 'description': description, + }); + + return PlaylistModel.fromJson(response.data['playlist']); + } catch (e) { + throw Exception('Failed to create playlist: $e'); + } + } + + Future addToPlaylist(String playlistId, String trackHash) async { + try { + await _dio.post('/playlist/$playlistId/add', data: { + 'trackhash': trackHash, + }); + } catch (e) { + throw Exception('Failed to add to playlist: $e'); + } + } + + Future removeFromPlaylist(String playlistId, String trackHash) async { + try { + await _dio.delete('/playlist/$playlistId/remove', data: { + 'trackhash': trackHash, + }); + } catch (e) { + throw Exception('Failed to remove from playlist: $e'); + } + } + + // Favorites methods + Future toggleFavoriteTrack(String trackHash) async { + try { + await _dio.post('/favorites/track/toggle', data: { + 'trackhash': trackHash, + }); + } catch (e) { + throw Exception('Failed to toggle favorite track: $e'); + } + } + + Future toggleFavoriteAlbum(String albumHash) async { + try { + await _dio.post('/favorites/album/toggle', data: { + 'albumhash': albumHash, + }); + } catch (e) { + throw Exception('Failed to toggle favorite album: $e'); + } + } + + Future toggleFavoriteArtist(String artistHash) async { + try { + await _dio.post('/favorites/artist/toggle', data: { + 'artisthash': artistHash, + }); + } catch (e) { + throw Exception('Failed to toggle favorite artist: $e'); + } + } + + Future> getFavoriteTracks({ + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/favorites/tracks', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final tracksData = response.data['tracks'] as List? ?? []; + + return tracksData.map((trackData) => TrackModel.fromJson(trackData)).toList(); + } catch (e) { + throw Exception('Failed to load favorite tracks: $e'); + } + } + + Future> getFavoriteAlbums({ + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/favorites/albums', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final albumsData = response.data['albums'] as List? ?? []; + + return albumsData.map((albumData) => AlbumModel.fromJson(albumData)).toList(); + } catch (e) { + throw Exception('Failed to load favorite albums: $e'); + } + } + + Future> getFavoriteArtists({ + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/favorites/artists', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final artistsData = response.data['artists'] as List? ?? []; + + return artistsData.map((artistData) => ArtistModel.fromJson(artistData)).toList(); + } catch (e) { + throw Exception('Failed to load favorite artists: $e'); + } + } + + // Search methods + Future> getSearchSuggestions(String query) async { + try { + final response = await _dio.get('/search/suggestions', queryParameters: { + 'q': query, + 'limit': 10, + }); + final suggestionsData = response.data['suggestions'] as List? ?? []; + + return suggestionsData.map((suggestionData) => SearchSuggestionModel.fromJson(suggestionData)).toList(); + } catch (e) { + throw Exception('Failed to get search suggestions: $e'); + } + } + + // Folder methods + Future> getFolders() async { + try { + final response = await _dio.get('/folders'); + return response.data['folders'] as List? ?? []; + } catch (e) { + throw Exception('Failed to load folders: $e'); + } + } + + Future> getFolderTracks(String folderHash, { + int limit = 20, + int offset = 0, + }) async { + try { + final response = await _dio.get('/folder/$folderHash/tracks', queryParameters: { + 'limit': limit, + 'offset': offset, + }); + final tracksData = response.data['tracks'] as List? ?? []; + + return tracksData.map((trackData) => TrackModel.fromJson(trackData)).toList(); + } catch (e) { + throw Exception('Failed to load folder tracks: $e'); + } + } + + // User methods + Future> getUserInfo() async { + try { + final response = await _dio.get('/user/info'); + return response.data as Map? ?? {}; + } catch (e) { + throw Exception('Failed to get user info: $e'); + } + } + + Future updateUserPreferences(Map preferences) async { + try { + await _dio.post('/user/preferences', data: preferences); + } catch (e) { + throw Exception('Failed to update user preferences: $e'); + } + } + + Future> getUserPreferences() async { + try { + final response = await _dio.get('/user/preferences'); + return response.data as Map? ?? {}; + } catch (e) { + throw Exception('Failed to get user preferences: $e'); + } + } + + // Statistics methods + Future> getStatistics() async { + try { + final response = await _dio.get('/statistics'); + return response.data as Map? ?? {}; + } catch (e) { + throw Exception('Failed to get statistics: $e'); + } + } + + // Download methods + Future downloadTrack(String trackHash) async { + try { + await _dio.post('/download/track', data: { + 'trackhash': trackHash, + }); + } catch (e) { + throw Exception('Failed to download track: $e'); + } + } + + Future> getDownloads() async { + try { + final response = await _dio.get('/downloads'); + return response.data['downloads'] as List? ?? []; + } catch (e) { + throw Exception('Failed to get downloads: $e'); + } + } + + Future deleteDownload(String downloadId) async { + try { + await _dio.delete('/download/$downloadId'); + } catch (e) { + throw Exception('Failed to delete download: $e'); + } + } + + // Lyrics methods + Future getLyrics(String trackHash) async { + try { + final response = await _dio.get('/lyrics/$trackHash'); + return response.data['lyrics'] as String?; + } catch (e) { + throw Exception('Failed to get lyrics: $e'); + } + } + + // Queue methods + Future> getQueue() async { + try { + final response = await _dio.get('/queue'); + final tracksData = response.data['tracks'] as List? ?? []; + + return tracksData.map((trackData) => TrackModel.fromJson(trackData)).toList(); + } catch (e) { + throw Exception('Failed to get queue: $e'); + } + } + + Future addToQueue(String trackHash) async { + try { + await _dio.post('/queue/add', data: { + 'trackhash': trackHash, + }); + } catch (e) { + throw Exception('Failed to add to queue: $e'); + } + } + + Future removeFromQueue(String trackHash) async { + try { + await _dio.delete('/queue/remove', data: { + 'trackhash': trackHash, + }); + } catch (e) { + throw Exception('Failed to remove from queue: $e'); + } + } + + Future clearQueue() async { + try { + await _dio.delete('/queue/clear'); + } catch (e) { + throw Exception('Failed to clear queue: $e'); + } + } + + Future reorderQueue(List trackHashes) async { + try { + await _dio.post('/queue/reorder', data: { + 'track_hashes': trackHashes, + }); + } catch (e) { + throw Exception('Failed to reorder queue: $e'); + } + } +} diff --git a/swingmusic_mobile/lib/data/services/lyrics_service.dart b/swingmusic_mobile/lib/data/services/lyrics_service.dart new file mode 100644 index 00000000..91b99d9c --- /dev/null +++ b/swingmusic_mobile/lib/data/services/lyrics_service.dart @@ -0,0 +1,114 @@ +import 'package:dio/dio.dart'; +import '../models/track_model.dart'; + +class LyricsService { + late Dio _dio; + final String baseUrl; + + LyricsService({String? baseUrl}) : baseUrl = baseUrl ?? 'https://your-server.com' { + _dio = Dio(BaseOptions( + baseUrl: baseUrl, + connectTimeout: const Duration(seconds: 10), + receiveTimeout: const Duration(seconds: 10), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + )); + + _dio.interceptors.add(LogInterceptor( + requestBody: true, + responseBody: true, + logPrint: (obj) { + print('Lyrics API: $obj'); + }, + )); + + _dio.interceptors.add(InterceptorsWrapper( + onError: (error, handler) { + String errorMessage = 'Failed to load lyrics'; + + if (error.type == DioExceptionType.connectionTimeout || + error.type == DioExceptionType.receiveTimeout) { + errorMessage = 'Network timeout - please check your connection'; + } else if (error.response?.statusCode == 404) { + errorMessage = 'Lyrics not found for this track'; + } else if (error.response?.statusCode == 500) { + errorMessage = 'Server error - please try again later'; + } + + print('Lyrics Error: $errorMessage'); + handler.next(error); + }, + )); + } + + void setAuthToken(String token) { + _dio.options.headers['Authorization'] = 'Bearer $token'; + } + + Future getLyrics(String trackHash) async { + try { + final response = await _dio.get('/lyrics/$trackHash'); + + if (response.statusCode == 200) { + final data = response.data; + return data['lyrics'] as String?; + } else { + return null; + } + } catch (e) { + print('Error fetching lyrics: $e'); + return null; + } + } + + Future searchLyrics(String query, {int limit = 10}) async { + try { + final response = await _dio.get('/lyrics/search', queryParameters: { + 'q': query, + 'limit': limit, + }); + + if (response.statusCode == 200) { + final data = response.data; + final results = data['results'] as List? ?? []; + return results.isNotEmpty ? results.first['lyrics'] as String? : null; + } else { + return null; + } + } catch (e) { + print('Error searching lyrics: $e'); + return null; + } + } + + Future saveLyrics(String trackHash, String lyrics) async { + try { + final response = await _dio.post('/lyrics/save', data: { + 'trackHash': trackHash, + 'lyrics': lyrics, + }); + + return response.statusCode == 200; + } catch (e) { + print('Error saving lyrics: $e'); + return false; + } + } + + Future> getLyricsStats() async { + try { + final response = await _dio.get('/lyrics/stats'); + + if (response.statusCode == 200) { + return response.data as Map? ?? {}; + } else { + return {}; + } + } catch (e) { + print('Error fetching lyrics stats: $e'); + return {}; + } + } +} diff --git a/swingmusic_mobile/lib/features/analytics/analytics_screen.dart b/swingmusic_mobile/lib/features/analytics/analytics_screen.dart new file mode 100644 index 00000000..e6d32594 --- /dev/null +++ b/swingmusic_mobile/lib/features/analytics/analytics_screen.dart @@ -0,0 +1,442 @@ +import 'package:flutter/material.dart'; + +class AnalyticsScreen extends StatefulWidget { + const AnalyticsScreen({super.key}); + + @override + State createState() => _AnalyticsScreenState(); +} + +class _AnalyticsScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Analytics'), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Overview Cards + Row( + children: [ + Expanded( + child: _buildOverviewCard( + 'Total Plays', + Icons.play_arrow, + '12,345', + Theme.of(context).colorScheme.primary, + ), + ), + const SizedBox(width: 16), + Expanded( + child: _buildOverviewCard( + 'Total Listening Time', + Icons.access_time, + '48h 32m', + Theme.of(context).colorScheme.secondary, + ), + ), + ], + ), + const SizedBox(height: 16), + + // Top Tracks + _buildSectionHeader('Top Tracks'), + const SizedBox(height: 8), + _buildTopTracksList(), + + const SizedBox(height: 24), + + // Listening Stats + _buildSectionHeader('Listening Statistics'), + const SizedBox(height: 8), + _buildListeningStats(), + + const SizedBox(height: 24), + + // Genre Distribution + _buildSectionHeader('Genre Distribution'), + const SizedBox(height: 8), + _buildGenreChart(), + + const SizedBox(height: 24), + + // Time Distribution + _buildSectionHeader('Time Distribution'), + const SizedBox(height: 8), + _buildTimeChart(), + ], + ), + ), + ); + } + + Widget _buildSectionHeader(String title) { + return Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(12.0), + ), + child: Row( + children: [ + Icon( + Icons.analytics, + color: Theme.of(context).colorScheme.primary, + size: 24, + ), + const SizedBox(width: 12), + Text( + title, + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ); + } + + Widget _buildOverviewCard(String title, IconData icon, String value, Color color) { + return Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(12.0), + border: Border.all( + color: Theme.of(context).colorScheme.outline, + width: 1.0, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon( + icon, + color: Theme.of(context).colorScheme.onPrimary, + size: 32, + ), + const SizedBox(width: 12), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onPrimary, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + Text( + value, + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + color: Theme.of(context).colorScheme.onPrimary, + ), + ), + ], + ), + ], + ), + ], + ), + ); + } + + Widget _buildTopTracksList() { + final topTracks = [ + {'title': 'Bohemian Rhapsody', 'artist': 'Queen', 'plays': 1234, 'duration': '5:55'}, + {'title': 'Stairway to Heaven', 'artist': 'Led Zeppelin', 'plays': 987, 'duration': '8:02'}, + {'title': 'Hotel California', 'artist': 'Eagles', 'plays': 856, 'duration': '3:31'}, + {'title': 'Sweet Child O\' Mine', 'artist': 'Guns N\' Roses', 'plays': 743, 'duration': '5:44'}, + {'title': 'Don\'t Stop Believin\'', 'artist': 'Journey', 'plays': 654, 'duration': '4:12'}, + ]; + + return Card( + margin: const EdgeInsets.only(bottom: 16.0), + child: Column( + children: [ + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: topTracks.length, + itemBuilder: (context, index) { + final track = topTracks[index]; + return ListTile( + leading: CircleAvatar( + backgroundColor: Theme.of(context).colorScheme.primary, + child: Text( + '${index + 1}', + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + title: Text( + track['title']?.toString() ?? '', + style: Theme.of(context).textTheme.titleMedium, + ), + subtitle: Text( + track['artist']?.toString() ?? '', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + trailing: Text( + '${track['plays'] ?? 0} plays', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: Theme.of(context).colorScheme.primary, + fontWeight: FontWeight.bold, + ), + ), + ); + }, + ), + ], + ), + ); + } + + Widget _buildListeningStats() { + return Card( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Daily Average', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: _buildStatItem('Songs per Day', '24'), + ), + Expanded( + child: _buildStatItem('Hours per Day', '3.2'), + ), + ], + ), + const SizedBox(height: 16), + Text( + 'Weekly Average', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: _buildStatItem('Songs per Week', '168'), + ), + Expanded( + child: _buildStatItem('Hours per Week', '22.4'), + ), + ], + ), + const SizedBox(height: 16), + Text( + 'Monthly Average', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: _buildStatItem('Songs per Month', '730'), + ), + Expanded( + child: _buildStatItem('Hours per Month', '97.1'), + ), + ], + ), + ], + ), + ), + ); + } + + Widget _buildStatItem(String label, String value) { + return Container( + padding: const EdgeInsets.all(12.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainer, + borderRadius: BorderRadius.circular(8.0), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + value, + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + color: Theme.of(context).colorScheme.primary, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + Text( + label, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ); + } + + Widget _buildGenreChart() { + final genres = { + 'Rock': 35, + 'Pop': 28, + 'Electronic': 15, + 'Classical': 12, + 'Jazz': 8, + 'Hip-Hop': 7, + 'Country': 5, + }; + + return Card( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Genre Distribution', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 16), + SizedBox( + height: 200, + child: Wrap( + spacing: 8.0, + runSpacing: 8.0, + children: genres.entries.map((entry) { + return Chip( + label: Text(entry.key), + backgroundColor: _getGenreColor(entry.key), + labelStyle: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ); + }).toList(), + ), + ), + ], + ), + ), + ); + } + + Color _getGenreColor(String genre) { + switch (genre) { + case 'Rock': + return Colors.red; + case 'Pop': + return Colors.purple; + case 'Electronic': + return Colors.blue; + case 'Classical': + return Colors.brown; + case 'Jazz': + return Colors.orange; + case 'Hip-Hop': + return Colors.green; + case 'Country': + return Colors.amber; + default: + return Colors.grey; + } + } + + Widget _buildTimeChart() { + final timeData = [ + {'period': 'Morning', 'hours': 2.5, 'percentage': 15}, + {'period': 'Afternoon', 'hours': 4.2, 'percentage': 25}, + {'period': 'Evening', 'hours': 3.8, 'percentage': 22}, + {'period': 'Night', 'hours': 7.5, 'percentage': 38}, + ]; + + return Card( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Daily Listening Pattern', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 16), + SizedBox( + height: 200, + child: Column( + children: timeData.map((data) { + return Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + data['period']?.toString() ?? '', + style: Theme.of(context).textTheme.bodyMedium, + ), + Text( + '${data['percentage']}%', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: Theme.of(context).colorScheme.primary, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + Container( + height: 8, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.circular(4.0), + ), + child: FractionallySizedBox( + widthFactor: (data['percentage'] as int) / 100, + alignment: Alignment.centerLeft, + child: Container( + height: 4, + color: Colors.white, + ), + ), + ), + ], + ), + ); + }).toList(), + ), + ), + ], + ), + ), + ); + } +} diff --git a/swingmusic_mobile/lib/features/auth/auth_screen.dart b/swingmusic_mobile/lib/features/auth/auth_screen.dart new file mode 100644 index 00000000..14912e82 --- /dev/null +++ b/swingmusic_mobile/lib/features/auth/auth_screen.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; + +class AuthScreen extends StatefulWidget { + const AuthScreen({super.key}); + + @override + State createState() => _AuthScreenState(); +} + +class _AuthScreenState extends State { + bool _isLoading = false; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Authentication'), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Icons.music_note, + size: 80, + color: Colors.blue, + ), + const SizedBox(height: 24), + const Text( + 'SwingMusic', + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + const Text( + 'Connect to your music library', + style: TextStyle( + fontSize: 16, + color: Colors.grey, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 32), + ElevatedButton( + onPressed: _isLoading ? null : _handleLogin, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue, + foregroundColor: Colors.white, + ), + child: _isLoading + ? const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ) + : const Text('Login'), + ), + ], + ), + ), + ); + } + + void _handleLogin() async { + setState(() { + _isLoading = true; + }); + + await Future.delayed(const Duration(seconds: 2)); + + setState(() { + _isLoading = false; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Login successful!')), + ); + + Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); + } +} diff --git a/swingmusic_mobile/lib/features/auth/enhanced_auth_screen.dart b/swingmusic_mobile/lib/features/auth/enhanced_auth_screen.dart new file mode 100644 index 00000000..74af58ed --- /dev/null +++ b/swingmusic_mobile/lib/features/auth/enhanced_auth_screen.dart @@ -0,0 +1,468 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/auth_provider.dart'; +import '../../core/constants/app_spacing.dart'; +import '../../core/enums/auth_state.dart'; + +class EnhancedAuthScreen extends StatefulWidget { + const EnhancedAuthScreen({super.key}); + + @override + State createState() => _EnhancedAuthScreenState(); +} + +class _EnhancedAuthScreenState extends State { + final _formKey = GlobalKey(); + final _baseUrlController = TextEditingController(); + final _usernameController = TextEditingController(); + final _passwordController = TextEditingController(); + final _qrCodeController = TextEditingController(); + + bool _isPasswordVisible = false; + bool _isLoading = false; + bool _isQrMode = false; + String? _errorMessage; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + Provider.of(context, listen: false).initialize(); + }); + } + + @override + void dispose() { + _baseUrlController.dispose(); + _usernameController.dispose(); + _passwordController.dispose(); + _qrCodeController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.surface, + body: SafeArea( + child: SingleChildScrollView( + padding: AppSpacing.paddingLG, + child: Column( + children: [ + // Logo and Title + _buildHeader(context), + + const SizedBox(height: 32), + + // Auth Mode Toggle + _buildAuthModeToggle(context), + + const SizedBox(height: 32), + + // Auth Form + _buildAuthForm(context), + + const SizedBox(height: 24), + + // Error Message + if (_errorMessage != null) + _buildErrorMessage(context), + ], + ), + ), + ), + ); + } + + Widget _buildHeader(BuildContext context) { + return Column( + children: [ + Icon( + Icons.music_note, + size: 80, + color: Theme.of(context).colorScheme.primary, + ), + const SizedBox(height: 16), + Text( + 'SwingMusic', + style: Theme.of(context).textTheme.headlineLarge?.copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + const SizedBox(height: 8), + Text( + 'Connect to your music library', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + textAlign: TextAlign.center, + ), + ], + ); + } + + Widget _buildAuthModeToggle(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: () => setState(() => _isQrMode = false), + child: Container( + padding: const EdgeInsets.symmetric(vertical: 16), + decoration: BoxDecoration( + color: _isQrMode + ? Theme.of(context).colorScheme.surface + : Theme.of(context).colorScheme.primary, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(12), + bottomLeft: Radius.circular(12), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.person, + color: _isQrMode + ? Theme.of(context).colorScheme.onSurfaceVariant + : Theme.of(context).colorScheme.onPrimary, + ), + const SizedBox(width: 8), + Text( + 'Username & Password', + style: TextStyle( + color: _isQrMode + ? Theme.of(context).colorScheme.onSurfaceVariant + : Theme.of(context).colorScheme.onPrimary, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ), + Expanded( + child: GestureDetector( + onTap: () => setState(() => _isQrMode = true), + child: Container( + padding: const EdgeInsets.symmetric(vertical: 16), + decoration: BoxDecoration( + color: _isQrMode + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.surface, + borderRadius: const BorderRadius.only( + topRight: Radius.circular(12), + bottomRight: Radius.circular(12), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.qr_code_scanner, + color: _isQrMode + ? Theme.of(context).colorScheme.onPrimary + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(width: 8), + Text( + 'QR Code', + style: TextStyle( + color: _isQrMode + ? Theme.of(context).colorScheme.onPrimary + : Theme.of(context).colorScheme.onSurfaceVariant, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ), + ], + ), + ); + } + + Widget _buildAuthForm(BuildContext context) { + return Consumer( + builder: (context, authProvider, child) { + return Form( + key: _formKey, + child: Column( + children: [ + if (_isQrMode) ...[ + // QR Code Input + TextFormField( + controller: _qrCodeController, + decoration: InputDecoration( + labelText: 'QR Code', + hintText: 'Enter or scan QR code', + prefixIcon: const Icon(Icons.qr_code_scanner), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.outline, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + readOnly: true, + onTap: () => _scanQrCode(context), + ), + ] else ...[ + // Server URL Input + TextFormField( + controller: _baseUrlController, + decoration: InputDecoration( + labelText: 'Server URL', + hintText: 'https://your-server.com', + prefixIcon: const Icon(Icons.link), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.outline, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + validator: (value) { + if (value == null || value!.isEmpty) { + return 'Server URL is required'; + } + if (!_isValidUrl(value)) { + return 'Please enter a valid URL'; + } + return null; + }, + ), + + const SizedBox(height: 16), + + // Username Input + TextFormField( + controller: _usernameController, + decoration: InputDecoration( + labelText: 'Username', + hintText: 'Enter your username', + prefixIcon: const Icon(Icons.person), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.outline, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + validator: (value) { + if (value == null || value!.isEmpty) { + return 'Username is required'; + } + return null; + }, + ), + + const SizedBox(height: 16), + + // Password Input + TextFormField( + controller: _passwordController, + obscureText: !_isPasswordVisible, + decoration: InputDecoration( + labelText: 'Password', + hintText: 'Enter your password', + prefixIcon: const Icon(Icons.lock), + suffixIcon: IconButton( + onPressed: () => setState(() => _isPasswordVisible = !_isPasswordVisible), + icon: Icon( + _isPasswordVisible ? Icons.visibility : Icons.visibility_off, + ), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.outline, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + validator: (value) { + if (value == null || value!.isEmpty) { + return 'Password is required'; + } + return null; + }, + ), + ], + + const SizedBox(height: 24), + + // Login Button + SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + onPressed: _isLoading ? null : () => _handleLogin(context), + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Theme.of(context).colorScheme.onPrimary, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + child: _isLoading + ? const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ) + : Text( + _isQrMode ? 'Login with QR' : 'Login', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ], + ), + ); + }, + ); + } + + Widget _buildErrorMessage(BuildContext context) { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.errorContainer, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + children: [ + Icon( + Icons.error_outline, + color: Theme.of(context).colorScheme.error, + size: 20, + ), + const SizedBox(width: 8), + Expanded( + child: Text( + _errorMessage!, + style: TextStyle( + color: Theme.of(context).colorScheme.error, + fontSize: 14, + ), + ), + ), + IconButton( + onPressed: () => setState(() => _errorMessage = null), + icon: const Icon(Icons.close), + iconSize: 16, + color: Theme.of(context).colorScheme.error, + ), + ], + ), + ); + } + + bool _isValidUrl(String url) { + try { + final uri = Uri.parse(url); + return uri.hasScheme && (uri.scheme == 'http' || uri.scheme == 'https'); + } catch (e) { + return false; + } + } + + Future _handleLogin(BuildContext context) async { + if (!_formKey.currentState!.validate()) { + return; + } + + setState(() { + _isLoading = true; + _errorMessage = null; + }); + + try { + final authProvider = Provider.of(context, listen: false); + + if (_isQrMode) { + await authProvider.loginWithQrCode(_qrCodeController.text.trim()); + } else { + await authProvider.loginWithUsernameAndPassword( + _baseUrlController.text.trim(), + _usernameController.text.trim(), + _passwordController.text, + ); + } + + if (mounted) { + Navigator.of(context).pushReplacementNamed('/home'); + } + } catch (e) { + setState(() { + _isLoading = false; + _errorMessage = e.toString(); + }); + } + } + + Future _scanQrCode(BuildContext context) async { + try { + final qrCode = await Navigator.pushNamed('/qr'); + if (qrCode != null && mounted) { + _qrCodeController.text = qrCode!; + } + } catch (e) { + setState(() { + _errorMessage = 'Failed to scan QR code: $e'; + }); + } + } +} diff --git a/swingmusic_mobile/lib/features/folder/folder_screen.dart b/swingmusic_mobile/lib/features/folder/folder_screen.dart new file mode 100644 index 00000000..35fd36a3 --- /dev/null +++ b/swingmusic_mobile/lib/features/folder/folder_screen.dart @@ -0,0 +1,889 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../data/models/track_model.dart'; + +class FolderScreen extends StatefulWidget { + const FolderScreen({super.key}); + + @override + State createState() => _FolderScreenState(); +} + +class _FolderScreenState extends State { + List _folderItems = []; + List _currentPath = []; + bool _isLoading = false; + final TextEditingController _searchController = TextEditingController(); + String _currentFolderId = 'root'; + + @override + void initState() { + super.initState(); + _loadFolderContents(_currentFolderId); + } + + @override + void dispose() { + _searchController.dispose(); + super.dispose(); + } + + Future _loadFolderContents(String folderId) async { + setState(() { + _isLoading = true; + }); + + // Simulate API call + await Future.delayed(const Duration(milliseconds: 500)); + + setState(() { + _isLoading = false; + if (folderId == 'root') { + _currentPath = []; + _folderItems = [ + FolderItem( + id: 'music', + name: 'Music', + type: FolderType.folder, + itemCount: 156, + path: '/music', + modifiedDate: DateTime.now().subtract(const Duration(days: 1)), + ), + FolderItem( + id: 'downloads', + name: 'Downloads', + type: FolderType.folder, + itemCount: 42, + path: '/downloads', + modifiedDate: DateTime.now().subtract(const Duration(hours: 3)), + ), + FolderItem( + id: 'rock', + name: 'Rock', + type: FolderType.folder, + itemCount: 89, + path: '/music/rock', + modifiedDate: DateTime.now().subtract(const Duration(days: 7)), + ), + FolderItem( + id: 'pop', + name: 'Pop', + type: FolderType.folder, + itemCount: 67, + path: '/music/pop', + modifiedDate: DateTime.now().subtract(const Duration(days: 2)), + ), + FolderItem( + id: 'jazz', + name: 'Jazz', + type: FolderType.folder, + itemCount: 34, + path: '/music/jazz', + modifiedDate: DateTime.now().subtract(const Duration(days: 14)), + ), + FolderItem( + id: 'electronic', + name: 'Electronic', + type: FolderType.folder, + itemCount: 78, + path: '/music/electronic', + modifiedDate: DateTime.now().subtract(const Duration(days: 5)), + ), + FolderItem( + id: 'classical', + name: 'Classical', + type: FolderType.folder, + itemCount: 45, + path: '/music/classical', + modifiedDate: DateTime.now().subtract(const Duration(days: 21)), + ), + ]; + } else if (folderId == 'music') { + _currentPath = [ + FolderItem(id: 'root', name: '..', type: FolderType.folder, path: '/'), + FolderItem(id: 'rock', name: 'Rock', type: FolderType.folder, itemCount: 89, path: '/music/rock'), + FolderItem(id: 'pop', name: 'Pop', type: FolderType.folder, itemCount: 67, path: '/music/pop'), + FolderItem(id: 'jazz', name: 'Jazz', type: FolderType.folder, itemCount: 34, path: '/music/jazz'), + FolderItem(id: 'electronic', name: 'Electronic', type: FolderType.folder, itemCount: 78, path: '/music/electronic'), + FolderItem(id: 'classical', name: 'Classical', type: FolderType.folder, itemCount: 45, path: '/music/classical'), + ]; + _folderItems = [ + TrackFolderItem( + id: '1', + name: 'Bohemian Rhapsody.mp3', + artist: 'Queen', + album: 'A Night at the Opera', + duration: 334, + size: 5.2, + modifiedDate: DateTime.now().subtract(const Duration(days: 30)), + ), + TrackFolderItem( + id: '2', + name: 'Stairway to Heaven.mp3', + artist: 'Led Zeppelin', + album: 'Led Zeppelin IV', + duration: 482, + size: 7.8, + modifiedDate: DateTime.now().subtract(const Duration(days: 25)), + ), + TrackFolderItem( + id: '3', + name: 'Hotel California.mp3', + artist: 'Eagles', + album: 'Hotel California', + duration: 391, + size: 6.1, + modifiedDate: DateTime.now().subtract(const Duration(days: 20)), + ), + TrackFolderItem( + id: '4', + name: 'Sweet Child O\' Mine.mp3', + artist: 'Queen', + album: 'A Night at the Opera', + duration: 348, + size: 5.4, + modifiedDate: DateTime.now().subtract(const Duration(days: 15)), + ), + TrackFolderItem( + id: '5', + name: 'Another Brick in the Wall.mp3', + artist: 'Pink Floyd', + album: 'The Wall', + duration: 623, + size: 9.8, + modifiedDate: DateTime.now().subtract(const Duration(days: 10)), + ), + ]; + } else { + // Handle other folders with sample data + _currentPath = [ + FolderItem(id: 'root', name: '..', type: FolderType.folder, path: '/'), + ]; + _folderItems = [ + TrackFolderItem( + id: '1', + name: 'Sample Track.mp3', + artist: 'Sample Artist', + album: 'Sample Album', + duration: 240, + size: 4.2, + modifiedDate: DateTime.now().subtract(const Duration(days: 5)), + ), + ]; + } + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(_getFolderTitle()), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + leading: _currentFolderId != 'root' + ? IconButton( + onPressed: () => _navigateToFolder('root'), + icon: const Icon(Icons.arrow_back), + ) + : null, + actions: [ + PopupMenuButton( + onSelected: _handleMenuAction, + itemBuilder: (context) => [ + const PopupMenuItem( + value: 'sort_name', + child: ListTile( + leading: const Icon(Icons.sort_by_alpha), + title: Text('Sort by Name'), + contentPadding: EdgeInsets.zero, + ), + ), + const PopupMenuItem( + value: 'sort_date', + child: ListTile( + leading: const Icon(Icons.access_time), + title: Text('Sort by Date'), + contentPadding: EdgeInsets.zero, + ), + ), + const PopupMenuItem( + value: 'sort_size', + child: ListTile( + leading: const Icon(Icons.storage), + title: Text('Sort by Size'), + contentPadding: EdgeInsets.zero, + ), + ), + const PopupMenuItem( + value: 'view_list', + child: ListTile( + leading: const Icon(Icons.list), + title: Text('List View'), + contentPadding: EdgeInsets.zero, + ), + ), + const PopupMenuItem( + value: 'view_grid', + child: ListTile( + leading: const Icon(Icons.grid_view), + title: Text('Grid View'), + contentPadding: EdgeInsets.zero, + ), + ), + ], + ), + ], + ), + body: Column( + children: [ + // Breadcrumb Navigation + _buildBreadcrumbNavigation(), + + // Search Bar + Padding( + padding: const EdgeInsets.all(16.0), + child: TextField( + controller: _searchController, + decoration: InputDecoration( + hintText: 'Search in current folder...', + prefixIcon: const Icon(Icons.search), + suffixIcon: _searchController.text.isNotEmpty + ? IconButton( + onPressed: () { + _searchController.clear(); + }, + icon: const Icon(Icons.clear), + ) + : null, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerHighest, + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + ), + onChanged: (value) { + _filterItems(value); + }, + ), + ), + + // Folder Contents + Expanded( + child: _isLoading + ? const Center(child: CircularProgressIndicator()) + : _folderItems.isEmpty + ? _buildEmptyState() + : _buildFolderContents(), + ), + ], + ), + ); + } + + Widget _buildBreadcrumbNavigation() { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + // Root/Home + InkWell( + onTap: () => _navigateToFolder('root'), + borderRadius: BorderRadius.circular(8), + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: BoxDecoration( + color: _currentFolderId == 'root' + ? Theme.of(context).colorScheme.primaryContainer + : Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.home, + size: 20, + color: _currentFolderId == 'root' + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(width: 8), + Text( + 'Home', + style: TextStyle( + color: _currentFolderId == 'root' + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onSurfaceVariant, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + + // Breadcrumb items + ..._currentPath.map((item) { + return Padding( + padding: const EdgeInsets.only(left: 4), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.chevron_right, size: 16), + const SizedBox(width: 4), + InkWell( + onTap: () => _navigateToFolder(item.id), + borderRadius: BorderRadius.circular(8), + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: BoxDecoration( + color: item.id == _currentFolderId + ? Theme.of(context).colorScheme.primaryContainer + : Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + item.name, + style: TextStyle( + color: item.id == _currentFolderId + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onSurfaceVariant, + fontWeight: FontWeight.w500, + ), + ), + ), + ), + ], + ), + ); + }).toList(), + ], + ), + ), + ); + } + + Widget _buildFolderContents() { + return ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: _folderItems.length, + itemBuilder: (context, index) { + final item = _folderItems[index]; + + if (item is TrackFolderItem) { + return TrackFolderTile( + track: item, + onTap: () => _playTrack(item), + onPlay: () => _playTrack(item), + ); + } else { + return FolderTile( + folder: item, + onTap: () => _navigateToFolder(item.id), + onLongPress: () => _showFolderOptions(item), + ); + } + }, + ); + } + + Widget _buildEmptyState() { + return Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.folder_open, + size: 64, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 16), + Text( + 'This folder is empty', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 8), + Text( + 'Add music files to see them here', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } + + String _getFolderTitle() { + if (_currentFolderId == 'root') { + return 'Music Library'; + } else { + final folder = _currentPath.firstWhere( + (item) => item.id == _currentFolderId, + orElse: () => FolderItem(id: '', name: '', type: FolderType.folder), + ); + return folder.name; + } + } + + void _filterItems(String query) { + setState(() { + if (query.isEmpty) { + _loadFolderContents(_currentFolderId); + } else { + // Filter items (in real app, this would call API) + _folderItems = _folderItems.where((item) { + final name = item.name.toLowerCase(); + return name.contains(query.toLowerCase()); + }).toList(); + } + }); + } + + void _navigateToFolder(String folderId) { + setState(() { + _currentFolderId = folderId; + }); + _loadFolderContents(folderId); + } + + void _playTrack(TrackFolderItem track) { + final trackModel = TrackModel( + id: int.parse(track.id), + title: track.name, + album: track.album, + albumhash: track.album.hashCode.toString(), + artists: [], + albumartists: [], + artisthashes: [], + track: 0, + disc: 1, + duration: track.duration, + bitrate: 320, + filepath: track.id, // Use ID as filepath for demo + folder: '', + genres: [], + genrehashes: [], + copyright: '', + date: DateTime.now().millisecondsSinceEpoch ~/ 1000, + lastModified: DateTime.now().millisecondsSinceEpoch ~/ 1000, + trackhash: track.id, + image: '', + weakHash: '', + extra: {}, + lastplayed: 0, + playcount: 0, + playduration: track.duration, + explicit: false, + favUserids: [], + isFavorite: false, + score: 0.0, + ); + + final audioProvider = Provider.of(context, listen: false); + audioProvider.setQueue([trackModel]); + audioProvider.loadTrack(trackModel); + audioProvider.play(); + + Navigator.pushNamed(context, '/player'); + } + + void _handleMenuAction(String action) { + switch (action) { + case 'sort_name': + setState(() { + _folderItems.sort((a, b) => a.name.compareTo(b.name)); + }); + break; + case 'sort_date': + setState(() { + _folderItems.sort((a, b) => b.modifiedDate!.compareTo(a.modifiedDate!)); + }); + break; + case 'sort_size': + setState(() { + _folderItems.sort((a, b) { + final sizeA = a is TrackFolderItem ? a.size : 0; + final sizeB = b is TrackFolderItem ? b.size : 0; + return sizeA.compareTo(sizeB); + }); + }); + break; + // View options would be handled here + } + } + + void _showFolderOptions(FolderItem folder) { + showModalBottomSheet( + context: context, + builder: (context) => Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + leading: const Icon(Icons.play_arrow), + title: const Text('Play All'), + onTap: () { + Navigator.pop(context); + _playAllInFolder(); + }, + ), + ListTile( + leading: const Icon(Icons.shuffle), + title: const Text('Shuffle All'), + onTap: () { + Navigator.pop(context); + _shuffleAllInFolder(); + }, + ), + ListTile( + leading: const Icon(Icons.playlist_add), + title: const Text('Add to Playlist'), + onTap: () { + Navigator.pop(context); + _addToPlaylist(); + }, + ), + const SizedBox(height: 8), + ListTile( + leading: Icon( + Icons.delete, + color: Theme.of(context).colorScheme.error, + ), + title: Text( + 'Delete', + style: TextStyle( + color: Theme.of(context).colorScheme.error, + ), + ), + onTap: () { + Navigator.pop(context); + _deleteFolder(); + }, + ), + ], + ), + ), + ); + } + + void _playAllInFolder() { + // Implementation to play all tracks in folder + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Playing all tracks in folder')), + ); + } + + void _shuffleAllInFolder() { + // Implementation to shuffle all tracks in folder + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Shuffling all tracks in folder')), + ); + } + + void _addToPlaylist() { + // Implementation to add folder contents to playlist + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Added to playlist')), + ); + } + + void _deleteFolder() { + // Implementation to delete folder + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Folder deleted')), + ); + } +} + +// Helper classes +class FolderItem { + final String id; + final String name; + final FolderType type; + final int? itemCount; + final String? path; + final DateTime? modifiedDate; + + FolderItem({ + required this.id, + required this.name, + required this.type, + this.itemCount, + this.path, + this.modifiedDate, + }); +} + +class TrackFolderItem extends FolderItem { + final String artist; + final String album; + final int duration; + final double size; + + TrackFolderItem({ + required String id, + required String name, + required this.artist, + required this.album, + required this.duration, + required this.size, + String? path, + DateTime? modifiedDate, + }) : super( + id: id, + name: name, + type: FolderType.track, + path: path, + modifiedDate: modifiedDate ?? DateTime.now(), + ); +} + +enum FolderType { + folder, + track, +} + +// Custom widgets +class FolderTile extends StatelessWidget { + final FolderItem folder; + final VoidCallback onTap; + final VoidCallback? onLongPress; + + const FolderTile({ + super.key, + required this.folder, + required this.onTap, + this.onLongPress, + }); + + @override + Widget build(BuildContext context) { + return Card( + child: InkWell( + onTap: onTap, + onLongPress: onLongPress, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Row( + children: [ + // Folder/Track Icon + Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: folder.type == FolderType.folder + ? Theme.of(context).colorScheme.primary.withOpacity(0.1) + : Theme.of(context).colorScheme.secondary.withOpacity(0.1), + borderRadius: BorderRadius.circular(8.0), + ), + child: Icon( + folder.type == FolderType.folder ? Icons.folder : Icons.music_note, + color: folder.type == FolderType.folder + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.secondary, + ), + ), + + const SizedBox(width: 16), + + // Folder/Track Info + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + folder.name, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + if (folder.itemCount != null) + Text( + '${folder.itemCount} items', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + if (folder.modifiedDate != null) + Text( + _formatDate(folder.modifiedDate!), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + if (folder is TrackFolderItem) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + (folder as TrackFolderItem).artist, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + Text( + (folder as TrackFolderItem).album, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ], + ), + ), + ], + ), + ), + ), + ); + } +} + +class TrackFolderTile extends StatelessWidget { + final TrackFolderItem track; + final VoidCallback onTap; + final VoidCallback? onPlay; + + const TrackFolderTile({ + super.key, + required this.track, + required this.onTap, + this.onPlay, + }); + + @override + Widget build(BuildContext context) { + return Card( + child: InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Row( + children: [ + // Track Icon + Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.secondary.withOpacity(0.1), + borderRadius: BorderRadius.circular(8), + ), + child: Icon( + Icons.music_note, + color: Theme.of(context).colorScheme.secondary, + ), + ), + + const SizedBox(width: 16), + + // Track Info + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + track.name, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + track.artist, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + Text( + track.album, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 8), + Row( + children: [ + Text( + _formatDuration(track.duration), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(width: 8), + Text( + '${track.size.toStringAsFixed(1)} MB', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ], + ), + ), + + // Play Button + IconButton( + onPressed: onPlay, + icon: const Icon(Icons.play_arrow), + color: Theme.of(context).colorScheme.primary, + ), + ], + ), + ), + ), + ); + } +} + +String _formatDate(DateTime date) { + final now = DateTime.now(); + final difference = now.difference(date); + + if (difference.inDays == 0) { + return 'Today'; + } else if (difference.inDays == 1) { + return 'Yesterday'; + } else if (difference.inDays < 7) { + return '${difference.inDays} days ago'; + } else if (difference.inDays < 30) { + return '${(difference.inDays / 7).floor()} weeks ago'; + } else { + return '${(difference.inDays / 30).floor()} months ago'; + } +} + +String _formatDuration(int seconds) { + final minutes = seconds ~/ 60; + final remainingSeconds = seconds % 60; + return '${minutes}:${remainingSeconds.toString().padLeft(2, '0')}'; +} diff --git a/swingmusic_mobile/lib/features/home/home_screen.dart b/swingmusic_mobile/lib/features/home/home_screen.dart new file mode 100644 index 00000000..b271bdbd --- /dev/null +++ b/swingmusic_mobile/lib/features/home/home_screen.dart @@ -0,0 +1,407 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../shared/providers/library_provider.dart'; +import '../../core/widgets/album_card.dart'; +import '../../core/widgets/track_list_tile.dart'; +import '../../data/models/track_model.dart'; + +class HomeScreen extends StatefulWidget { + const HomeScreen({super.key}); + + @override + State createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + late LibraryProvider _libraryProvider; + late AudioProvider _audioProvider; + bool _isLoading = false; + + @override + void initState() { + super.initState(); + _libraryProvider = Provider.of(context, listen: false); + _audioProvider = Provider.of(context, listen: false); + _loadHomeData(); + } + + Future _loadHomeData() async { + setState(() { + _isLoading = true; + }); + + try { + // Load recent data from library + await Future.wait([ + _libraryProvider.loadTracks(limit: 10), + _libraryProvider.loadAlbums(limit: 5), + _libraryProvider.loadArtists(limit: 5), + ]); + } catch (e) { + // Handle error silently for now + } + + setState(() { + _isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + slivers: [ + // App Bar + SliverAppBar( + floating: true, + snap: true, + backgroundColor: Theme.of(context).colorScheme.surface, + elevation: 0, + title: Text( + 'SwingMusic', + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + actions: [ + IconButton( + onPressed: () { + // Show notifications + }, + icon: const Icon(Icons.notifications_outlined), + ), + PopupMenuButton( + icon: CircleAvatar( + backgroundColor: Theme.of(context).colorScheme.primaryContainer, + child: Icon( + Icons.person, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), + ), + onSelected: (value) { + if (value == 'settings') { + Navigator.pushNamed(context, '/settings'); + } + }, + itemBuilder: (context) => [ + const PopupMenuItem( + value: 'settings', + child: Row( + children: [ + Icon(Icons.settings), + SizedBox(width: 8), + Text('Settings'), + ], + ), + ), + ], + ), + ], + ), + + // Quick Actions Section + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Quick Actions', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + Row( + children: [ + Expanded( + child: _buildQuickActionCard( + icon: Icons.search, + label: 'Search', + color: Theme.of(context).colorScheme.primary, + onTap: () { + Navigator.pushNamed(context, '/search'); + }, + ), + ), + const SizedBox(width: 12), + Expanded( + child: _buildQuickActionCard( + icon: Icons.library_music, + label: 'Library', + color: Theme.of(context).colorScheme.secondary, + onTap: () { + Navigator.pushNamed(context, '/library'); + }, + ), + ), + ], + ), + const SizedBox(height: 12), + Row( + children: [ + Expanded( + child: _buildQuickActionCard( + icon: Icons.favorite, + label: 'Favorites', + color: Colors.red, + onTap: () { + Navigator.pushNamed(context, '/library'); + }, + ), + ), + const SizedBox(width: 12), + Expanded( + child: _buildQuickActionCard( + icon: Icons.download, + label: 'Downloads', + color: Colors.green, + onTap: () { + // Navigate to downloads + }, + ), + ), + ], + ), + ], + ), + ), + ), + + // Recently Played Section + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Recently Played', + style: Theme.of(context).textTheme.titleLarge, + ), + TextButton( + onPressed: () { + Navigator.pushNamed(context, '/library'); + }, + child: const Text('See all'), + ), + ], + ), + const SizedBox(height: 16), + if (_isLoading) + const Center(child: CircularProgressIndicator()) + else if (_libraryProvider.tracks.isEmpty) + _buildEmptySection('No recently played tracks') + else + SizedBox( + height: 200, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: _libraryProvider.tracks.length.clamp(0, 10), + itemBuilder: (context, index) { + final track = _libraryProvider.tracks[index]; + return Container( + width: 160, + margin: const EdgeInsets.only(right: 12), + child: TrackListTile( + track: track, + onTap: () => _playTrack(track), + onPlay: () => _playTrack(track), + showAlbumArt: true, + ), + ); + }, + ), + ), + ], + ), + ), + ), + + // Recent Albums Section + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Recent Albums', + style: Theme.of(context).textTheme.titleLarge, + ), + TextButton( + onPressed: () { + Navigator.pushNamed(context, '/library'); + }, + child: const Text('See all'), + ), + ], + ), + const SizedBox(height: 16), + if (_isLoading) + const Center(child: CircularProgressIndicator()) + else if (_libraryProvider.albums.isEmpty) + _buildEmptySection('No recent albums') + else + GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.8, + crossAxisSpacing: 16, + mainAxisSpacing: 16, + ), + itemCount: _libraryProvider.albums.length.clamp(0, 4), + itemBuilder: (context, index) { + final album = _libraryProvider.albums[index]; + return AlbumCard( + album: album, + onTap: () { + // Navigate to album details + }, + ); + }, + ), + ], + ), + ), + ), + + // Top Artists Section + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Top Artists', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + if (_isLoading) + const Center(child: CircularProgressIndicator()) + else if (_libraryProvider.artists.isEmpty) + _buildEmptySection('No top artists') + else + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: _libraryProvider.artists.length.clamp(0, 5), + itemBuilder: (context, index) { + final artist = _libraryProvider.artists[index]; + return ListTile( + leading: CircleAvatar( + backgroundColor: Theme.of(context).colorScheme.primaryContainer, + child: Text( + artist.name.isNotEmpty ? artist.name[0].toUpperCase() : '?', + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimaryContainer, + fontWeight: FontWeight.bold, + ), + ), + ), + title: Text(artist.name), + trailing: const Icon(Icons.arrow_forward_ios), + onTap: () { + // Navigate to artist details + }, + ); + }, + ), + ], + ), + ), + ), + + // Bottom padding + const SliverToBoxAdapter( + child: SizedBox(height: 100), // Space for mini player + ), + ], + ), + ); + } + + Widget _buildQuickActionCard({ + required IconData icon, + required String label, + required Color color, + required VoidCallback onTap, + }) { + return Card( + child: InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: color.withValues(alpha: 0.1), + borderRadius: BorderRadius.circular(12), + ), + child: Icon( + icon, + color: color, + size: 28, + ), + ), + const SizedBox(height: 12), + Text( + label, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w500, + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + ); + } + + Widget _buildEmptySection(String message) { + return Container( + padding: const EdgeInsets.all(32), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + children: [ + Icon( + Icons.music_note_outlined, + size: 48, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 12), + Text( + message, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ); + } + + void _playTrack(TrackModel track) { + _audioProvider.setQueue([track]); + _audioProvider.loadTrack(track); + _audioProvider.play(); + + Navigator.pushNamed(context, '/player'); + } +} diff --git a/swingmusic_mobile/lib/features/library/library_screen.dart b/swingmusic_mobile/lib/features/library/library_screen.dart new file mode 100644 index 00000000..1e2e7ead --- /dev/null +++ b/swingmusic_mobile/lib/features/library/library_screen.dart @@ -0,0 +1,363 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../shared/providers/library_provider.dart'; +import '../../core/widgets/album_card.dart'; +import '../../core/widgets/track_list_tile.dart'; +import '../../data/models/track_model.dart'; + +class LibraryScreen extends StatefulWidget { + const LibraryScreen({super.key}); + + @override + State createState() => _LibraryScreenState(); +} + +class _LibraryScreenState extends State + with SingleTickerProviderStateMixin { + late TabController _tabController; + late LibraryProvider _libraryProvider; + late AudioProvider _audioProvider; + bool _isLoading = false; + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 6, vsync: this); + _libraryProvider = Provider.of(context, listen: false); + _audioProvider = Provider.of(context, listen: false); + _loadLibraryData(); + } + + Future _loadLibraryData() async { + setState(() { + _isLoading = true; + }); + + try { + await Future.wait([ + _libraryProvider.loadTracks(), + _libraryProvider.loadAlbums(), + _libraryProvider.loadArtists(), + _libraryProvider.loadFavorites(), + ]); + } catch (e) { + // Handle error silently for now + } + + setState(() { + _isLoading = false; + }); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + // Header + Container( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Your Library', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + // Search bar + TextField( + decoration: InputDecoration( + hintText: 'Search your library...', + prefixIcon: const Icon(Icons.search), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerHighest, + ), + ), + ], + ), + ), + + // Tabs + TabBar( + controller: _tabController, + isScrollable: true, + tabs: const [ + Tab(text: 'Recent'), + Tab(text: 'Albums'), + Tab(text: 'Tracks'), + Tab(text: 'Folders'), + Tab(text: 'Favorites'), + Tab(text: 'Playlists'), + ], + ), + + // Tab content + Expanded( + child: TabBarView( + controller: _tabController, + children: [ + _buildRecentTab(), + _buildAlbumsTab(), + _buildTracksTab(), + _buildFoldersTab(), + _buildFavoritesTab(), + _buildPlaylistsTab(), + ], + ), + ), + ], + ), + ); + } + + Widget _buildRecentTab() { + if (_isLoading) { + return const Center(child: CircularProgressIndicator()); + } + + return SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Recently Played', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + if (_libraryProvider.tracks.isEmpty) + _buildEmptyState('No recently played tracks') + else + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: _libraryProvider.tracks.length, + itemBuilder: (context, index) { + final track = _libraryProvider.tracks[index]; + return TrackListTile( + track: track, + onTap: () => _playTrack(track), + onPlay: () => _playTrack(track), + isPlaying: _isCurrentTrack(track), + ); + }, + ), + ], + ), + ); + } + + Widget _buildAlbumsTab() { + if (_isLoading) { + return const Center(child: CircularProgressIndicator()); + } + + return SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Albums', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + if (_libraryProvider.albums.isEmpty) + _buildEmptyState('No albums found') + else + GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.8, + crossAxisSpacing: 16, + mainAxisSpacing: 16, + ), + itemCount: _libraryProvider.albums.length, + itemBuilder: (context, index) { + final album = _libraryProvider.albums[index]; + return AlbumCard( + album: album, + onTap: () { + // Navigate to album details + }, + ); + }, + ), + ], + ), + ); + } + + Widget _buildTracksTab() { + if (_isLoading) { + return const Center(child: CircularProgressIndicator()); + } + + return SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'All Tracks', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + if (_libraryProvider.tracks.isEmpty) + _buildEmptyState('No tracks found') + else + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: _libraryProvider.tracks.length, + itemBuilder: (context, index) { + final track = _libraryProvider.tracks[index]; + return TrackListTile( + track: track, + onTap: () => _playTrack(track), + onPlay: () => _playTrack(track), + isPlaying: _isCurrentTrack(track), + ); + }, + ), + ], + ), + ); + } + + Widget _buildFavoritesTab() { + if (_isLoading) { + return const Center(child: CircularProgressIndicator()); + } + + return SingleChildScrollView( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Favorite Tracks', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + if (_libraryProvider.favoriteTracks.isEmpty) + _buildEmptyState('No favorite tracks yet') + else + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: _libraryProvider.favoriteTracks.length, + itemBuilder: (context, index) { + final track = _libraryProvider.favoriteTracks[index]; + return TrackListTile( + track: track, + onTap: () => _playTrack(track), + onPlay: () => _playTrack(track), + isPlaying: _isCurrentTrack(track), + ); + }, + ), + ], + ), + ); + } + + Widget _buildFoldersTab() { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.folder, + size: 64, + color: Theme.of(context).colorScheme.onSurface, + ), + const SizedBox(height: 16), + Text( + 'Folder navigation coming soon', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.normal, + color: Theme.of(context).colorScheme.onSurface, + ), + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + Widget _buildPlaylistsTab() { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.playlist_play, + size: 64, + color: Theme.of(context).colorScheme.onSurface, + ), + const SizedBox(height: 16), + Text( + 'Playlist management coming soon', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.normal, + color: Theme.of(context).colorScheme.onSurface, + ), + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + Widget _buildEmptyState(String message) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.music_note, + size: 64, + color: Theme.of(context).colorScheme.onSurface, + ), + const SizedBox(height: 16), + Text( + message, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.normal, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + ], + ), + ); + } + + void _playTrack(TrackModel track) { + _audioProvider.setQueue([track]); + _audioProvider.loadTrack(track); + _audioProvider.play(); + + Navigator.pushNamed(context, '/player'); + } + + bool _isCurrentTrack(TrackModel track) { + return _audioProvider.currentTrack?.trackhash == track.trackhash; + } +} diff --git a/swingmusic_mobile/lib/features/lyrics/lyrics_screen.dart b/swingmusic_mobile/lib/features/lyrics/lyrics_screen.dart new file mode 100644 index 00000000..c5739eca --- /dev/null +++ b/swingmusic_mobile/lib/features/lyrics/lyrics_screen.dart @@ -0,0 +1,482 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../data/services/lyrics_service.dart'; +import '../../core/constants/app_spacing.dart'; + +class LyricsScreen extends StatefulWidget { + const LyricsScreen({super.key}); + + @override + State createState() => _LyricsScreenState(); +} + +class _LyricsScreenState extends State { + bool _isLoading = false; + String? _lyrics; + String? _error; + final TextEditingController _lyricsController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.surface, + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.surface, + elevation: 0, + title: Text( + 'Lyrics', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.w600, + ), + ), + leading: IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: Icon( + Icons.close, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + ), + body: Consumer( + builder: (context, audioProvider, child) { + final currentTrack = audioProvider.currentTrack; + + if (currentTrack == null) { + return _buildEmptyState(context); + } + + return Column( + children: [ + // Track Info + Container( + padding: AppSpacing.paddingLG, + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + currentTrack.displayTitle, + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.w600, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 8), + Text( + currentTrack.artistNames, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + if (currentTrack.displayAlbum.isNotEmpty) ...[ + const SizedBox(height: 4), + Text( + currentTrack.displayAlbum, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ], + ), + ), + const SizedBox(width: 16), + // Album Art + Container( + width: 80, + height: 80, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + child: ClipRRect( + borderRadius: BorderRadius.circular(8), + child: currentTrack.image.isNotEmpty + ? Image.network( + currentTrack.image, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.8), + Theme.of(context).colorScheme.primary, + ], + ), + ), + child: Icon( + Icons.music_note, + color: Theme.of(context).colorScheme.onPrimary, + size: 32, + ), + ); + }, + ) + : Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.8), + Theme.of(context).colorScheme.primary, + ], + ), + ), + child: Icon( + Icons.album, + color: Theme.of(context).colorScheme.onPrimary, + size: 32, + ), + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 24), + + // Sync Button + SizedBox( + width: double.infinity, + child: ElevatedButton.icon( + onPressed: () => _loadLyrics(context, currentTrack?.trackhash ?? ''), + icon: Icon( + Icons.sync, + color: Theme.of(context).colorScheme.onPrimary, + ), + label: 'Sync Lyrics', + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Theme.of(context).colorScheme.onPrimary, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), + ), + ), + ), + + const SizedBox(height: 24), + + // Lyrics Content + Expanded( + child: Container( + padding: AppSpacing.paddingLG, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceVariant, + borderRadius: BorderRadius.circular(12), + border: Border.all( + color: Theme.of(context).colorScheme.outline.withOpacity(0.3), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (_isLoading) ...[ + const Center( + child: CircularProgressIndicator(), + ), + ] else if (_error != null) ...[ + Container( + padding: AppSpacing.paddingMD, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.errorContainer, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + children: [ + Icon( + Icons.error_outline, + color: Theme.of(context).colorScheme.error, + size: 20, + ), + const SizedBox(width: 12), + Expanded( + child: Text( + _error!, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.error, + ), + ), + ), + ], + ), + ), + ] else if (_lyrics != null && _lyrics!.isNotEmpty) ...[ + // Edit Mode + if (_isEditMode) ...[ + _buildEditMode(context), + ] else ...[ + // Display Mode + _buildLyricsDisplay(context), + ], + ] else ...[ + Container( + padding: AppSpacing.paddingXL, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.lyrics, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + size: 48, + ), + const SizedBox(height: 16), + Text( + 'No lyrics available', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ], + ], + ), + ), + ), + ], + ); + }, + ), + ); + } + + Widget _buildEmptyState(BuildContext context) { + return Container( + padding: AppSpacing.paddingXL, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.music_note, + size: 64, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + const SizedBox(height: 16), + Text( + 'No lyrics available', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + 'Play a track to see its lyrics', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + Widget _buildLyricsDisplay(BuildContext context) { + return Container( + padding: AppSpacing.paddingMD, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Header with Edit button + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Lyrics', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.w600, + ), + ), + Row( + children: [ + // Edit/Save buttons + if (_isEditMode) ...[ + IconButton( + onPressed: () => _saveLyrics(context), + icon: Icon( + Icons.save, + color: Theme.of(context).colorScheme.primary, + size: 20, + ), + ), + IconButton( + onPressed: () => _cancelEdit(context), + icon: Icon( + Icons.close, + color: Theme.of(context).colorScheme.onSurface, + size: 20, + ), + ), + ] else ...[ + IconButton( + onPressed: () => _enableEditMode(context), + icon: Icon( + Icons.edit, + color: Theme.of(context).colorScheme.primary, + size: 20, + ), + ), + ], + ], + + // Sync button + SizedBox( + width: double.infinity, + child: ElevatedButton.icon( + onPressed: () => _syncLyrics(context), + icon: Icon( + Icons.refresh, + color: Theme.of(context).colorScheme.onPrimary, + ), + label: 'Sync', + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Theme.of(context).colorScheme.onPrimary, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + ), + ), + ), + ], + ), + ), + + // Lyrics text + Expanded( + child: SingleChildScrollView( + child: Text( + _lyrics!, + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + height: 1.6, + color: Theme.of(context).colorScheme.onSurface, + leading: TextStyle( + height: 1.4, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + ), + ), + ), + ), + ], + ), + ); + } + + Widget _buildEditMode(BuildContext context) { + return Container( + padding: AppSpacing.paddingMD, + child: Row( + children: [ + Expanded( + child: TextField( + controller: _lyricsController, + maxLines: null, + style: TextStyle( + height: 1.6, + color: Theme.of(context).colorScheme.onSurface, + ), + decoration: InputDecoration( + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary, + width: 2, + ), + ), + ), + ), + ), + IconButton( + onPressed: () => _saveLyrics(context), + icon: Icon( + Icons.save, + color: Theme.of(context).colorScheme.primary, + ), + ), + ], + ), + ); + } + + bool get _isEditMode => _lyricsController.text != _lyrics; + + void _enableEditMode() { + _lyricsController.text = _lyrics ?? ''; + setState(() {}); + } + + void _cancelEdit() { + _lyricsController.text = _lyrics ?? ''; + setState(() {}); + } + + void _saveLyrics(BuildContext context) { + final updatedLyrics = _lyricsController.text.trim(); + + // TODO: Save lyrics to API + setState(() { + _lyrics = updatedLyrics; + _isEditMode = false; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Lyrics saved successfully'), + backgroundColor: Colors.green, + ), + ); + } + + Future _loadLyrics(BuildContext context, String trackHash) async { + setState(() { + _isLoading = true; + _error = null; + }); + + try { + final lyricsService = LyricsService(); + final lyrics = await lyricsService.getLyrics(trackHash); + + setState(() { + _isLoading = false; + _lyrics = lyrics; + }); + } catch (e) { + setState(() { + _isLoading = false; + _error = 'Failed to load lyrics: $e'; + }); + } + } + + void _syncLyrics(BuildContext context) { + final currentTrack = Provider.of(context, listen: false).currentTrack; + if (currentTrack != null) return; + + _loadLyrics(context, currentTrack.trackhash); + } +} diff --git a/swingmusic_mobile/lib/features/offline/offline_screen.dart b/swingmusic_mobile/lib/features/offline/offline_screen.dart new file mode 100644 index 00000000..a561f080 --- /dev/null +++ b/swingmusic_mobile/lib/features/offline/offline_screen.dart @@ -0,0 +1,374 @@ +import 'package:flutter/material.dart'; + +class OfflineScreen extends StatefulWidget { + const OfflineScreen({super.key}); + + @override + State createState() => _OfflineScreenState(); +} + +class _OfflineScreenState extends State { + bool _isOfflineMode = false; + final List> _downloadedTracks = []; + int _totalDownloads = 0; + int _completedDownloads = 0; + double _totalDownloadSize = 0.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Offline Mode'), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + actions: [ + Switch( + value: _isOfflineMode, + onChanged: (value) { + setState(() { + _isOfflineMode = value; + }); + }, + activeThumbColor: Theme.of(context).colorScheme.primary, + activeTrackColor: Theme.of(context).colorScheme.onPrimary, + ), + ], + ), + body: Column( + children: [ + // Offline Mode Toggle Card + Container( + margin: const EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(12.0), + border: Border.all( + color: Theme.of(context).colorScheme.outline, + width: 1.0, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon( + Icons.cloud_off, + color: _isOfflineMode + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurfaceVariant, + size: 24, + ), + const SizedBox(width: 12), + Text( + 'Offline Mode', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + ], + ), + const SizedBox(height: 8), + Text( + _isOfflineMode + ? 'Download music for offline listening' + : 'Connect to server for online mode', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ), + + const SizedBox(height: 16), + + // Downloads Section + Expanded( + child: Container( + margin: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(12.0), + border: Border.all( + color: Theme.of(context).colorScheme.outline, + width: 1.0, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Downloads Header + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Downloads', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + IconButton( + onPressed: _clearDownloads, + icon: const Icon(Icons.clear_all), + tooltip: 'Clear All', + ), + ], + ), + const SizedBox(height: 16), + + // Download Stats + Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(8.0), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _buildStatCard('Total', _totalDownloads.toString(), Icons.download), + _buildStatCard('Completed', _completedDownloads.toString(), Icons.check_circle), + _buildStatCard('Size', _formatFileSize(_totalDownloadSize), Icons.storage), + ], + ), + ), + const SizedBox(height: 16), + + // Downloaded Tracks List + Expanded( + child: _downloadedTracks.isEmpty + ? _buildEmptyState() + : _buildDownloadsList(), + ), + ], + ), + ), + ), + ], + ), + ); + } + + Widget _buildStatCard(String title, String value, IconData icon) { + return Container( + padding: const EdgeInsets.all(12.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primaryContainer, + borderRadius: BorderRadius.circular(8.0), + ), + child: Column( + children: [ + Icon( + icon, + color: Theme.of(context).colorScheme.onPrimaryContainer, + size: 24, + ), + const SizedBox(height: 8), + Text( + title, + style: Theme.of(context).textTheme.labelMedium?.copyWith( + color: Theme.of(context).colorScheme.onPrimaryContainer, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + Text( + value, + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), + ), + ], + ), + ); + } + + Widget _buildEmptyState() { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.download_outlined, + size: 64, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 16), + Text( + 'No downloads yet', + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 8), + ElevatedButton( + onPressed: _simulateDownload, + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Theme.of(context).colorScheme.onPrimary, + ), + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.download), + const SizedBox(width: 8), + const Text('Download Sample Track'), + ], + ), + ), + ], + ), + ); + } + + Widget _buildDownloadsList() { + return ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: _downloadedTracks.length, + itemBuilder: (context, index) { + final track = _downloadedTracks[index]; + return Card( + margin: const EdgeInsets.only(bottom: 8.0), + child: ListTile( + leading: ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainer, + ), + child: track['isOffline'] == true + ? const Icon(Icons.offline_pin, color: Colors.green) + : const Icon(Icons.music_note, color: Colors.blue), + ), + ), + title: Text( + track['title']?.toString() ?? 'Unknown Track', + style: Theme.of(context).textTheme.titleMedium, + ), + subtitle: Text( + track['artist']?.toString() ?? 'Unknown Artist', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + _formatFileSize(track['size']?.toDouble() ?? 0.0), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(width: 8), + PopupMenuButton( + onSelected: (value) { + _handleTrackAction(track, value); + }, + itemBuilder: (context) => [ + const PopupMenuItem( + value: 'play', + child: Row( + children: [ + const Icon(Icons.play_arrow, size: 16), + const SizedBox(width: 8), + const Text('Play'), + ], + ), + ), + const PopupMenuItem( + value: 'delete', + child: Row( + children: [ + const Icon(Icons.delete, size: 16, color: Colors.red), + const SizedBox(width: 8), + const Text('Delete'), + ], + ), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } + + String _formatFileSize(double bytes) { + if (bytes < 1024) { + return '${bytes.toStringAsFixed(0)} B'; + } else if (bytes < 1024 * 1024) { + return '${(bytes / 1024).toStringAsFixed(1)} KB'; + } else if (bytes < 1024 * 1024 * 1024) { + return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB'; + } else { + return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(1)} GB'; + } + } + + void _clearDownloads() { + setState(() { + _downloadedTracks.clear(); + _totalDownloads = 0; + _completedDownloads = 0; + _totalDownloadSize = 0.0; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('All downloads cleared')), + ); + } + + void _simulateDownload() { + setState(() { + _totalDownloads++; + _completedDownloads++; + final trackSize = 5.2 * 1024 * 1024; // 5.2 MB + _totalDownloadSize += trackSize; + + _downloadedTracks.add({ + 'id': 'track_${_totalDownloads}', + 'title': 'Sample Track $_totalDownloads', + 'artist': 'Sample Artist', + 'album': 'Sample Album', + 'duration': '3:45', + 'size': trackSize, + 'isOffline': true, + 'downloadDate': DateTime.now().toIso8601String(), + }); + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Sample track downloaded')), + ); + } + + void _handleTrackAction(Map track, String action) { + switch (action) { + case 'play': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Playing: ${track['title']}')), + ); + break; + case 'delete': + setState(() { + _downloadedTracks.remove(track); + _totalDownloads--; + if (track['isOffline'] == true) { + _completedDownloads--; + _totalDownloadSize -= (track['size'] ?? 0.0); + } + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Deleted: ${track['title']}')), + ); + break; + } + } +} diff --git a/swingmusic_mobile/lib/features/player/enhanced_player_screen.dart b/swingmusic_mobile/lib/features/player/enhanced_player_screen.dart new file mode 100644 index 00000000..1584ad33 --- /dev/null +++ b/swingmusic_mobile/lib/features/player/enhanced_player_screen.dart @@ -0,0 +1,427 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../core/constants/app_spacing.dart'; +import '../../core/enums/playback_mode.dart'; + +class EnhancedPlayerScreen extends StatefulWidget { + const EnhancedPlayerScreen({super.key}); + + @override + State createState() => _EnhancedPlayerScreenState(); +} + +class _EnhancedPlayerScreenState extends State { + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, audioProvider, child) { + final currentTrack = audioProvider.currentTrack; + + if (currentTrack == null) { + return _buildEmptyPlayer(); + } + + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.surface, + body: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.surface.withOpacity(0.95), + ], + ), + ), + child: SafeArea( + child: Column( + children: [ + // Top Bar + Padding( + padding: AppSpacing.horizontalMD, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: Icon( + Icons.keyboard_arrow_down, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + Text( + 'Now Playing', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + IconButton( + onPressed: () => _showMoreOptions(context), + icon: Icon( + Icons.more_vert, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + ], + ), + ), + + // Album Artwork + Expanded( + flex: 3, + child: Padding( + padding: AppSpacing.horizontalLG, + child: _buildAlbumArtwork(context, currentTrack), + ), + ), + + // Track Info & Controls + Expanded( + flex: 2, + child: Padding( + padding: AppSpacing.horizontalLG, + child: Column( + children: [ + // Track Info + _buildTrackInfo(context, currentTrack), + + const SizedBox(height: 24), + + // Progress Bar + _buildProgressBar(context, audioProvider), + + const SizedBox(height: 24), + + // Playback Controls + _buildPlaybackControls(context, audioProvider), + + const SizedBox(height: 16), + + // Bottom Controls + _buildBottomControls(context, audioProvider), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ); + } + + Widget _buildAlbumArtwork(BuildContext context, dynamic currentTrack) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.3), + blurRadius: 20, + offset: const Offset(0, 8), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: currentTrack.image.isNotEmpty + ? Image.network( + currentTrack.image, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return _buildDefaultAlbumArt(context); + }, + ) + : _buildDefaultAlbumArt(context), + ), + ); + } + + Widget _buildTrackInfo(BuildContext context, dynamic currentTrack) { + return Column( + children: [ + Text( + currentTrack.displayTitle, + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.onSurface, + ), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 8), + Text( + currentTrack.artistNames, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + if (currentTrack.displayAlbum.isNotEmpty) ...[ + const SizedBox(height: 4), + Text( + currentTrack.displayAlbum, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ], + ); + } + + Widget _buildProgressBar(BuildContext context, AudioProvider audioProvider) { + return Column( + children: [ + SliderTheme( + data: SliderTheme.of(context).copyWith( + thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 8), + trackHeight: 4, + activeTrackColor: Theme.of(context).colorScheme.primary, + inactiveTrackColor: Theme.of(context).colorScheme.surfaceVariant, + ), + child: Slider( + value: audioProvider.progress, + onChanged: (value) { + final newPosition = Duration( + milliseconds: (value * audioProvider.duration.inMilliseconds).round(), + ); + audioProvider.seekTo(newPosition); + }, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + audioProvider.positionFormatted, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + ), + Text( + audioProvider.durationFormatted, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + ), + ], + ), + ), + ], + ); + } + + Widget _buildPlaybackControls(BuildContext context, AudioProvider audioProvider) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + // Shuffle + IconButton( + onPressed: () => audioProvider.toggleShuffle(), + icon: Icon( + Icons.shuffle, + color: audioProvider.shuffleMode == ShuffleMode.on + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // Previous + IconButton( + onPressed: () => audioProvider.playPrevious(), + icon: Icon( + Icons.skip_previous, + color: Theme.of(context).colorScheme.onSurface, + ), + iconSize: 40, + ), + + // Play/Pause with buffering indicator + _buildPlayPauseButton(context, audioProvider), + + // Next + IconButton( + onPressed: () => audioProvider.playNext(), + icon: Icon( + Icons.skip_next, + color: Theme.of(context).colorScheme.onSurface, + ), + iconSize: 40, + ), + + // Repeat + IconButton( + onPressed: () => audioProvider.toggleRepeat(), + icon: _getRepeatIcon(audioProvider.repeatMode), + color: audioProvider.repeatMode != RepeatMode.off + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ], + ); + } + + Widget _buildPlayPauseButton(BuildContext context, AudioProvider audioProvider) { + return Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.primary, + ), + child: Stack( + alignment: Alignment.center, + children: [ + IconButton( + onPressed: () { + if (audioProvider.isPlaying) { + audioProvider.pause(); + } else { + audioProvider.play(); + } + }, + icon: Icon( + audioProvider.isPlaying ? Icons.pause : Icons.play_arrow, + color: Theme.of(context).colorScheme.onPrimary, + size: 48, + ), + ), + if (audioProvider.isBuffering) + Container( + width: 60, + height: 60, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.primary.withOpacity(0.8), + ), + child: const CircularProgressIndicator( + strokeWidth: 3, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ), + ], + ), + ); + } + + Widget _buildBottomControls(BuildContext context, AudioProvider audioProvider) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + // Favorite + IconButton( + onPressed: () => _toggleFavorite(context, audioProvider), + icon: Icon( + audioProvider.currentTrack?.isFavorite == true + ? Icons.favorite + : Icons.favorite_border, + color: audioProvider.currentTrack?.isFavorite == true + ? Colors.red + : Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // Queue + IconButton( + onPressed: () => _showQueue(context), + icon: Icon( + Icons.queue_music, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // Volume + IconButton( + onPressed: () => _showVolumeSlider(context, audioProvider), + icon: Icon( + Icons.volume_up, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + +} + +IconData _getRepeatIcon(RepeatMode mode) { +switch (mode) { + case RepeatMode.one: + return Icons.repeat_one; + case RepeatMode.all: + return Icons.repeat; + case RepeatMode.off: + default: + return Icons.repeat; +} +} + +void _toggleFavorite(BuildContext context, AudioProvider audioProvider) { +// Toggle favorite functionality +} + +void _showQueue(BuildContext context) { +// Show queue functionality +} + +void _showVolumeSlider(BuildContext context, AudioProvider audioProvider) { + showModalBottomSheet( + context: context, + builder: (context) => Container( + padding: AppSpacing.paddingLG, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Volume', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 16), + Slider( + value: audioProvider.volume, + onChanged: (value) => audioProvider.setVolume(value), + min: 0.0, + max: 1.0, + ), + ], + ), + ), + ); +} + +void _showMoreOptions(BuildContext context) { +showModalBottomSheet( + context: context, + builder: (context) => Container( + padding: AppSpacing.large, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + leading: const Icon(Icons.share), + title: const Text('Share'), + onTap: () => Navigator.pop(context), + ), + ListTile( + leading: const Icon(Icons.playlist_add), + title: const Text('Add to Playlist'), + onTap: () => Navigator.pop(context), + ), + ListTile( + leading: const Icon(Icons.info_outline), + title: const Text('Track Info'), + onTap: () => Navigator.pop(context), + ), + ], + ), + ), +); +} diff --git a/swingmusic_mobile/lib/features/player/enhanced_player_screen_new.dart b/swingmusic_mobile/lib/features/player/enhanced_player_screen_new.dart new file mode 100644 index 00000000..e1258c08 --- /dev/null +++ b/swingmusic_mobile/lib/features/player/enhanced_player_screen_new.dart @@ -0,0 +1,489 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../core/constants/app_spacing.dart'; +import '../../core/enums/playback_mode.dart'; + +class EnhancedPlayerScreen extends StatefulWidget { + const EnhancedPlayerScreen({super.key}); + + @override + State createState() => _EnhancedPlayerScreenState(); +} + +class _EnhancedPlayerScreenState extends State { + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, audioProvider, child) { + final currentTrack = audioProvider.currentTrack; + + if (currentTrack == null) { + return _buildEmptyPlayer(); + } + + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.surface, + body: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.surface.withOpacity(0.95), + ], + ), + ), + child: SafeArea( + child: Column( + children: [ + // Top Bar + Padding( + padding: AppSpacing.horizontalMD, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: Icon( + Icons.keyboard_arrow_down, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + Text( + 'Now Playing', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + IconButton( + onPressed: () => _showMoreOptions(context), + icon: Icon( + Icons.more_vert, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + ], + ), + ), + + // Album Artwork + Expanded( + flex: 3, + child: Padding( + padding: AppSpacing.horizontalLG, + child: _buildAlbumArtwork(context, currentTrack), + ), + ), + + // Track Info & Controls + Expanded( + flex: 2, + child: Padding( + padding: AppSpacing.horizontalLG, + child: Column( + children: [ + // Track Info + _buildTrackInfo(context, currentTrack), + + const SizedBox(height: 24), + + // Progress Bar + _buildProgressBar(context, audioProvider), + + const SizedBox(height: 24), + + // Playback Controls + _buildPlaybackControls(context, audioProvider), + + const SizedBox(height: 16), + + // Bottom Controls + _buildBottomControls(context, audioProvider), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ); + } + + Widget _buildAlbumArtwork(BuildContext context, dynamic currentTrack) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.3), + blurRadius: 20, + offset: const Offset(0, 8), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: currentTrack.image.isNotEmpty + ? Image.network( + currentTrack.image, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return _buildDefaultAlbumArt(context); + }, + ) + : _buildDefaultAlbumArt(context), + ), + ); + } + + Widget _buildTrackInfo(BuildContext context, dynamic currentTrack) { + return Column( + children: [ + Text( + currentTrack.displayTitle, + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.onSurface, + ), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 8), + Text( + currentTrack.artistNames, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + if (currentTrack.displayAlbum.isNotEmpty) ...[ + const SizedBox(height: 4), + Text( + currentTrack.displayAlbum, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ], + ); + } + + Widget _buildProgressBar(BuildContext context, AudioProvider audioProvider) { + return Column( + children: [ + SliderTheme( + data: SliderTheme.of(context).copyWith( + thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 8), + trackHeight: 4, + activeTrackColor: Theme.of(context).colorScheme.primary, + inactiveTrackColor: Theme.of(context).colorScheme.surfaceVariant, + ), + child: Slider( + value: audioProvider.progress, + onChanged: (value) { + final newPosition = Duration( + milliseconds: (value * audioProvider.duration.inMilliseconds).round(), + ); + audioProvider.seekTo(newPosition); + }, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + audioProvider.positionFormatted, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + ), + Text( + audioProvider.durationFormatted, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + ), + ], + ), + ), + ], + ); + } + + Widget _buildPlaybackControls(BuildContext context, AudioProvider audioProvider) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + // Shuffle + IconButton( + onPressed: () => audioProvider.toggleShuffle(), + icon: Icon( + Icons.shuffle, + color: audioProvider.shuffleMode == ShuffleMode.on + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // Previous + IconButton( + onPressed: () => audioProvider.playPrevious(), + icon: Icon( + Icons.skip_previous, + color: Theme.of(context).colorScheme.onSurface, + ), + iconSize: 40, + ), + + // Play/Pause with buffering indicator + _buildPlayPauseButton(context, audioProvider), + + // Next + IconButton( + onPressed: () => audioProvider.playNext(), + icon: Icon( + Icons.skip_next, + color: Theme.of(context).colorScheme.onSurface, + ), + iconSize: 40, + ), + + // Repeat + IconButton( + onPressed: () => audioProvider.toggleRepeat(), + icon: _getRepeatIcon(audioProvider.repeatMode), + color: audioProvider.repeatMode != RepeatMode.off + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ], + ); + } + + Widget _buildPlayPauseButton(BuildContext context, AudioProvider audioProvider) { + return Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.primary, + ), + child: Stack( + alignment: Alignment.center, + children: [ + IconButton( + onPressed: () { + if (audioProvider.isPlaying) { + audioProvider.pause(); + } else { + audioProvider.play(); + } + }, + icon: Icon( + audioProvider.isPlaying ? Icons.pause : Icons.play_arrow, + color: Theme.of(context).colorScheme.onPrimary, + size: 48, + ), + ), + if (audioProvider.isBuffering) + Container( + width: 60, + height: 60, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.primary.withOpacity(0.8), + ), + child: const CircularProgressIndicator( + strokeWidth: 3, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ), + ], + ), + ); + } + + Widget _buildBottomControls(BuildContext context, AudioProvider audioProvider) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + // Favorite + IconButton( + onPressed: () => _toggleFavorite(context, audioProvider), + icon: Icon( + audioProvider.currentTrack?.isFavorite == true + ? Icons.favorite + : Icons.favorite_border, + color: audioProvider.currentTrack?.isFavorite == true + ? Colors.red + : Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // Queue + IconButton( + onPressed: () => _showQueue(context), + icon: Icon( + Icons.queue_music, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // Volume + IconButton( + onPressed: () => _showVolumeSlider(context, audioProvider), + icon: Icon( + Icons.volume_up, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + + // More options + IconButton( + onPressed: () => _showMoreOptions(context), + icon: Icon( + Icons.more_horiz, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + ), + ], + ); + } + + Widget _buildDefaultAlbumArt(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.7), + Theme.of(context).colorScheme.secondary.withOpacity(0.7), + ], + ), + ), + child: Icon( + Icons.album, + size: 120, + color: Theme.of(context).colorScheme.onPrimary, + ), + ); + } + + Widget _buildEmptyPlayer() { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.music_note, + size: 64, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + ), + const SizedBox(height: 16), + Text( + 'No track playing', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurface, + ), + ), + const SizedBox(height: 8), + Text( + 'Select a track from your library to start playing', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } + + IconData _getRepeatIcon(RepeatMode mode) { + switch (mode) { + case RepeatMode.one: + return Icons.repeat_one; + case RepeatMode.all: + return Icons.repeat; + case RepeatMode.off: + return Icons.repeat; + } + } + + void _toggleFavorite(BuildContext context, AudioProvider audioProvider) { + // Toggle favorite functionality + } + + void _showQueue(BuildContext context) { + // Show queue functionality + } + + void _showVolumeSlider(BuildContext context, AudioProvider audioProvider) { + showModalBottomSheet( + context: context, + builder: (context) => Container( + padding: AppSpacing.paddingLG, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Volume', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 16), + Slider( + value: audioProvider.volume, + onChanged: (value) => audioProvider.setVolume(value), + min: 0.0, + max: 1.0, + ), + ], + ), + ), + ); + } + + void _showMoreOptions(BuildContext context) { + showModalBottomSheet( + context: context, + builder: (context) => Container( + padding: AppSpacing.paddingLG, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + leading: const Icon(Icons.share), + title: const Text('Share'), + onTap: () => Navigator.pop(context), + ), + ListTile( + leading: const Icon(Icons.playlist_add), + title: const Text('Add to Playlist'), + onTap: () => Navigator.pop(context), + ), + ListTile( + leading: const Icon(Icons.info_outline), + title: const Text('Track Info'), + onTap: () => Navigator.pop(context), + ), + ], + ), + ), + ); + } +} diff --git a/swingmusic_mobile/lib/features/player/player_screen.dart b/swingmusic_mobile/lib/features/player/player_screen.dart new file mode 100644 index 00000000..66be1681 --- /dev/null +++ b/swingmusic_mobile/lib/features/player/player_screen.dart @@ -0,0 +1,373 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../core/constants/app_spacing.dart'; + +class PlayerScreen extends StatefulWidget { + const PlayerScreen({super.key}); + + @override + State createState() => _PlayerScreenState(); +} + +class _PlayerScreenState extends State { + @override + void initState() { + super.initState(); + // Initialize audio service if not already done + WidgetsBinding.instance.addPostFrameCallback((_) { + Provider.of(context, listen: false).initialize(); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Consumer( + builder: (context, audioProvider, child) { + final currentTrack = audioProvider.currentTrack; + + if (currentTrack == null) { + return _buildEmptyPlayer(); + } + + return Column( + children: [ + // App Bar + SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: const Icon(Icons.keyboard_arrow_down), + ), + Text( + 'Now Playing', + style: Theme.of(context).textTheme.titleMedium, + ), + IconButton( + onPressed: () { + // Show more options + }, + icon: const Icon(Icons.more_vert), + ), + ], + ), + ), + ), + + // Album Art + Expanded( + flex: 3, + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.3), + blurRadius: 20, + offset: const Offset(0, 8), + ), + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.7), + Theme.of(context).colorScheme.secondary.withOpacity(0.7), + ], + ), + ), + child: currentTrack.image.isNotEmpty + ? Image.network( + currentTrack.image, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return _buildDefaultAlbumArt(context); + }, + ) + : _buildDefaultAlbumArt(context), + ), + ), + ), + ), + ), + + // Track Info + Expanded( + flex: 1, + child: Padding( + padding: AppSpacing.horizontalXL, + child: Column( + children: [ + Text( + currentTrack.displayTitle, + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 8), + Text( + currentTrack.artistNames, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + if (currentTrack.displayAlbum.isNotEmpty) ...[ + const SizedBox(height: 4), + Text( + currentTrack.displayAlbum, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ], + ), + ), + ), + + // Progress Bar + Padding( + padding: AppSpacing.horizontalXL, + child: Column( + children: [ + SliderTheme( + data: SliderTheme.of(context).copyWith( + thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 8), + trackHeight: 4, + ), + child: Slider( + value: audioProvider.progress, + onChanged: (value) { + final newPosition = Duration( + milliseconds: (value * audioProvider.duration.inMilliseconds).round(), + ); + audioProvider.seekTo(newPosition); + }, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + audioProvider.positionFormatted, + style: Theme.of(context).textTheme.bodySmall, + ), + Text( + audioProvider.durationFormatted, + style: Theme.of(context).textTheme.bodySmall, + ), + // Volume Control + Expanded( + child: Row( + children: [ + Icon( + Icons.volume_up, + color: Theme.of(context).colorScheme.onSurfaceVariant, + size: 20, + ), + Expanded( + child: Slider( + value: audioProvider.volume, + onChanged: (value) { + audioProvider.setVolume(value); + }, + min: 0.0, + max: 1.0, + ), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ), + + // Playback Controls + Expanded( + flex: 1, + child: Padding( + padding: AppSpacing.horizontalXL, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + // Shuffle + IconButton( + onPressed: () => audioProvider.toggleShuffle(), + icon: Icon( + Icons.shuffle, + color: audioProvider.isShuffleMode + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + + // Previous + IconButton( + onPressed: () => audioProvider.playPrevious(), + icon: const Icon(Icons.skip_previous), + iconSize: 32, + ), + + // Play/Pause + Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context).colorScheme.primary, + ), + child: IconButton( + onPressed: () { + if (audioProvider.isPlaying) { + audioProvider.pause(); + } else { + audioProvider.play(); + } + }, + icon: audioProvider.isLoading + ? const SizedBox( + width: 24, + height: 24, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ) + : Icon( + audioProvider.isPlaying ? Icons.pause : Icons.play_arrow, + color: Theme.of(context).colorScheme.onPrimary, + size: 32, + ), + ), + ), + + // Next + IconButton( + onPressed: () => audioProvider.playNext(), + icon: const Icon(Icons.skip_next), + iconSize: 32, + ), + + // Repeat + IconButton( + onPressed: () => audioProvider.toggleRepeat(), + icon: Icon( + audioProvider.isRepeatMode ? Icons.repeat_one : Icons.repeat, + color: audioProvider.isRepeatMode + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ), + ), + + // Bottom Controls + Padding( + padding: const EdgeInsets.only(bottom: 32.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + onPressed: () { + // Add to favorites + }, + icon: const Icon(Icons.favorite_border), + ), + IconButton( + onPressed: () { + // Show playlist + }, + icon: const Icon(Icons.playlist_play), + ), + IconButton( + onPressed: () { + // Share + }, + icon: const Icon(Icons.share), + ), + ], + ), + ), + ], + ); + }, + ), + ); + } + + Widget _buildEmptyPlayer() { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.music_note, + size: 64, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 16), + Text( + 'No track playing', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 8), + Text( + 'Select a track from your library to start playing', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + ), + ], + ), + ); + } + + Widget _buildDefaultAlbumArt(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withOpacity(0.7), + Theme.of(context).colorScheme.secondary.withOpacity(0.7), + ], + ), + ), + child: Icon( + Icons.album, + size: 120, + color: Theme.of(context).colorScheme.onPrimary, + ), + ); + } +} diff --git a/swingmusic_mobile/lib/features/playlists/playlists_screen.dart b/swingmusic_mobile/lib/features/playlists/playlists_screen.dart new file mode 100644 index 00000000..6d08c8df --- /dev/null +++ b/swingmusic_mobile/lib/features/playlists/playlists_screen.dart @@ -0,0 +1,437 @@ +import 'package:flutter/material.dart'; +import '../../data/models/playlist_model.dart'; + +class PlaylistsScreen extends StatefulWidget { + const PlaylistsScreen({super.key}); + + @override + State createState() => _PlaylistsScreenState(); +} + +class _PlaylistsScreenState extends State { + List _playlists = []; + bool _isLoading = false; + final TextEditingController _playlistNameController = TextEditingController(); + final TextEditingController _searchController = TextEditingController(); + + @override + void initState() { + super.initState(); + _loadPlaylists(); + } + + @override + void dispose() { + _playlistNameController.dispose(); + _searchController.dispose(); + super.dispose(); + } + + Future _loadPlaylists() async { + setState(() { + _isLoading = true; + }); + + // Simulate API call + await Future.delayed(const Duration(seconds: 1)); + + setState(() { + _isLoading = false; + // Sample playlists for demo + _playlists = [ + PlaylistModel( + id: '1', + name: 'My Favorites', + description: 'My favorite tracks', + trackcount: 25, + isPublic: false, + createdDate: DateTime.now().subtract(const Duration(days: 30)), + lastModified: DateTime.now().subtract(const Duration(days: 5)), + ), + PlaylistModel( + id: '2', + name: 'Workout Mix', + description: 'High energy tracks for workouts', + trackcount: 18, + isPublic: false, + createdDate: DateTime.now().subtract(const Duration(days: 15)), + lastModified: DateTime.now().subtract(const Duration(days: 2)), + ), + PlaylistModel( + id: '3', + name: 'Chill Vibes', + description: 'Relaxing and focus music', + trackcount: 32, + isPublic: true, + createdDate: DateTime.now().subtract(const Duration(days: 7)), + lastModified: DateTime.now().subtract(const Duration(days: 1)), + ), + PlaylistModel( + id: '4', + name: 'Road Trip Classics', + description: 'Classic hits for long drives', + trackcount: 45, + isPublic: false, + createdDate: DateTime.now().subtract(const Duration(days: 90)), + lastModified: DateTime.now().subtract(const Duration(days: 10)), + ), + ]; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Playlists'), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + actions: [ + IconButton( + onPressed: _showCreatePlaylistDialog, + icon: const Icon(Icons.add), + ), + ], + ), + body: Column( + children: [ + // Search Bar + Padding( + padding: const EdgeInsets.all(16.0), + child: TextField( + controller: _searchController, + decoration: InputDecoration( + hintText: 'Search playlists...', + prefixIcon: const Icon(Icons.search), + suffixIcon: _searchController.text.isNotEmpty + ? IconButton( + onPressed: () { + _searchController.clear(); + _filterPlaylists(''); + }, + icon: const Icon(Icons.clear), + ) + : null, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerHighest, + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + ), + onChanged: (value) { + _filterPlaylists(value); + }, + ), + ), + + // Playlists Grid + Expanded( + child: _isLoading + ? const Center(child: CircularProgressIndicator()) + : _playlists.isEmpty + ? _buildEmptyState() + : _buildPlaylistsGrid(), + ), + ], + ), + floatingActionButton: FloatingActionButton( + onPressed: _showCreatePlaylistDialog, + child: const Icon(Icons.add), + ), + ); + } + + Widget _buildPlaylistsGrid() { + return GridView.builder( + padding: const EdgeInsets.all(16.0), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.8, + crossAxisSpacing: 16, + mainAxisSpacing: 16, + ), + itemCount: _playlists.length, + itemBuilder: (context, index) { + final playlist = _playlists[index]; + return Card( + child: InkWell( + onTap: () => _openPlaylist(playlist), + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Playlist Cover + Container( + width: double.infinity, + height: 120, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Theme.of(context).colorScheme.primary.withValues(alpha: 0.8), + Theme.of(context).colorScheme.secondary.withValues(alpha: 0.8), + ], + ), + borderRadius: BorderRadius.circular(8), + ), + child: Stack( + children: [ + // Playlist Icon + Positioned( + top: 8, + right: 8, + child: Container( + padding: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: Colors.black.withValues(alpha: 0.7), + borderRadius: BorderRadius.circular(4), + ), + child: Icon( + Icons.playlist_play, + color: Colors.white, + size: 20, + ), + ), + ), + // Public/Private Badge + if (playlist.isPublic) + Positioned( + bottom: 8, + left: 8, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2), + decoration: BoxDecoration( + color: Colors.green, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + 'PUBLIC', + style: const TextStyle( + color: Colors.white, + fontSize: 8, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 12), + + // Playlist Info + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + playlist.name, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + playlist.description, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 8), + Row( + children: [ + Icon( + Icons.music_note, + size: 16, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(width: 4), + Text( + '${playlist.trackcount} tracks', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + const SizedBox(height: 4), + Text( + _formatDate(playlist.lastModified), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ); + } + + Widget _buildEmptyState() { + return Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.playlist_add, + size: 64, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 16), + Text( + 'No playlists yet', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 8), + Text( + 'Create your first playlist to get started', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 16), + ElevatedButton.icon( + onPressed: _showCreatePlaylistDialog, + icon: const Icon(Icons.add), + label: const Text('Create Playlist'), + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), + ), + ), + ], + ), + ), + ); + } + + void _filterPlaylists(String query) { + setState(() { + if (query.isEmpty) { + // Reset to all playlists + _loadPlaylists(); + } else { + // Filter playlists (in real app, this would call API) + _playlists = _playlists.where((playlist) => + playlist.name.toLowerCase().contains(query.toLowerCase()) + ).toList(); + } + }); + } + + void _openPlaylist(PlaylistModel playlist) { + Navigator.pushNamed(context, '/playlist', arguments: playlist); + } + + void _showCreatePlaylistDialog() { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Create Playlist'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: _playlistNameController, + decoration: const InputDecoration( + labelText: 'Playlist Name', + border: OutlineInputBorder(), + ), + autofocus: true, + ), + const SizedBox(height: 16), + TextField( + decoration: const InputDecoration( + labelText: 'Description (Optional)', + border: OutlineInputBorder(), + ), + maxLines: 3, + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + ElevatedButton( + onPressed: _createPlaylist, + child: const Text('Create'), + ), + ], + ), + ); + } + + void _createPlaylist() async { + final name = _playlistNameController.text.trim(); + if (name.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Please enter a playlist name')), + ); + return; + } + + // Create playlist (in real app, this would call API) + final newPlaylist = PlaylistModel( + id: DateTime.now().millisecondsSinceEpoch.toString(), + name: name, + description: '', + trackcount: 0, + isPublic: false, + createdDate: DateTime.now(), + lastModified: DateTime.now(), + ); + + setState(() { + _playlists.insert(0, newPlaylist); + }); + + _playlistNameController.clear(); + Navigator.pop(context); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Playlist "$name" created successfully')), + ); + } + + String _formatDate(DateTime date) { + final now = DateTime.now(); + final difference = now.difference(date); + + if (difference.inDays == 0) { + return 'Today'; + } else if (difference.inDays == 1) { + return 'Yesterday'; + } else if (difference.inDays < 7) { + return '${difference.inDays} days ago'; + } else if (difference.inDays < 30) { + return '${(difference.inDays / 7).floor()} weeks ago'; + } else { + return '${(difference.inDays / 30).floor()} months ago'; + } + } +} \ No newline at end of file diff --git a/swingmusic_mobile/lib/features/qr/qr_screen.dart b/swingmusic_mobile/lib/features/qr/qr_screen.dart new file mode 100644 index 00000000..241e4324 --- /dev/null +++ b/swingmusic_mobile/lib/features/qr/qr_screen.dart @@ -0,0 +1,292 @@ +import 'package:flutter/material.dart'; + +class QRScreen extends StatefulWidget { + const QRScreen({super.key}); + + @override + State createState() => _QRScreenState(); +} + +class _QRScreenState extends State { + String _qrCode = ''; + bool _isGenerating = false; + bool _isScanning = false; + final TextEditingController _qrController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('QR Code Pairing'), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + leading: IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: const Icon(Icons.arrow_back), + ), + ), + body: Padding( + padding: const EdgeInsets.all(24.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // QR Code Display + Container( + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(16.0), + border: Border.all( + color: Theme.of(context).colorScheme.outline, + width: 2.0, + ), + ), + child: Column( + children: [ + const Icon( + Icons.qr_code_scanner, + size: 80, + color: Colors.blue, + ), + const SizedBox(height: 16), + Text( + 'QR Code Pairing', + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + Text( + 'Scan or generate a QR code to connect', + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 24), + + // QR Code Visual + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12.0), + border: Border.all( + color: Theme.of(context).colorScheme.outline, + width: 2.0, + ), + ), + child: _isGenerating + ? const Center( + child: CircularProgressIndicator(), + ) + : Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 180, + height: 180, + color: Colors.black, + child: const Center( + child: Text( + 'QR CODE', + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + const SizedBox(height: 16), + Text( + _qrCode.isEmpty ? 'Generate QR Code' : _qrCode, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + const SizedBox(height: 24), + + // Action Buttons + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: ElevatedButton( + onPressed: _isScanning ? null : _toggleScanning, + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Theme.of(context).colorScheme.onPrimary, + ), + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.qr_code_scanner), + const SizedBox(width: 8), + const Text('Scan QR Code'), + ], + ), + ), + ), + const SizedBox(width: 16), + Expanded( + child: ElevatedButton( + onPressed: _isScanning ? null : _generateQRCode, + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.secondary, + foregroundColor: Theme.of(context).colorScheme.onSecondary, + ), + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.qr_code), + const SizedBox(width: 8), + const Text('Generate QR'), + ], + ), + ), + ), + ], + ), + const SizedBox(height: 16), + + // Manual Entry + TextField( + controller: _qrController, + decoration: InputDecoration( + labelText: 'Or enter QR code manually', + hintText: 'Enter QR code', + prefixIcon: const Icon(Icons.keyboard), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12.0), + borderSide: BorderSide.none, + ), + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerHighest, + ), + onChanged: (value) { + setState(() { + _qrCode = value; + }); + }, + ), + const SizedBox(height: 24), + + // Connect Button + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _qrCode.isEmpty ? null : _connectWithQR, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(vertical: 16), + ), + child: const Text('Connect'), + ), + ), + ], + ), + ), + ], + ), + ), + ); + } + + void _toggleScanning() { + setState(() { + _isScanning = !_isScanning; + }); + + if (_isScanning) { + _scanQRCode(); + } + } + + void _generateQRCode() { + setState(() { + _isGenerating = true; + }); + + // Generate a random QR code for demo + Future.delayed(const Duration(seconds: 2)).then((_) { + setState(() { + _isGenerating = false; + _qrCode = 'SWING-${DateTime.now().millisecondsSinceEpoch % 10000}'; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('QR Code generated!')), + ); + }); + } + + void _scanQRCode() async { + try { + // In a real app, this would use camera plugin + // For demo, we'll simulate scanning + await Future.delayed(const Duration(seconds: 3)); + + setState(() { + _isScanning = false; + _qrCode = 'DEMO-SCANNED-${DateTime.now().millisecondsSinceEpoch}'; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('QR Code scanned!')), + ); + } catch (e) { + setState(() { + _isScanning = false; + }); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Scan failed: ${e.toString()}')), + ); + } + } + + void _connectWithQR() async { + if (_qrCode.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Please enter or scan a QR code')), + ); + return; + } + + setState(() { + _isGenerating = true; + }); + + try { + // Simulate connection with QR code + await Future.delayed(const Duration(seconds: 2)); + + setState(() { + _isGenerating = false; + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Connected with QR Code!')), + ); + + // Navigate to main app + Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); + } catch (e) { + setState(() { + _isGenerating = false; + }); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Connection failed: ${e.toString()}')), + ); + } + } +} diff --git a/swingmusic_mobile/lib/features/search/search_screen.dart b/swingmusic_mobile/lib/features/search/search_screen.dart new file mode 100644 index 00000000..8f848e72 --- /dev/null +++ b/swingmusic_mobile/lib/features/search/search_screen.dart @@ -0,0 +1,523 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/audio_provider.dart'; +import '../../core/widgets/album_card.dart'; +import '../../core/widgets/track_list_tile.dart'; +import '../../data/models/track_model.dart'; +import '../../data/models/album_model.dart'; +import '../../data/models/artist_model.dart' as artist_model; +import '../../data/models/search_suggestion_model.dart'; + +class SearchScreen extends StatefulWidget { + const SearchScreen({super.key}); + + @override + State createState() => _SearchScreenState(); +} + +class _SearchScreenState extends State with TickerProviderStateMixin { + late TabController _tabController; + final TextEditingController _searchController = TextEditingController(); + final FocusNode _searchFocusNode = FocusNode(); + + // Search results + final List _trackResults = []; + final List _albumResults = []; + final List _artistResults = []; + + bool _isSearching = false; + String _currentQuery = ''; + + // Search filters + String _selectedFilter = 'all'; // 'all', 'tracks', 'albums', 'artists' + final List _searchFilters = ['all', 'tracks', 'albums', 'artists']; + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 4, vsync: this); + _searchFocusNode.requestFocus(); + } + + @override + void dispose() { + _tabController.dispose(); + _searchController.dispose(); + _searchFocusNode.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + // Search Header + Container( + padding: const EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.1), + blurRadius: 4, + offset: const Offset(0, 2), + ), + ], + ), + child: Column( + children: [ + // Search Bar + TextField( + controller: _searchController, + focusNode: _searchFocusNode, + onChanged: _onSearchChanged, + onSubmitted: _onSearchSubmitted, + decoration: InputDecoration( + hintText: 'Search tracks, albums, artists...', + prefixIcon: const Icon(Icons.search), + suffixIcon: _searchController.text.isNotEmpty + ? IconButton( + onPressed: _clearSearch, + icon: const Icon(Icons.clear), + ) + : null, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerHighest, + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + ), + ), + + const SizedBox(height: 12), + + // Filter Chips + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: _searchFilters.map((filter) { + final isSelected = _selectedFilter == filter; + return Padding( + padding: const EdgeInsets.only(right: 8), + child: FilterChip( + label: Text(filter.toUpperCase()), + selected: isSelected, + onSelected: (selected) { + setState(() { + _selectedFilter = filter; + }); + _performSearch(_currentQuery); + }, + backgroundColor: isSelected + ? Theme.of(context).colorScheme.primaryContainer + : Theme.of(context).colorScheme.surfaceContainerHighest, + labelStyle: TextStyle( + color: isSelected + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ); + }).toList(), + ), + ), + ], + ), + ), + + // Search Results + Expanded( + child: _isSearching + ? const Center(child: CircularProgressIndicator()) + : _currentQuery.isEmpty + ? _buildSearchSuggestions() + : _buildSearchResults(), + ), + ], + ), + ); + } + + Widget _buildSearchSuggestions() { + return DefaultTabController( + length: 4, + child: Column( + children: [ + TabBar( + controller: _tabController, + isScrollable: true, + tabs: const [ + Tab(text: 'Top'), + Tab(text: 'Tracks'), + Tab(text: 'Albums'), + Tab(text: 'Artists'), + ], + ), + Expanded( + child: TabBarView( + controller: _tabController, + children: [ + _buildTopSearches(), + _buildRecentSearches(), + _buildBrowseGenres(), + _buildBrowseFolders(), + ], + ), + ), + ], + ), + ); + } + + Widget _buildTopSearches() { + return Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Top Searches', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + // Sample top searches + ...['Rock', 'Pop', 'Jazz', 'Electronic', 'Classical'].map((genre) { + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: ListTile( + leading: Icon( + Icons.trending_up, + color: Theme.of(context).colorScheme.primary, + ), + title: Text(genre), + trailing: const Icon(Icons.arrow_forward_ios), + onTap: () { + _searchController.text = genre; + _performSearch(genre); + }, + ), + ); + }), + ], + ), + ); + } + + Widget _buildRecentSearches() { + return Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Recent Searches', + style: Theme.of(context).textTheme.titleLarge, + ), + const SizedBox(height: 16), + // Sample recent searches + ...['Beatles', 'Queen', 'Pink Floyd', 'Led Zeppelin'].map((search) { + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: ListTile( + leading: Icon( + Icons.history, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + title: Text(search), + trailing: IconButton( + onPressed: () { + _searchController.text = search; + _performSearch(search); + }, + icon: const Icon(Icons.arrow_forward_ios), + ), + onTap: () { + _searchController.text = search; + _performSearch(search); + }, + ), + ); + }), + ], + ), + ); + } + + Widget _buildBrowseGenres() { + return Padding( + padding: const EdgeInsets.all(16.0), + child: GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 2.5, + crossAxisSpacing: 12, + mainAxisSpacing: 12, + ), + itemCount: ['Rock', 'Pop', 'Jazz', 'Electronic', 'Classical', 'Hip Hop', 'Country', 'R&B'].length, + itemBuilder: (context, index) { + final genre = ['Rock', 'Pop', 'Jazz', 'Electronic', 'Classical', 'Hip Hop', 'Country', 'R&B'][index]; + return Card( + child: InkWell( + onTap: () { + _searchController.text = genre; + _performSearch(genre); + }, + borderRadius: BorderRadius.circular(8), + child: Center( + child: Text( + genre, + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + fontWeight: FontWeight.w500, + ), + ), + ), + ), + ); + }, + ), + ); + } + + Widget _buildBrowseFolders() { + return Padding( + padding: const EdgeInsets.all(16.0), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.folder_outlined, + size: 64, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 16), + Text( + 'Folder browsing coming soon', + style: TextStyle( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ), + ); + } + + Widget _buildSearchResults() { + if (_selectedFilter == 'all') { + return DefaultTabController( + length: 3, + child: Column( + children: [ + TabBar( + tabs: const [ + Tab(text: 'Tracks'), + Tab(text: 'Albums'), + Tab(text: 'Artists'), + ], + ), + Expanded( + child: TabBarView( + children: [ + _buildTrackResults(), + _buildAlbumResults(), + _buildArtistResults(), + ], + ), + ), + ], + ), + ); + } else if (_selectedFilter == 'tracks') { + return _buildTrackResults(); + } else if (_selectedFilter == 'albums') { + return _buildAlbumResults(); + } else { + return _buildArtistResults(); + } + } + + Widget _buildTrackResults() { + if (_trackResults.isEmpty) { + return _buildEmptyResults('No tracks found'); + } + + return ListView.builder( + itemCount: _trackResults.length, + itemBuilder: (context, index) { + final track = _trackResults[index]; + return TrackListTile( + track: track, + onTap: () => _playTrack(track), + onPlay: () => _playTrack(track), + ); + }, + ); + } + + Widget _buildAlbumResults() { + if (_albumResults.isEmpty) { + return _buildEmptyResults('No albums found'); + } + + return GridView.builder( + padding: const EdgeInsets.all(16.0), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.8, + crossAxisSpacing: 16, + mainAxisSpacing: 16, + ), + itemCount: _albumResults.length, + itemBuilder: (context, index) { + final album = _albumResults[index]; + return AlbumCard( + album: album, + onTap: () { + // Navigate to album details + }, + ); + }, + ); + } + + Widget _buildArtistResults() { + if (_artistResults.isEmpty) { + return _buildEmptyResults('No artists found'); + } + + return ListView.builder( + itemCount: _artistResults.length, + itemBuilder: (context, index) { + final artist = _artistResults[index]; + return ListTile( + leading: CircleAvatar( + backgroundColor: Theme.of(context).colorScheme.primaryContainer, + child: Text( + artist.name.isNotEmpty ? artist.name[0].toUpperCase() : '?', + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimaryContainer, + fontWeight: FontWeight.bold, + ), + ), + ), + title: Text(artist.name), + trailing: const Icon(Icons.arrow_forward_ios), + onTap: () { + // Navigate to artist details + }, + ); + }, + ); + } + + Widget _buildEmptyResults(String message) { + return Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.search_off, + size: 64, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + const SizedBox(height: 16), + Text( + message, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + const SizedBox(height: 8), + Text( + 'Try different keywords or browse categories', + style: TextStyle( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } + + void _onSearchChanged(String query) { + _currentQuery = query; + if (query.isEmpty) { + setState(() { + _isSearching = false; + _trackResults.clear(); + _albumResults.clear(); + _artistResults.clear(); + }); + } else { + // Debounce search + Future.delayed(const Duration(milliseconds: 500), () { + if (_searchController.text == query) { + _performSearch(query); + } + }); + } + } + + void _onSearchSubmitted(String query) { + _performSearch(query); + _searchFocusNode.unfocus(); + } + + void _clearSearch() { + _searchController.clear(); + setState(() { + _currentQuery = ''; + _isSearching = false; + _trackResults.clear(); + _albumResults.clear(); + _artistResults.clear(); + }); + } + + Future _performSearch(String query) async { + if (query.trim().isEmpty) return; + + setState(() { + _isSearching = true; + }); + + try { + // Simulate API call + await Future.delayed(const Duration(milliseconds: 800)); + + // This would be actual API calls + setState(() { + _isSearching = false; + // For demo, just clear results + _trackResults.clear(); + _albumResults.clear(); + _artistResults.clear(); + }); + } catch (e) { + setState(() { + _isSearching = false; + }); + // Handle error + } + } + + void _playTrack(TrackModel track) { + final audioProvider = Provider.of(context, listen: false); + audioProvider.setQueue([track]); + audioProvider.loadTrack(track); + audioProvider.play(); + + Navigator.pushNamed(context, '/player'); + } +} \ No newline at end of file diff --git a/swingmusic_mobile/lib/features/settings/enhanced_settings_screen.dart b/swingmusic_mobile/lib/features/settings/enhanced_settings_screen.dart new file mode 100644 index 00000000..3589d00b --- /dev/null +++ b/swingmusic_mobile/lib/features/settings/enhanced_settings_screen.dart @@ -0,0 +1,845 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../shared/providers/auth_provider.dart'; +import '../../shared/providers/enhanced_library_provider.dart'; +import '../../core/constants/app_spacing.dart'; + +class EnhancedSettingsScreen extends StatefulWidget { + const EnhancedSettingsScreen({super.key}); + + @override + State createState() => _EnhancedSettingsScreenState(); +} + +class _EnhancedSettingsScreenState extends State { + bool _isExpanded = false; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Theme.of(context).colorScheme.surface, + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.surface, + elevation: 0, + title: Text( + 'Settings', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.w600, + ), + ), + leading: IconButton( + onPressed: () => Navigator.of(context).pop(), + icon: Icon( + Icons.arrow_back, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + ), + body: SingleChildScrollView( + padding: AppSpacing.paddingLG, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Connection Settings + _buildSection( + context, + 'Connection', + Icons.cloud, + [ + _buildServerUrlTile(context), + _buildAuthStatusTile(context), + _buildConnectionTestTile(context), + ], + ), + + const SizedBox(height: 24), + + // Audio Settings + _buildSection( + context, + 'Audio', + Icons.music_note, + [ + _buildAudioQualityTile(context), + _buildCrossfadeTile(context), + _buildGaplessTile(context), + _buildVolumeTile(context), + ], + ), + + const SizedBox(height: 24), + + // Download Settings + _buildSection( + context, + 'Downloads', + Icons.download, + [ + _buildDownloadQualityTile(context), + _buildDownloadLocationTile(context), + _buildWifiOnlyTile(context), + _buildMaxDownloadSizeTile(context), + ], + ), + + const SizedBox(height: 24), + + // Theme Settings + _buildSection( + context, + 'Appearance', + Icons.palette, + [ + _buildThemeTile(context), + _buildAccentColorTile(context), + ], + ), + + const SizedBox(height: 24), + + // Cache Settings + _buildSection( + context, + 'Storage', + Icons.storage, + [ + _buildCacheSizeTile(context), + _buildClearCacheTile(context), + ], + ), + + const SizedBox(height: 24), + + // About + _buildSection( + context, + 'About', + Icons.info, + [ + _buildVersionTile(context), + _buildBuildNumberTile(context), + _buildDeveloperTile(context), + ], + ), + ], + ), + ), + ); + } + + Widget _buildSection( + BuildContext context, + String title, + IconData icon, + List children, + ) { + return Container( + margin: const EdgeInsets.only(bottom: 16), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceVariant, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + Icon( + icon, + color: Theme.of(context).colorScheme.primary, + size: 20, + ), + const SizedBox(width: 12), + Text( + title, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w600, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ], + ), + ), + ...children, + ], + ), + ); + } + + Widget _buildServerUrlTile(BuildContext context) { + return Consumer( + builder: (context, authProvider, child) { + return ListTile( + leading: Icon( + Icons.link, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Server URL', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + authProvider.baseUrl ?? 'Not set', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: IconButton( + onPressed: () => _showServerUrlDialog(context, authProvider), + icon: Icon( + Icons.edit, + color: Theme.of(context).colorScheme.primary, + ), + ), + ); + }, + ); + } + + Widget _buildAuthStatusTile(BuildContext context) { + return Consumer( + builder: (context, authProvider, child) { + return ListTile( + leading: Icon( + authProvider.isLoggedIn ? Icons.check_circle : Icons.error, + color: authProvider.isLoggedIn + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.error, + ), + title: Text( + 'Authentication Status', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + authProvider.isLoggedIn ? 'Connected' : 'Not connected', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: authProvider.isLoggedIn + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.7) + : Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: authProvider.isLoggedIn + ? IconButton( + onPressed: () => _showLogoutDialog(context, authProvider), + icon: Icon( + Icons.logout, + color: Theme.of(context).colorScheme.error, + ), + ) + : null, + ); + }, + ); + } + + Widget _buildConnectionTestTile(BuildContext context) { + return ListTile( + leading: Icon( + Icons.wifi, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Test Connection', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Check server connectivity', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: IconButton( + onPressed: () => _testConnection(context), + icon: Icon( + Icons.play_arrow, + color: Theme.of(context).colorScheme.primary, + ), + ), + ); + } + + Widget _buildAudioQualityTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.high_quality, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Audio Quality', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Higher quality uses more storage', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: libraryProvider.userPreferences['audioQuality'] ?? '320kbps', + items: const ['128kbps', '320kbps', '512kbps', 'flac'], + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'audioQuality': value, + }), + ), + ); + }, + ); + } + + Widget _buildCrossfadeTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.blur_on, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Crossfade', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Smooth transitions between tracks', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: Switch( + value: libraryProvider.userPreferences['crossfade'] ?? false, + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'crossfade': value, + }), + ), + ); + }, + ); + } + + Widget _buildGaplessTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.skip_next, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Gapless Playback', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Remove silence between tracks', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: Switch( + value: libraryProvider.userPreferences['gapless'] ?? false, + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'gapless': value, + }), + ), + ); + }, + ); + } + + Widget _buildVolumeTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.volume_up, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Default Volume', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Set default volume level', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: (libraryProvider.userPreferences['defaultVolume'] ?? 1.0).toDouble(), + items: [0.25, 0.5, 0.75, 1.0], + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'defaultVolume': value, + }), + ), + ); + }, + ); + } + + Widget _buildDownloadQualityTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.download, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Download Quality', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Choose audio quality for downloads', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: libraryProvider.userPreferences['downloadQuality'] ?? '320kbps', + items: const ['128kbps', '320kbps', '512kbps', 'flac'], + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'downloadQuality': value, + }), + ), + ); + }, + ); + } + + Widget _buildDownloadLocationTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.folder, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Download Location', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Where to save downloaded files', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: libraryProvider.userPreferences['downloadLocation'] ?? 'Music', + items: const ['Music', 'Downloads', 'Custom'], + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'downloadLocation': value, + }), + ), + ); + }, + ); + } + + Widget _buildWifiOnlyTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.wifi, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Wi-Fi Only', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Download only when connected to Wi-Fi', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: Switch( + value: libraryProvider.userPreferences['wifiOnly'] ?? false, + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'wifiOnly': value, + }), + ), + ); + }, + ); + } + + Widget _buildMaxDownloadSizeTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.sd_storage, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Max Download Size', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Maximum size for automatic downloads', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: libraryProvider.userPreferences['maxDownloadSize'] ?? '100MB', + items: const ['50MB', '100MB', '500MB', '1GB'], + onChanged: (value) => libraryProvider.updateUserPreferences({ + 'maxDownloadSize': value, + }), + ), + ); + }, + ); + } + + Widget _buildThemeTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.palette, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Theme', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Choose app appearance', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: _getThemeMode(libraryProvider.userPreferences['theme']), + items: const [ + DropdownMenuItem(value: ThemeMode.system, child: Text('System')), + DropdownMenuItem(value: ThemeMode.light, child: Text('Light')), + DropdownMenuItem(value: ThemeMode.dark, child: Text('Dark')), + ], + onChanged: (ThemeMode? value) => libraryProvider.updateUserPreferences({ + 'theme': value?.name, + }), + ), + ); + }, + ); + } + + Widget _buildAccentColorTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.color_lens, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Accent Color', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Customize accent colors', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: libraryProvider.userPreferences['accentColor'] ?? 'Blue', + items: const [ + DropdownMenuItem(value: 'Blue', child: Text('Blue')), + DropdownMenuItem(value: 'Green', child: Text('Green')), + DropdownMenuItem(value: 'Purple', child: Text('Purple')), + DropdownMenuItem(value: 'Orange', child: Text('Orange')), + DropdownMenuItem(value: 'Red', child: Text('Red')), + ], + onChanged: (String? value) => libraryProvider.updateUserPreferences({ + 'accentColor': value, + }), + ), + ); + }, + ); + } + + Widget _buildCacheSizeTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.cached, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Cache Size', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Maximum cache size', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: DropdownButton( + value: libraryProvider.userPreferences['cacheSize'] ?? '500MB', + items: const ['100MB', '500MB', '1GB', '2GB', '5GB'], + onChanged: (String? value) => libraryProvider.updateUserPreferences({ + 'cacheSize': value, + }), + ), + ); + }, + ); + } + + Widget _buildClearCacheTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.clear_all, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Clear Cache', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'Free up storage space', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + trailing: IconButton( + onPressed: () => _showClearCacheDialog(context), + icon: Icon( + Icons.delete_sweep, + color: Theme.of(context).colorScheme.error, + ), + ), + ); + }, + ); + } + + Widget _buildVersionTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.info, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Version', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + libraryProvider.statistics['version'] ?? 'Unknown', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + ); + }, + ); + } + + Widget _buildBuildNumberTile(BuildContext context) { + return Consumer( + builder: (context, libraryProvider, child) { + return ListTile( + leading: Icon( + Icons.build, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Build Number', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + libraryProvider.statistics['buildNumber'] ?? 'Unknown', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + ), + ); + }, + ); + } + + Widget _buildDeveloperTile(BuildContext context) { + return ListTile( + leading: Icon( + Icons.code, + color: Theme.of(context).colorScheme.onSurface, + ), + title: Text( + 'Developer', + style: Theme.of(context).textTheme.bodyLarge, + ), + subtitle: Text( + 'View developer options', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), + ), + trailing: IconButton( + onPressed: () => _showDeveloperOptions(context), + icon: Icon( + Icons.more_horiz, + color: Theme.of(context).colorScheme.primary, + ), + ), + ); + } + + ThemeMode _getThemeMode(String? themeString) { + switch (themeString) { + case 'system': + return ThemeMode.system; + case 'light': + return ThemeMode.light; + case 'dark': + return ThemeMode.dark; + default: + return ThemeMode.system; + } + } + + void _showServerUrlDialog(BuildContext context, AuthProvider authProvider) { + final controller = TextEditingController(text: authProvider.baseUrl ?? ''); + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Server URL'), + content: TextField( + controller: controller, + decoration: InputDecoration( + labelText: 'Server URL', + hintText: 'https://your-server.com', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.outline, + ), + ), + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text('Cancel'), + ), + TextButton( + onPressed: () { + authProvider.updateBaseUrl(controller.text.trim()); + Navigator.of(context).pop(); + }, + child: Text('Save'), + ), + ], + ), + ); + } + + void _showLogoutDialog(BuildContext context, AuthProvider authProvider) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Logout'), + content: Text('Are you sure you want to logout?'), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text('Cancel'), + ), + TextButton( + onPressed: () { + authProvider.logout(); + Navigator.of(context).pop(); + }, + child: Text('Logout'), + ), + ], + ), + ); + } + + void _testConnection(BuildContext context) { + // TODO: Implement connection test + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Connection test not implemented yet')), + ); + } + + void _showClearCacheDialog(BuildContext context) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Clear Cache'), + content: Text('Are you sure you want to clear all cached data?'), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text('Cancel'), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Cache cleared successfully')), + ); + }, + child: Text('Clear'), + ), + ], + ), + ); + } + + void _showDeveloperOptions(BuildContext context) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Developer Options'), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ListTile( + title: Text('Debug Mode'), + trailing: Switch( + value: false, + onChanged: (value) { + // TODO: Implement debug mode + }, + ), + ), + ListTile( + title: Text('Enable Logging'), + trailing: Switch( + value: false, + onChanged: (value) { + // TODO: Implement logging + }, + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text('Close'), + ), + ], + ), + ); + } +} diff --git a/swingmusic_mobile/lib/features/settings/settings_screen.dart b/swingmusic_mobile/lib/features/settings/settings_screen.dart new file mode 100644 index 00000000..e41da34f --- /dev/null +++ b/swingmusic_mobile/lib/features/settings/settings_screen.dart @@ -0,0 +1,518 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../core/constants/app_constants.dart'; + +class SettingsScreen extends StatefulWidget { + const SettingsScreen({super.key}); + + @override + State createState() => _SettingsScreenState(); +} + +class _SettingsScreenState extends State { + bool _isLoading = false; + + // Connection settings + String _serverUrl = ''; + String _username = ''; + bool _isConnected = false; + + // Audio settings + double _volume = 1.0; + double _audioQuality = 1.0; // 0.5 = Low, 1.0 = High + bool _gaplessPlayback = false; + bool _crossfade = true; + double _crossfadeDuration = 5.0; + + // Theme settings + ThemeMode _themeMode = ThemeMode.system; + + // Download settings + String _downloadQuality = 'high'; // 'low', 'medium', 'high' + bool _wifiOnlyDownloads = true; + int _maxDownloadSize = 1000; // MB + + // Cache settings + int _cacheSize = 500; // MB + bool _clearCacheOnStart = false; + + // Analytics settings + bool _enableAnalytics = true; + bool _shareListeningData = false; + + @override + void initState() { + super.initState(); + _loadSettings(); + } + + Future _loadSettings() async { + setState(() { + _isLoading = true; + }); + + final prefs = await SharedPreferences.getInstance(); + + setState(() { + _serverUrl = prefs.getString('server_url') ?? AppConstants.defaultApiUrl; + _username = prefs.getString('username') ?? ''; + _isConnected = prefs.getBool('is_connected') ?? false; + _volume = prefs.getDouble('volume') ?? 1.0; + _audioQuality = prefs.getDouble('audio_quality') ?? 1.0; + _gaplessPlayback = prefs.getBool('gapless_playback') ?? false; + _crossfade = prefs.getBool('crossfade') ?? true; + _crossfadeDuration = prefs.getDouble('crossfade_duration') ?? 5.0; + + final themeIndex = prefs.getInt('theme_mode') ?? 2; + _themeMode = ThemeMode.values[themeIndex]; + + _downloadQuality = prefs.getString('download_quality') ?? 'high'; + _wifiOnlyDownloads = prefs.getBool('wifi_only_downloads') ?? true; + _maxDownloadSize = prefs.getInt('max_download_size') ?? 1000; + _cacheSize = prefs.getInt('cache_size') ?? 500; + _clearCacheOnStart = prefs.getBool('clear_cache_on_start') ?? false; + _enableAnalytics = prefs.getBool('enable_analytics') ?? true; + _shareListeningData = prefs.getBool('share_listening_data') ?? false; + _isLoading = false; + }); + } + + Future _saveSettings() async { + final prefs = await SharedPreferences.getInstance(); + + await prefs.setString('server_url', _serverUrl); + await prefs.setString('username', _username); + await prefs.setBool('is_connected', _isConnected); + await prefs.setDouble('volume', _volume); + await prefs.setDouble('audio_quality', _audioQuality); + await prefs.setBool('gapless_playback', _gaplessPlayback); + await prefs.setBool('crossfade', _crossfade); + await prefs.setDouble('crossfade_duration', _crossfadeDuration); + await prefs.setInt('theme_mode', _themeMode.index); + await prefs.setString('download_quality', _downloadQuality); + await prefs.setBool('wifi_only_downloads', _wifiOnlyDownloads); + await prefs.setInt('max_download_size', _maxDownloadSize); + await prefs.setInt('cache_size', _cacheSize); + await prefs.setBool('clear_cache_on_start', _clearCacheOnStart); + await prefs.setBool('enable_analytics', _enableAnalytics); + await prefs.setBool('share_listening_data', _shareListeningData); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Settings'), + elevation: 0, + backgroundColor: Theme.of(context).colorScheme.surface, + actions: [ + TextButton( + onPressed: _saveSettings, + child: const Text('Save'), + ), + ], + ), + body: _isLoading + ? const Center(child: CircularProgressIndicator()) + : ListView( + padding: const EdgeInsets.all(16.0), + children: [ + // Connection Section + _buildSectionHeader('Connection'), + _buildServerUrlField(), + _buildUsernameField(), + _buildConnectionStatus(), + const SizedBox(height: 24), + + // Audio Section + _buildSectionHeader('Audio'), + _buildVolumeSlider(), + _buildAudioQualityDropdown(), + _buildGaplessPlaybackSwitch(), + _buildCrossfadeSwitch(), + _buildCrossfadeDurationSlider(), + const SizedBox(height: 24), + + // Theme Section + _buildSectionHeader('Appearance'), + _buildThemeSelector(), + const SizedBox(height: 24), + + // Download Section + _buildSectionHeader('Downloads'), + _buildDownloadQualityDropdown(), + _buildWifiOnlySwitch(), + _buildMaxDownloadSizeField(), + const SizedBox(height: 24), + + // Cache Section + _buildSectionHeader('Storage'), + _buildCacheSizeField(), + _buildClearCacheSwitch(), + _buildClearCacheButton(), + const SizedBox(height: 24), + + // Analytics Section + _buildSectionHeader('Analytics'), + _buildAnalyticsSwitch(), + _buildShareDataSwitch(), + const SizedBox(height: 24), + + // About Section + _buildSectionHeader('About'), + _buildAppInfo(), + _buildVersionInfo(), + ], + ), + ); + } + + Widget _buildSectionHeader(String title) { + return Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Text( + title, + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + ); + } + + Widget _buildServerUrlField() { + return TextField( + controller: TextEditingController(text: _serverUrl), + decoration: const InputDecoration( + labelText: 'Server URL', + hintText: 'http://192.168.1.100:1970', + border: OutlineInputBorder(), + ), + onChanged: (value) { + _serverUrl = value; + }, + ); + } + + Widget _buildUsernameField() { + return TextField( + controller: TextEditingController(text: _username), + decoration: const InputDecoration( + labelText: 'Username', + border: OutlineInputBorder(), + ), + onChanged: (value) { + _username = value; + }, + ); + } + + Widget _buildConnectionStatus() { + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: _isConnected ? Colors.green : Colors.red, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + children: [ + Icon( + _isConnected ? Icons.check_circle : Icons.error, + color: Colors.white, + ), + const SizedBox(width: 8), + Text( + _isConnected ? 'Connected' : 'Disconnected', + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ); + } + + Widget _buildVolumeSlider() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Volume: ${(_volume * 100).round()}%'), + Slider( + value: _volume, + min: 0.0, + max: 1.0, + divisions: 20, + onChanged: (value) { + setState(() { + _volume = value; + }); + }, + ), + ], + ); + } + + Widget _buildAudioQualityDropdown() { + return DropdownButtonFormField( + decoration: const InputDecoration( + labelText: 'Audio Quality', + border: OutlineInputBorder(), + ), + items: ['Low', 'Medium', 'High'].map((quality) { + return DropdownMenuItem( + value: quality, + child: Text(quality), + ); + }).toList(), + onChanged: (value) { + if (value != null) { + setState(() { + _audioQuality = value == 'Low' ? 0.5 : value == 'High' ? 1.0 : 0.75; + }); + } + }, + ); + } + + Widget _buildGaplessPlaybackSwitch() { + return SwitchListTile( + title: const Text('Gapless Playback'), + subtitle: const Text('Remove gaps between tracks'), + value: _gaplessPlayback, + onChanged: (value) { + setState(() { + _gaplessPlayback = value; + }); + }, + ); + } + + Widget _buildCrossfadeSwitch() { + return SwitchListTile( + title: const Text('Crossfade'), + subtitle: const Text('Smooth transition between tracks'), + value: _crossfade, + onChanged: (value) { + setState(() { + _crossfade = value; + }); + }, + ); + } + + Widget _buildCrossfadeDurationSlider() { + if (!_crossfade) return const SizedBox.shrink(); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Crossfade Duration: ${_crossfadeDuration.round()}s'), + Slider( + value: _crossfadeDuration, + min: 1.0, + max: 10.0, + divisions: 18, + onChanged: (value) { + setState(() { + _crossfadeDuration = value; + }); + }, + ), + ], + ); + } + + Widget _buildThemeSelector() { + return Column( + children: [ + RadioListTile( + title: const Text('Light'), + value: ThemeMode.light, + groupValue: _themeMode, + onChanged: (ThemeMode? value) { + if (value != null) { + setState(() { + _themeMode = value; + }); + } + }, + ), + RadioListTile( + title: const Text('Dark'), + value: ThemeMode.dark, + groupValue: _themeMode, + onChanged: (ThemeMode? value) { + if (value != null) { + setState(() { + _themeMode = value; + }); + } + }, + ), + RadioListTile( + title: const Text('System'), + value: ThemeMode.system, + groupValue: _themeMode, + onChanged: (ThemeMode? value) { + if (value != null) { + setState(() { + _themeMode = value; + }); + } + }, + ), + ], + ); + } + + Widget _buildDownloadQualityDropdown() { + return DropdownButtonFormField( + decoration: const InputDecoration( + labelText: 'Download Quality', + border: OutlineInputBorder(), + ), + items: ['Low', 'Medium', 'High'].map((quality) { + return DropdownMenuItem( + value: quality, + child: Text(quality), + ); + }).toList(), + onChanged: (value) { + if (value != null) { + setState(() { + _downloadQuality = value; + }); + } + }, + ); + } + + Widget _buildWifiOnlySwitch() { + return SwitchListTile( + title: const Text('Wi-Fi Only Downloads'), + subtitle: const Text('Only download when connected to Wi-Fi'), + value: _wifiOnlyDownloads, + onChanged: (value) { + setState(() { + _wifiOnlyDownloads = value; + }); + }, + ); + } + + Widget _buildMaxDownloadSizeField() { + return TextField( + controller: TextEditingController(text: _maxDownloadSize.toString()), + decoration: const InputDecoration( + labelText: 'Max Download Size (MB)', + border: OutlineInputBorder(), + ), + keyboardType: TextInputType.number, + onChanged: (value) { + _maxDownloadSize = int.tryParse(value) ?? _maxDownloadSize; + }, + ); + } + + Widget _buildCacheSizeField() { + return TextField( + controller: TextEditingController(text: _cacheSize.toString()), + decoration: const InputDecoration( + labelText: 'Cache Size (MB)', + border: OutlineInputBorder(), + ), + keyboardType: TextInputType.number, + onChanged: (value) { + _cacheSize = int.tryParse(value) ?? _cacheSize; + }, + ); + } + + Widget _buildClearCacheSwitch() { + return SwitchListTile( + title: const Text('Clear Cache on Start'), + subtitle: const Text('Clear cache when app starts'), + value: _clearCacheOnStart, + onChanged: (value) { + setState(() { + _clearCacheOnStart = value; + }); + }, + ); + } + + Widget _buildClearCacheButton() { + return ElevatedButton.icon( + onPressed: () async { + // Clear cache logic + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Cache cleared')), + ); + }, + icon: const Icon(Icons.delete_outline), + label: const Text('Clear Cache'), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + ), + ); + } + + Widget _buildAnalyticsSwitch() { + return SwitchListTile( + title: const Text('Enable Analytics'), + subtitle: const Text('Track listening statistics'), + value: _enableAnalytics, + onChanged: (value) { + setState(() { + _enableAnalytics = value; + }); + }, + ); + } + + Widget _buildShareDataSwitch() { + return SwitchListTile( + title: const Text('Share Listening Data'), + subtitle: const Text('Share anonymous listening data for improvements'), + value: _shareListeningData, + onChanged: (value) { + setState(() { + _shareListeningData = value; + }); + }, + ); + } + + Widget _buildAppInfo() { + return ListTile( + leading: const Icon(Icons.info_outline), + title: const Text('About SwingMusic'), + trailing: const Icon(Icons.arrow_forward_ios), + onTap: () { + showAboutDialog( + context: context, + applicationName: 'SwingMusic', + applicationVersion: '1.0.0', + applicationIcon: const Icon(Icons.music_note), + children: [ + const Text('A modern music player for SwingMusic server'), + const Text('Built with Flutter'), + ], + ); + }, + ); + } + + Widget _buildVersionInfo() { + return ListTile( + leading: const Icon(Icons.code), + title: const Text('Version'), + subtitle: const Text('1.0.0 (Flutter)'), + trailing: const Icon(Icons.arrow_forward_ios), + onTap: () { + // Show changelog + }, + ); + } +} \ No newline at end of file diff --git a/swingmusic_mobile/lib/main.dart b/swingmusic_mobile/lib/main.dart new file mode 100644 index 00000000..8ad1278a --- /dev/null +++ b/swingmusic_mobile/lib/main.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'features/home/home_screen.dart'; +import 'features/library/library_screen.dart'; +import 'features/player/enhanced_player_screen_new.dart'; +import 'features/search/search_screen.dart'; +import 'features/playlists/playlists_screen.dart'; +import 'features/settings/settings_screen.dart'; +import 'features/auth/enhanced_auth_screen.dart'; +import 'features/analytics/analytics_screen.dart'; +import 'shared/providers/audio_provider.dart'; +import 'shared/providers/auth_provider.dart'; +import 'shared/providers/enhanced_library_provider.dart'; +import 'shared/routes/app_router.dart'; +import 'shared/widgets/main_navigation.dart'; +import 'core/themes/app_theme.dart'; + +void main() { + runApp(const SwingMusicApp()); +} + +class SwingMusicApp extends StatelessWidget { + const SwingMusicApp({super.key}); + + @override + Widget build(BuildContext context) { + return MultiProvider( + providers: [ + ChangeNotifierProvider(create: (_) => AudioProvider()), + ChangeNotifierProvider(create: (_) => AuthProvider()), + ChangeNotifierProvider(create: (_) => EnhancedLibraryProvider()), + ], + child: MaterialApp.router( + title: 'SwingMusic', + theme: AppTheme.lightTheme, + darkTheme: AppTheme.darkTheme, + themeMode: ThemeMode.system, + routerConfig: AppRouter.router, + debugShowCheckedModeBanner: false, + ), + ); + } +} diff --git a/swingmusic_mobile/lib/shared/providers/audio_provider.dart b/swingmusic_mobile/lib/shared/providers/audio_provider.dart new file mode 100644 index 00000000..e9a0d86c --- /dev/null +++ b/swingmusic_mobile/lib/shared/providers/audio_provider.dart @@ -0,0 +1,147 @@ +import 'package:flutter/foundation.dart'; +import '../../data/services/audio_service.dart'; +import '../../data/models/track_model.dart'; +import '../../core/enums/playback_mode.dart'; + +class AudioProvider extends ChangeNotifier { + final AudioService _audioService = AudioService(); + + // Getters for audio state + TrackModel? get currentTrack => _audioService.currentTrack; + bool get isPlaying => _audioService.isPlaying; + bool get isPaused => _audioService.isPaused; + bool get isLoading => _audioService.isLoading; + bool get isBuffering => _audioService.isBuffering; + bool get hasError => _audioService.hasError; + String? get errorMessage => _audioService.errorMessage; + Duration get position => _audioService.position; + Duration get duration => _audioService.duration; + double get volume => _audioService.volume; + List get queue => _audioService.queue; + int get currentIndex => _audioService.currentIndex; + bool get isShuffleMode => _audioService.isShuffleMode; + bool get isRepeatMode => _audioService.isRepeatMode; + RepeatMode get repeatMode => _audioService.repeatMode; + ShuffleMode get shuffleMode => _audioService.shuffleMode; + double get playbackSpeed => _audioService.playbackSpeed; + + // Streams + Stream get positionStream => _audioService.positionStream; + Stream get durationStream => _audioService.durationStream; + Stream get playingStateStream => _audioService.playingStateStream; + Stream get currentTrackStream => _audioService.currentTrackStream; + Stream> get queueStream => _audioService.queueStream; + Stream get bufferingStream => _audioService.bufferingStream; + Stream get errorStream => _audioService.errorStream; + Stream get repeatModeStream => _audioService.repeatModeStream; + Stream get shuffleModeStream => _audioService.shuffleModeStream; + + // Audio controls + Future initialize() async { + await _audioService.initialize(); + notifyListeners(); + } + + Future loadTrack(TrackModel track) async { + await _audioService.loadTrack(track); + notifyListeners(); + } + + Future play() async { + await _audioService.play(); + notifyListeners(); + } + + Future pause() async { + await _audioService.pause(); + notifyListeners(); + } + + Future stop() async { + await _audioService.stop(); + notifyListeners(); + } + + Future seekTo(Duration position) async { + await _audioService.seekTo(position); + notifyListeners(); + } + + Future setVolume(double volume) async { + await _audioService.setVolume(volume); + notifyListeners(); + } + + Future setSpeed(double speed) async { + await _audioService.setSpeed(speed); + notifyListeners(); + } + + // Queue management + void setQueue(List tracks) { + _audioService.setQueue(tracks); + notifyListeners(); + } + + void addToQueue(TrackModel track) { + _audioService.addToQueue(track); + notifyListeners(); + } + + void removeFromQueue(int index) { + _audioService.removeFromQueue(index); + notifyListeners(); + } + + void clearQueue() { + _audioService.clearQueue(); + notifyListeners(); + } + + Future playNext() async { + await _audioService.playNext(); + notifyListeners(); + } + + Future playPrevious() async { + await _audioService.playPrevious(); + notifyListeners(); + } + + void jumpToIndex(int index) { + _audioService.jumpToIndex(index); + notifyListeners(); + } + + // Playback modes + void toggleShuffle() { + _audioService.toggleShuffle(); + notifyListeners(); + } + + void toggleRepeat() { + _audioService.toggleRepeat(); + notifyListeners(); + } + + void setShuffleMode(ShuffleMode mode) { + _audioService.setShuffleMode(mode == ShuffleMode.on); + notifyListeners(); + } + + void setRepeatMode(RepeatMode mode) { + _audioService.setRepeatMode(mode); + notifyListeners(); + } + + // Utility methods + String get positionFormatted => _audioService.positionFormatted; + String get durationFormatted => _audioService.durationFormatted; + double get progress => _audioService.progress; + + @override + void dispose() { + _audioService.dispose(); + super.dispose(); + } +} diff --git a/swingmusic_mobile/lib/shared/providers/auth_provider.dart b/swingmusic_mobile/lib/shared/providers/auth_provider.dart new file mode 100644 index 00000000..1a9fbc17 --- /dev/null +++ b/swingmusic_mobile/lib/shared/providers/auth_provider.dart @@ -0,0 +1,208 @@ +import 'package:flutter/foundation.dart'; +import 'dart:convert'; +import 'package:http/http.dart' as http; +import 'package:shared_preferences/shared_preferences.dart'; + +class AuthProvider extends ChangeNotifier { + AuthState _authState = AuthState.loggedOut; + String? _errorMessage; + String? _baseUrl; + String? _accessToken; + String? _refreshToken; + + // Getters + AuthState get authState => _authState; + String? get errorMessage => _errorMessage; + String? get baseUrl => _baseUrl; + String? get accessToken => _accessToken; + String? get refreshToken => _refreshToken; + bool get isLoggedIn => _authState.isLoggedIn; + bool get isLoggedOut => _authState.isLoggedOut; + bool get isAuthenticating => _authState.isAuthenticating; + bool get hasError => _authState.hasError; + + Future initialize() async { + await _loadStoredCredentials(); + _checkLoginStatus(); + } + + Future loginWithUsernameAndPassword( + String baseUrl, + String username, + String password, + ) async { + try { + _setAuthenticating(); + + // Validate URL + if (!_isValidUrl(baseUrl)) { + _setError('Please enter a valid server URL'); + return; + } + + if (username.isEmpty || password.isEmpty) { + _setError('Username and password are required'); + return; + } + + // Make API call to login + final response = await http.post( + Uri.parse('$baseUrl/api/auth/login'), + headers: {'Content-Type': 'application/json'}, + body: jsonEncode({ + 'username': username, + 'password': password, + }), + ); + + if (response.statusCode == 200) { + final data = jsonDecode(response.body); + _accessToken = data['access_token']; + _refreshToken = data['refresh_token']; + _baseUrl = baseUrl; + + // Store credentials + final prefs = await SharedPreferences.getInstance(); + await prefs.setString('access_token', _accessToken!); + await prefs.setString('refresh_token', _refreshToken!); + await prefs.setString('base_url', _baseUrl); + + _setAuthenticated(); + _clearError(); + } else { + _setError('Login failed: ${response.statusCode}'); + } + } catch (e) { + _setError('Login error: $e'); + } + } + + Future loginWithQrCode(String qrCode) async { + try { + _setAuthenticating(); + + // TODO: Implement QR code login logic + // For now, simulate successful login + await Future.delayed(const Duration(seconds: 1)); + + _accessToken = 'mock_token_from_qr'; + _refreshToken = 'mock_refresh_from_qr'; + + // Store credentials + final prefs = await SharedPreferences.getInstance(); + await prefs.setString('access_token', _accessToken!); + await prefs.setString('refresh_token', _refreshToken!); + + _setAuthenticated(); + _clearError(); + } catch (e) { + _setError('QR code login error: $e'); + } + } + + Future logout() async { + try { + final prefs = await SharedPreferences.getInstance(); + await prefs.remove('access_token'); + await prefs.remove('refresh_token'); + await prefs.remove('base_url'); + + _accessToken = null; + _refreshToken = null; + _setLoggedOut(); + _clearError(); + } catch (e) { + // Continue with logout even if storage fails + _accessToken = null; + _refreshToken = null; + _setLoggedOut(); + _clearError(); + } + } + + Future refreshTokens() async { + try { + if (_refreshToken == null) return; + + // TODO: Implement token refresh logic + // For now, just check if current token is still valid + } catch (e) { + _setError('Token refresh failed: $e'); + } + } + + void _setAuthenticating() { + _authState = AuthState.authenticating; + _clearError(); + notifyListeners(); + } + + void _setAuthenticated() { + _authState = AuthState.authenticated; + _clearError(); + notifyListeners(); + } + + void _setLoggedOut() { + _authState = AuthState.loggedOut; + _clearError(); + notifyListeners(); + } + + void _setError(String error) { + _errorMessage = error; + _authState = AuthState.error; + notifyListeners(); + } + + void _clearError() { + _errorMessage = null; + if (_authState == AuthState.error) { + _authState = AuthState.loggedOut; + } + notifyListeners(); + } + + bool _isValidUrl(String url) { + try { + final uri = Uri.parse(url); + return uri.hasScheme && (uri.scheme == 'http' || uri.scheme == 'https'); + } catch (e) { + return false; + } + } + + Future _loadStoredCredentials() async { + try { + final prefs = await SharedPreferences.getInstance(); + _accessToken = prefs.getString('access_token'); + _refreshToken = prefs.getString('refresh_token'); + _baseUrl = prefs.getString('base_url'); + + if (_accessToken != null) { + _setAuthenticated(); + } + } catch (e) { + // Continue without stored credentials + debugPrint('Error loading stored credentials: $e'); + } + } + + Future _checkLoginStatus() async { + // TODO: Implement token validation + // For now, assume stored token is valid + if (_accessToken != null) { + _setAuthenticated(); + } + } + + // HTTP client with auth headers + http.BaseClient get authenticatedHttpClient { + return http.BaseClient( + headers: { + 'Authorization': 'Bearer $_accessToken', + 'Content-Type': 'application/json', + }, + ); + } +} diff --git a/swingmusic_mobile/lib/shared/providers/enhanced_library_provider.dart b/swingmusic_mobile/lib/shared/providers/enhanced_library_provider.dart new file mode 100644 index 00000000..75d402e2 --- /dev/null +++ b/swingmusic_mobile/lib/shared/providers/enhanced_library_provider.dart @@ -0,0 +1,699 @@ +import 'package:flutter/foundation.dart'; +import '../../data/services/enhanced_api_service.dart'; +import '../../data/models/track_model.dart'; +import '../../data/models/album_model.dart'; +import '../../data/models/artist_model.dart' as artist; +import '../../data/models/playlist_model.dart'; + +class EnhancedLibraryProvider extends ChangeNotifier { + final EnhancedApiService _apiService; + + // State + List _tracks = []; + List _albums = []; + List _artists = []; + List _playlists = []; + List _folders = []; + Map _userInfo = {}; + Map _userPreferences = {}; + Map _statistics = {}; + List _favoriteTracks = []; + List _favoriteAlbums = []; + List _favoriteArtists = []; + List _queue = []; + + // Loading states + bool _isLoadingTracks = false; + bool _isLoadingAlbums = false; + bool _isLoadingArtists = false; + bool _isLoadingPlaylists = false; + bool _isLoadingFolders = false; + bool _isLoadingUserInfo = false; + bool _isLoadingStatistics = false; + bool _isLoadingFavorites = false; + bool _isLoadingQueue = false; + + // Error states + String? _error; + + EnhancedLibraryProvider({EnhancedApiService? apiService}) + : _apiService = apiService ?? EnhancedApiService(); + + // Getters + List get tracks => _tracks; + List get albums => _albums; + List get artists => _artists; + List get playlists => _playlists; + List get folders => _folders; + Map get userInfo => _userInfo; + Map get userPreferences => _userPreferences; + Map get statistics => _statistics; + List get favoriteTracks => _favoriteTracks; + List get favoriteAlbums => _favoriteAlbums; + List get favoriteArtists => _favoriteArtists; + List get queue => _queue; + + bool get isLoadingTracks => _isLoadingTracks; + bool get isLoadingAlbums => _isLoadingAlbums; + bool get isLoadingArtists => _isLoadingArtists; + bool get isLoadingPlaylists => _isLoadingPlaylists; + bool get isLoadingFolders => _isLoadingFolders; + bool get isLoadingUserInfo => _isLoadingUserInfo; + bool get isLoadingStatistics => _isLoadingStatistics; + bool get isLoadingFavorites => _isLoadingFavorites; + bool get isLoadingQueue => _isLoadingQueue; + + String? get error => _error; + bool get hasError => _error != null; + + // Initialize data + Future initialize() async { + await loadUserInfo(); + await loadStatistics(); + } + + // Track methods + Future loadTracks({String? search, String? artist, String? album, String? folder}) async { + _setLoadingTracks(true); + _clearError(); + + try { + _tracks = await _apiService.getTracks( + search: search, + artist: artist, + album: album, + folder: folder, + ); + _setLoadingTracks(false); + } catch (e) { + _setError('Failed to load tracks: $e'); + _setLoadingTracks(false); + } + } + + Future refreshTracks() async { + await loadTracks(); + } + + Future loadTrack(String trackHash) async { + try { + final track = await _apiService.getTrack(trackHash); + if (track != null) { + // Update track in current list if exists + final index = _tracks.indexWhere((t) => t.trackhash == trackHash); + if (index != -1) { + _tracks[index] = track; + } + } + } catch (e) { + _setError('Failed to load track: $e'); + } + } + + Future toggleFavoriteTrack(String trackHash) async { + try { + await _apiService.toggleFavoriteTrack(trackHash); + + // Update track in local list + final index = _tracks.indexWhere((t) => t.trackhash == trackHash); + if (index != -1) { + final track = _tracks[index]; + _tracks[index] = track.copyWith(isFavorite: !track.isFavorite); + } + + // Update in favorites list + final favIndex = _favoriteTracks.indexWhere((t) => t.trackhash == trackHash); + if (favIndex != -1) { + _favoriteTracks[favIndex] = _favoriteTracks[favIndex].copyWith(isFavorite: !_favoriteTracks[favIndex].isFavorite); + } else { + _favoriteTracks.add(_tracks.firstWhere((t) => t.trackhash == trackHash)); + } + + notifyListeners(); + } catch (e) { + _setError('Failed to toggle favorite: $e'); + } + } + + // Album methods + Future loadAlbums({String? search, String? artist}) async { + _setLoadingAlbums(true); + _clearError(); + + try { + _albums = await _apiService.getAlbums(search: search, artist: artist); + _setLoadingAlbums(false); + } catch (e) { + _setError('Failed to load albums: $e'); + } + } + + Future refreshAlbums() async { + await loadAlbums(); + } + + Future loadAlbum(String albumHash) async { + try { + final album = await _apiService.getAlbum(albumHash); + if (album != null) { + // Update album in current list if exists + final index = _albums.indexWhere((a) => a.albumhash == albumHash); + if (index != -1) { + _albums[index] = album; + } + } + } catch (e) { + _setError('Failed to load album: $e'); + } + } + + Future loadAlbumTracks(String albumHash) async { + _setLoadingTracks(true); + _clearError(); + + try { + final tracks = await _apiService.getAlbumTracks(albumHash); + _tracks = tracks; + _setLoadingTracks(false); + } catch (e) { + _setError('Failed to load album tracks: $e'); + } + } + + Future toggleFavoriteAlbum(String albumHash) async { + try { + await _apiService.toggleFavoriteAlbum(albumHash); + + // Update album in local list + final index = _albums.indexWhere((a) => a.albumhash == albumHash); + if (index != -1) { + final album = _albums[index]; + _albums[index] = album.copyWith(isFavorite: !album.isFavorite); + } + + // Update in favorites list + final favIndex = _favoriteAlbums.indexWhere((a) => a.albumhash == albumHash); + if (favIndex != -1) { + _favoriteAlbums[favIndex] = _favoriteAlbums[favIndex].copyWith(isFavorite: !_favoriteAlbums[favIndex].isFavorite); + } else { + _favoriteAlbums.add(_albums.firstWhere((a) => a.albumhash == albumHash)); + } + + notifyListeners(); + } catch (e) { + _setError('Failed to toggle favorite album: $e'); + } + } + + // Artist methods + Future loadArtists({String? search}) async { + _setLoadingArtists(true); + _clearError(); + + try { + _artists = await _apiService.getArtists(search: search); + _setLoadingArtists(false); + } catch (e) { + _setError('Failed to load artists: $e'); + } + } + + Future refreshArtists() async { + await loadArtists(); + } + + Future loadArtist(String artistHash) async { + try { + final artist = await _apiService.getArtist(artistHash); + if (artist != null) { + // Update artist in current list if exists + final index = _artists.indexWhere((a) => a.artisthash == artistHash); + if (index != -1) { + _artists[index] = artist; + } + } + } catch (e) { + _setError('Failed to load artist: $e'); + } + } + + Future loadArtistAlbums(String artistHash) async { + _setLoadingAlbums(true); + _clearError(); + + try { + final albums = await _apiService.getArtistAlbums(artistHash); + _albums = albums; + _setLoadingAlbums(false); + } catch (e) { + _setError('Failed to load artist albums: $e'); + } + } + + Future loadArtistTracks(String artistHash) async { + _setLoadingTracks(true); + _clearError(); + + try { + final tracks = await _apiService.getArtistTracks(artistHash); + _tracks = tracks; + _setLoadingTracks(false); + } catch (e) { + _setError('Failed to load artist tracks: $e'); + } + } + + Future toggleFavoriteArtist(String artistHash) async { + try { + await _apiService.toggleFavoriteArtist(artistHash); + + // Update artist in local list + final index = _artists.indexWhere((a) => a.artisthash == artistHash); + if (index != -1) { + final artist = _artists[index]; + _artists[index] = artist.copyWith(isFavorite: !artist.isFavorite); + } + + // Update in favorites list + final favIndex = _favoriteArtists.indexWhere((a) => a.artisthash == artistHash); + if (favIndex != -1) { + _favoriteArtists[favIndex] = _favoriteArtists[favIndex].copyWith(isFavorite: !_favoriteArtists[favIndex].isFavorite); + } else { + _favoriteArtists.add(_artists.firstWhere((a) => a.artisthash == artistHash)); + } + + notifyListeners(); + } catch (e) { + _setError('Failed to toggle favorite artist: $e'); + } + } + + // Playlist methods + Future loadPlaylists() async { + _setLoadingPlaylists(true); + _clearError(); + + try { + _playlists = await _apiService.getPlaylists(); + _setLoadingPlaylists(false); + } catch (e) { + _setError('Failed to load playlists: $e'); + } + } + + Future refreshPlaylists() async { + await loadPlaylists(); + } + + Future loadPlaylist(String playlistId) async { + try { + final playlist = await _apiService.getPlaylist(playlistId); + if (playlist != null) { + // Update playlist in current list if exists + final index = _playlists.indexWhere((p) => p.playlistId == playlistId); + if (index != -1) { + _playlists[index] = playlist; + } + } + } catch (e) { + _setError('Failed to load playlist: $e'); + } + } + + Future createPlaylist(String name, String description) async { + _setLoadingPlaylists(true); + _clearError(); + + try { + final newPlaylist = await _apiService.createPlaylist(name, description); + _playlists.insert(0, newPlaylist); + _setLoadingPlaylists(false); + } catch (e) { + _setError('Failed to create playlist: $e'); + } + } + + Future addToPlaylist(String playlistId, String trackHash) async { + try { + await _apiService.addToPlaylist(playlistId, trackHash); + } catch (e) { + _setError('Failed to add to playlist: $e'); + } + } + + Future removeFromPlaylist(String playlistId, String trackHash) async { + try { + await _apiService.removeFromPlaylist(playlistId, trackHash); + } catch (e) { + _setError('Failed to remove from playlist: $e'); + } + } + + // Folder methods + Future loadFolders() async { + _setLoadingFolders(true); + _clearError(); + + try { + _folders = await _apiService.getFolders(); + _setLoadingFolders(false); + } catch (e) { + _setError('Failed to load folders: $e'); + } + } + + Future loadFolderTracks(String folderHash) async { + _setLoadingTracks(true); + _clearError(); + + try { + final tracks = await _apiService.getFolderTracks(folderHash); + _tracks = tracks; + _setLoadingTracks(false); + } catch (e) { + _setError('Failed to load folder tracks: $e'); + } + } + + // Favorites methods + Future loadFavoriteTracks() async { + _setLoadingFavorites(true); + _clearError(); + + try { + _favoriteTracks = await _apiService.getFavoriteTracks(); + _setLoadingFavorites(false); + } catch (e) { + _setError('Failed to load favorite tracks: $e'); + } + } + + Future loadFavoriteAlbums() async { + _setLoadingFavorites(true); + _clearError(); + + try { + _favoriteAlbums = await _apiService.getFavoriteAlbums(); + _setLoadingFavorites(false); + } catch (e) { + _setError('Failed to load favorite albums: $e'); + } + } + + Future loadFavoriteArtists() async { + _setLoadingFavorites(true); + _clearError(); + + try { + _favoriteArtists = await _apiService.getFavoriteArtists(); + _setLoadingFavorites(false); + } catch (e) { + _setError('Failed to load favorite artists: $e'); + } + } + + // User methods + Future loadUserInfo() async { + _setLoadingUserInfo(true); + _clearError(); + + try { + _userInfo = await _apiService.getUserInfo(); + _setLoadingUserInfo(false); + } catch (e) { + _setError('Failed to load user info: $e'); + } + } + + Future updateUserPreferences(Map preferences) async { + try { + await _apiService.updateUserPreferences(preferences); + _userPreferences = preferences; + } catch (e) { + _setError('Failed to update preferences: $e'); + } + } + + Future loadUserPreferences() async { + _setLoadingUserInfo(true); + _clearError(); + + try { + _userPreferences = await _apiService.getUserPreferences(); + _setLoadingUserInfo(false); + } catch (e) { + _setError('Failed to load preferences: $e'); + } + } + + // Statistics methods + Future loadStatistics() async { + _setLoadingStatistics(true); + _clearError(); + + try { + _statistics = await _apiService.getStatistics(); + _setLoadingStatistics(false); + } catch (e) { + _setError('Failed to load statistics: $e'); + } + } + + // Download methods + Future loadDownloads() async { + _setLoadingDownloads(true); + _clearError(); + + try { + // TODO: Implement actual download loading from API + _downloads = [ + { + 'downloadId': '1', + 'title': 'Example Track 1', + 'artist': 'Example Artist', + 'status': 'completed', + 'progress': 1.0, + 'speed': 2.5, + 'eta': 0, + }, + { + 'downloadId': '2', + 'title': 'Example Track 2', + 'artist': 'Example Artist', + 'status': 'downloading', + 'progress': 0.5, + 'speed': 1.8, + 'eta': 120, + }, + ]; + _setLoadingDownloads(false); + } catch (e) { + _setError('Failed to load downloads: $e'); + _setLoadingDownloads(false); + } + } + + Future loadDownloadSettings() async { + _setLoadingUserInfo(true); + _clearError(); + + try { + // TODO: Implement actual settings loading from API + _downloadSettings = { + 'downloadPath': '/storage/emulated/0/Android/data/com.example.swingmusic/files/Downloads', + 'defaultQuality': '320kbps', + 'wifiOnly': false, + 'maxConcurrentDownloads': 3, + }; + _setLoadingUserInfo(false); + } catch (e) { + _setError('Failed to load download settings: $e'); + _setLoadingUserInfo(false); + } + } + + Future updateDownloadSettings(Map settings) async { + try { + // TODO: Implement actual settings update to API + _downloadSettings.addAll(settings); + } catch (e) { + _setError('Failed to update download settings: $e'); + } + } + + Future pauseDownload(String downloadId) async { + try { + // TODO: Implement actual pause via API + final index = _downloads.indexWhere((d) => d['downloadId'] == downloadId); + if (index != -1) { + _downloads[index] = {..._downloads[index], 'status': 'paused'}; + } + } catch (e) { + _setError('Failed to pause download: $e'); + } + } + + Future resumeDownload(String downloadId) async { + try { + // TODO: Implement actual resume via API + final index = _downloads.indexWhere((d) => d['downloadId'] == downloadId); + if (index != -1) { + _downloads[index] = {..._downloads[index], 'status': 'downloading'}; + } + } catch (e) { + _setError('Failed to resume download: $e'); + } + } + + Future cancelDownload(String downloadId) async { + try { + // TODO: Implement actual cancel via API + _downloads.removeWhere((d) => d['downloadId'] == downloadId); + } catch (e) { + _setError('Failed to cancel download: $e'); + } + } + + Future retryDownload(String downloadId) async { + try { + // TODO: Implement actual retry via API + final index = _downloads.indexWhere((d) => d['downloadId'] == downloadId); + if (index != -1) { + _downloads[index] = {..._downloads[index], 'status': 'downloading'}; + } + } catch (e) { + _setError('Failed to retry download: $e'); + } + } + + Future deleteDownload(String downloadId) async { + try { + // TODO: Implement actual delete via API + _downloads.removeWhere((d) => d['downloadId'] == downloadId); + } catch (e) { + _setError('Failed to delete download: $e'); + } + } + Future loadQueue() async { + _setLoadingQueue(true); + _clearError(); + + try { + _queue = await _apiService.getQueue(); + _setLoadingQueue(false); + } catch (e) { + _setError('Failed to load queue: $e'); + } + } + + Future addToQueue(String trackHash) async { + try { + await _apiService.addToQueue(trackHash); + + // Add to queue from tracks if available + final track = _tracks.firstWhere((t) => t.trackhash == trackHash); + if (track != null && !_queue.any((q) => q.trackhash == trackHash)) { + _queue.add(track); + } + + notifyListeners(); + } catch (e) { + _setError('Failed to add to queue: $e'); + } + } + + Future removeFromQueue(String trackHash) async { + try { + await _apiService.removeFromQueue(trackHash); + _queue.removeWhere((track) => track.trackhash == trackHash); + notifyListeners(); + } catch (e) { + _setError('Failed to remove from queue: $e'); + } + } + + Future clearQueue() async { + try { + await _apiService.clearQueue(); + _queue.clear(); + notifyListeners(); + } catch (e) { + _setError('Failed to clear queue: $e'); + } + } + + Future reorderQueue(List trackHashes) async { + try { + await _apiService.reorderQueue(trackHashes); + + // Reorder local queue + final reorderedQueue = []; + for (final hash in trackHashes) { + final track = _queue.firstWhere((t) => t.trackhash == hash); + if (track != null) { + reorderedQueue.add(track); + } + } + _queue = reorderedQueue; + notifyListeners(); + } catch (e) { + _setError('Failed to reorder queue: $e'); + } + } + + // Private helper methods + void _setLoadingTracks(bool loading) { + _isLoadingTracks = loading; + notifyListeners(); + } + + void _setLoadingAlbums(bool loading) { + _isLoadingAlbums = loading; + notifyListeners(); + } + + void _setLoadingArtists(bool loading) { + _isLoadingArtists = loading; + notifyListeners(); + } + + void _setLoadingPlaylists(bool loading) { + _isLoadingPlaylists = loading; + notifyListeners(); + } + + void _setLoadingFolders(bool loading) { + _isLoadingFolders = loading; + notifyListeners(); + } + + void _setLoadingUserInfo(bool loading) { + _isLoadingUserInfo = loading; + notifyListeners(); + } + + void _setLoadingStatistics(bool loading) { + _isLoadingStatistics = loading; + notifyListeners(); + } + + void _setLoadingFavorites(bool loading) { + _isLoadingFavorites = loading; + notifyListeners(); + } + + void _setLoadingQueue(bool loading) { + _isLoadingQueue = loading; + notifyListeners(); + } + + void _clearError() { + _error = null; + notifyListeners(); + } + + void _setError(String error) { + _error = error; + notifyListeners(); + } +} diff --git a/swingmusic_mobile/lib/shared/providers/library_provider.dart b/swingmusic_mobile/lib/shared/providers/library_provider.dart new file mode 100644 index 00000000..fa923adb --- /dev/null +++ b/swingmusic_mobile/lib/shared/providers/library_provider.dart @@ -0,0 +1,297 @@ +import 'package:flutter/foundation.dart'; +import '../../data/services/api_service.dart'; +import '../../data/models/track_model.dart'; +import '../../data/models/album_model.dart'; +import '../../data/models/playlist_model.dart'; + +class LibraryProvider extends ChangeNotifier { + final ApiService _apiService = ApiService(); + + // Library data + List _tracks = []; + List _albums = []; + List _artists = []; + List _playlists = []; + List _favoriteTracks = []; + List _favoriteAlbums = []; + List _favoriteArtists = []; + + // Loading states + bool _isLoadingTracks = false; + bool _isLoadingAlbums = false; + bool _isLoadingArtists = false; + bool _isLoadingPlaylists = false; + bool _isLoadingFavorites = false; + + // Search state + List _searchResults = []; + bool _isSearching = false; + String _searchQuery = ''; + + // Getters + List get tracks => _tracks; + List get albums => _albums; + List get artists => _artists; + List get playlists => _playlists; + List get favoriteTracks => _favoriteTracks; + List get favoriteAlbums => _favoriteAlbums; + List get favoriteArtists => _favoriteArtists; + + bool get isLoadingTracks => _isLoadingTracks; + bool get isLoadingAlbums => _isLoadingAlbums; + bool get isLoadingArtists => _isLoadingArtists; + bool get isLoadingPlaylists => _isLoadingPlaylists; + bool get isLoadingFavorites => _isLoadingFavorites; + + List get searchResults => _searchResults; + bool get isSearching => _isSearching; + String get searchQuery => _searchQuery; + + // Tracks operations + Future loadTracks({int limit = 20, int offset = 0}) async { + try { + _isLoadingTracks = true; + notifyListeners(); + + final response = await _apiService.getTracks(limit: limit, offset: offset); + _tracks = response.map((json) => TrackModel.fromJson(json)).toList(); + + _isLoadingTracks = false; + notifyListeners(); + } catch (e) { + _isLoadingTracks = false; + notifyListeners(); + throw Exception('Failed to load tracks: $e'); + } + } + + Future loadMoreTracks({int limit = 20}) async { + try { + final response = await _apiService.getTracks(limit: limit, offset: _tracks.length); + final newTracks = response.map((json) => TrackModel.fromJson(json)).toList(); + _tracks.addAll(newTracks); + notifyListeners(); + } catch (e) { + throw Exception('Failed to load more tracks: $e'); + } + } + + // Albums operations + Future loadAlbums({int limit = 20, int offset = 0}) async { + try { + _isLoadingAlbums = true; + notifyListeners(); + + final response = await _apiService.getAlbums(limit: limit, offset: offset); + _albums = response.map((json) => AlbumModel.fromJson(json)).toList(); + + _isLoadingAlbums = false; + notifyListeners(); + } catch (e) { + _isLoadingAlbums = false; + notifyListeners(); + throw Exception('Failed to load albums: $e'); + } + } + + Future loadMoreAlbums({int limit = 20}) async { + try { + final response = await _apiService.getAlbums(limit: limit, offset: _albums.length); + final newAlbums = response.map((json) => AlbumModel.fromJson(json)).toList(); + _albums.addAll(newAlbums); + notifyListeners(); + } catch (e) { + throw Exception('Failed to load more albums: $e'); + } + } + + // Artists operations + Future loadArtists({int limit = 20, int offset = 0}) async { + try { + _isLoadingArtists = true; + notifyListeners(); + + final response = await _apiService.getArtists(limit: limit, offset: offset); + _artists = response.map((json) => ArtistModel.fromJson(json)).toList(); + + _isLoadingArtists = false; + notifyListeners(); + } catch (e) { + _isLoadingArtists = false; + notifyListeners(); + throw Exception('Failed to load artists: $e'); + } + } + + Future loadMoreArtists({int limit = 20}) async { + try { + final response = await _apiService.getArtists(limit: limit, offset: _artists.length); + final newArtists = response.map((json) => ArtistModel.fromJson(json)).toList(); + _artists.addAll(newArtists); + notifyListeners(); + } catch (e) { + throw Exception('Failed to load more artists: $e'); + } + } + + // Playlists operations + Future loadPlaylists() async { + try { + _isLoadingPlaylists = true; + notifyListeners(); + + final response = await _apiService.getPlaylists(); + _playlists = response.map((json) => PlaylistModel.fromJson(json)).toList(); + + _isLoadingPlaylists = false; + notifyListeners(); + } catch (e) { + _isLoadingPlaylists = false; + notifyListeners(); + throw Exception('Failed to load playlists: $e'); + } + } + + Future createPlaylist(String name, {String description = ''}) async { + try { + final response = await _apiService.createPlaylist(name, description: description); + final newPlaylist = PlaylistModel.fromJson(response); + _playlists.add(newPlaylist); + notifyListeners(); + return newPlaylist; + } catch (e) { + throw Exception('Failed to create playlist: $e'); + } + } + + // Favorites operations + Future loadFavorites() async { + try { + _isLoadingFavorites = true; + notifyListeners(); + + final tracksResponse = await _apiService.getFavoriteTracks(); + final albumsResponse = await _apiService.getFavoriteAlbums(); + final artistsResponse = await _apiService.getFavoriteArtists(); + + _favoriteTracks = tracksResponse.map((json) => TrackModel.fromJson(json)).toList(); + _favoriteAlbums = albumsResponse.map((json) => AlbumModel.fromJson(json)).toList(); + _favoriteArtists = artistsResponse.map((json) => ArtistModel.fromJson(json)).toList(); + + _isLoadingFavorites = false; + notifyListeners(); + } catch (e) { + _isLoadingFavorites = false; + notifyListeners(); + throw Exception('Failed to load favorites: $e'); + } + } + + Future toggleFavoriteTrack(String trackhash) async { + try { + await _apiService.toggleFavoriteTrack(trackhash); + + // Update local state + final trackIndex = _favoriteTracks.indexWhere((track) => track.trackhash == trackhash); + if (trackIndex != -1) { + _favoriteTracks.removeAt(trackIndex); + } else { + final track = _tracks.firstWhere((t) => t.trackhash == trackhash); + _favoriteTracks.add(track); + } + notifyListeners(); + } catch (e) { + throw Exception('Failed to toggle favorite track: $e'); + } + } + + Future toggleFavoriteAlbum(String albumhash) async { + try { + await _apiService.toggleFavoriteAlbum(albumhash); + + // Update local state + final albumIndex = _favoriteAlbums.indexWhere((album) => album.albumhash == albumhash); + if (albumIndex != -1) { + _favoriteAlbums.removeAt(albumIndex); + } else { + final album = _albums.firstWhere((a) => a.albumhash == albumhash); + _favoriteAlbums.add(album); + } + notifyListeners(); + } catch (e) { + throw Exception('Failed to toggle favorite album: $e'); + } + } + + Future toggleFavoriteArtist(String artisthash) async { + try { + await _apiService.toggleFavoriteArtist(artisthash); + + // Update local state + final artistIndex = _favoriteArtists.indexWhere((artist) => artist.artisthash == artisthash); + if (artistIndex != -1) { + _favoriteArtists.removeAt(artistIndex); + } else { + final artist = _artists.firstWhere((a) => a.artisthash == artisthash); + _favoriteArtists.add(artist); + } + notifyListeners(); + } catch (e) { + throw Exception('Failed to toggle favorite artist: $e'); + } + } + + // Search operations + Future searchTracks(String query, {int limit = 15}) async { + if (query.isEmpty) { + _searchResults.clear(); + _searchQuery = ''; + notifyListeners(); + return; + } + + try { + _isSearching = true; + _searchQuery = query; + notifyListeners(); + + final response = await _apiService.searchTracks(query, limit: limit); + _searchResults = response.map((json) => TrackModel.fromJson(json)).toList(); + + _isSearching = false; + notifyListeners(); + } catch (e) { + _isSearching = false; + notifyListeners(); + throw Exception('Failed to search tracks: $e'); + } + } + + void clearSearch() { + _searchResults.clear(); + _searchQuery = ''; + _isSearching = false; + notifyListeners(); + } + + // Utility methods + void refresh() { + loadTracks(); + loadAlbums(); + loadArtists(); + loadPlaylists(); + loadFavorites(); + } + + bool isTrackFavorite(String trackhash) { + return _favoriteTracks.any((track) => track.trackhash == trackhash); + } + + bool isAlbumFavorite(String albumhash) { + return _favoriteAlbums.any((album) => album.albumhash == albumhash); + } + + bool isArtistFavorite(String artisthash) { + return _favoriteArtists.any((artist) => artist.artisthash == artisthash); + } +} diff --git a/swingmusic_mobile/lib/shared/routes/app_router.dart b/swingmusic_mobile/lib/shared/routes/app_router.dart new file mode 100644 index 00000000..bb534706 --- /dev/null +++ b/swingmusic_mobile/lib/shared/routes/app_router.dart @@ -0,0 +1,95 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import '../../features/player/enhanced_player_screen_new.dart'; +import '../../features/library/library_screen.dart'; +import '../../features/search/search_screen.dart'; +import '../../features/playlists/playlists_screen.dart'; +import '../../features/settings/enhanced_settings_screen.dart'; +import '../../features/auth/enhanced_auth_screen.dart'; +import '../../features/downloads/downloads_screen.dart'; +import '../../features/analytics/analytics_screen.dart'; +import '../../features/home/home_screen.dart'; +import '../widgets/main_navigation.dart'; +import '../../core/constants/app_constants.dart'; + +class AppRouter { + static final GoRouter _router = GoRouter( + initialLocation: AppConstants.homeRoute, + routes: [ + ShellRoute( + builder: (context, state, child) { + return MainNavigation(child: child); + }, + routes: [ + GoRoute( + path: AppConstants.homeRoute, + name: 'home', + builder: (context, state) => const HomeScreen(), + ), + GoRoute( + path: AppConstants.libraryRoute, + name: 'library', + builder: (context, state) => const LibraryScreen(), + ), + GoRoute( + path: AppConstants.playerRoute, + name: 'player', + builder: (context, state) => const EnhancedPlayerScreen(), + ), + GoRoute( + path: AppConstants.searchRoute, + name: 'search', + builder: (context, state) => const SearchScreen(), + ), + GoRoute( + path: AppConstants.playlistsRoute, + name: 'playlists', + builder: (context, state) => const PlaylistsScreen(), + ), + GoRoute( + path: AppConstants.authRoute, + name: 'auth', + builder: (context, state) => const EnhancedAuthScreen(), + ), + GoRoute( + path: '/downloads', + name: 'downloads', + builder: (context, state) => const DownloadsScreen(), + ), + GoRoute( + path: AppConstants.analyticsRoute, + name: 'analytics', + builder: (context, state) => const AnalyticsScreen(), + ), + GoRoute( + path: AppConstants.settingsRoute, + name: 'settings', + builder: (context, state) => const EnhancedSettingsScreen(), + ), + ], + ), + ], + errorBuilder: (context, state) => Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Icons.error_outline, + size: 64, + color: Colors.red, + ), + const SizedBox(height: 16), + Text( + 'Page not found: ${state.uri}', + style: const TextStyle(fontSize: 18), + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + ); + + static GoRouter get router => _router; +} diff --git a/swingmusic_mobile/lib/shared/widgets/main_navigation.dart b/swingmusic_mobile/lib/shared/widgets/main_navigation.dart new file mode 100644 index 00000000..ca4f4f52 --- /dev/null +++ b/swingmusic_mobile/lib/shared/widgets/main_navigation.dart @@ -0,0 +1,135 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import '../../core/constants/app_constants.dart'; +import '../../core/constants/app_icons.dart'; +import '../../core/widgets/mini_player.dart'; + +class MainNavigation extends StatefulWidget { + final Widget child; + + const MainNavigation({ + super.key, + required this.child, + }); + + @override + State createState() => _MainNavigationState(); +} + +class _MainNavigationState extends State { + int _currentIndex = 0; + + final List _navigationItems = [ + NavigationItem( + icon: AppIcons.home, + selectedIcon: AppIcons.homeFilled, + label: 'Home', + route: AppConstants.homeRoute, + ), + NavigationItem( + icon: AppIcons.search, + selectedIcon: AppIcons.searchFilled, + label: 'Search', + route: AppConstants.searchRoute, + ), + NavigationItem( + icon: AppIcons.library, + selectedIcon: AppIcons.libraryFilled, + label: 'Library', + route: AppConstants.libraryRoute, + ), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Expanded( + child: widget.child, + ), + const MiniPlayer(), + ], + ), + bottomNavigationBar: Container( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + boxShadow: [ + BoxShadow( + color: Theme.of(context).shadowColor.withValues(alpha: 0.1), + blurRadius: 8, + offset: const Offset(0, -2), + ), + ], + ), + child: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: _navigationItems.map((item) { + final isSelected = _currentIndex == _navigationItems.indexOf(item); + return Expanded( + child: InkWell( + onTap: () => _onItemTapped(_navigationItems.indexOf(item)), + borderRadius: BorderRadius.circular(8), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + isSelected ? item.selectedIcon : item.icon, + color: isSelected + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.6), + size: 24, + ), + const SizedBox(height: 4), + Text( + item.label, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: isSelected + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.6), + fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500, + fontSize: 12, + ), + ), + ], + ), + ), + ), + ); + }).toList(), + ), + ), + ), + ), + ); + } + + void _onItemTapped(int index) { + final item = _navigationItems[index]; + if (_currentIndex != index) { + setState(() { + _currentIndex = index; + }); + context.go(item.route); + } + } +} + +class NavigationItem { + final IconData icon; + final IconData selectedIcon; + final String label; + final String route; + + NavigationItem({ + required this.icon, + required this.selectedIcon, + required this.label, + required this.route, + }); +} diff --git a/swingmusic_mobile/linux/.gitignore b/swingmusic_mobile/linux/.gitignore new file mode 100644 index 00000000..d3896c98 --- /dev/null +++ b/swingmusic_mobile/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/swingmusic_mobile/linux/CMakeLists.txt b/swingmusic_mobile/linux/CMakeLists.txt new file mode 100644 index 00000000..162ab2a1 --- /dev/null +++ b/swingmusic_mobile/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 "swingmusic_mobile") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.dvorinka.swingmusic.swingmusic_mobile") + +# 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/swingmusic_mobile/linux/flutter/CMakeLists.txt b/swingmusic_mobile/linux/flutter/CMakeLists.txt new file mode 100644 index 00000000..d5bd0164 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/linux/runner/CMakeLists.txt b/swingmusic_mobile/linux/runner/CMakeLists.txt new file mode 100644 index 00000000..e97dabc7 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/linux/runner/main.cc b/swingmusic_mobile/linux/runner/main.cc new file mode 100644 index 00000000..e7c5c543 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/linux/runner/my_application.cc b/swingmusic_mobile/linux/runner/my_application.cc new file mode 100644 index 00000000..935100f2 --- /dev/null +++ b/swingmusic_mobile/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, "swingmusic_mobile"); + 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, "swingmusic_mobile"); + } + + 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/swingmusic_mobile/linux/runner/my_application.h b/swingmusic_mobile/linux/runner/my_application.h new file mode 100644 index 00000000..db16367a --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/.gitignore b/swingmusic_mobile/macos/.gitignore new file mode 100644 index 00000000..746adbb6 --- /dev/null +++ b/swingmusic_mobile/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/swingmusic_mobile/macos/Flutter/Flutter-Debug.xcconfig b/swingmusic_mobile/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 00000000..c2efd0b6 --- /dev/null +++ b/swingmusic_mobile/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/swingmusic_mobile/macos/Flutter/Flutter-Release.xcconfig b/swingmusic_mobile/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 00000000..c2efd0b6 --- /dev/null +++ b/swingmusic_mobile/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/swingmusic_mobile/macos/Flutter/GeneratedPluginRegistrant.swift b/swingmusic_mobile/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 00000000..b4eac62c --- /dev/null +++ b/swingmusic_mobile/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,18 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import audio_session +import flutter_media_metadata +import just_audio +import shared_preferences_foundation + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) + FlutterMediaMetadataPlugin.register(with: registry.registrar(forPlugin: "FlutterMediaMetadataPlugin")) + JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) +} diff --git a/swingmusic_mobile/macos/Runner.xcodeproj/project.pbxproj b/swingmusic_mobile/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..19537b59 --- /dev/null +++ b/swingmusic_mobile/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 /* swingmusic_mobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swingmusic_mobile.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 /* swingmusic_mobile.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 /* swingmusic_mobile.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.dvorinka.swingmusic.swingmusicMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swingmusic_mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/swingmusic_mobile"; + }; + 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.dvorinka.swingmusic.swingmusicMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swingmusic_mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/swingmusic_mobile"; + }; + 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.dvorinka.swingmusic.swingmusicMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swingmusic_mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/swingmusic_mobile"; + }; + 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/swingmusic_mobile/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/swingmusic_mobile/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/swingmusic_mobile/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/swingmusic_mobile/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/swingmusic_mobile/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..9eb9a259 --- /dev/null +++ b/swingmusic_mobile/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swingmusic_mobile/macos/Runner.xcworkspace/contents.xcworkspacedata b/swingmusic_mobile/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/swingmusic_mobile/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/swingmusic_mobile/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/swingmusic_mobile/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/swingmusic_mobile/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/swingmusic_mobile/macos/Runner/AppDelegate.swift b/swingmusic_mobile/macos/Runner/AppDelegate.swift new file mode 100644 index 00000000..b3c17614 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..a2ec33f1 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 00000000..82b6f9d9 Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 00000000..13b35eba Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 00000000..0a3f5fa4 Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 00000000..bdb57226 Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 00000000..f083318e Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 00000000..326c0e72 Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 00000000..2f1632cf Binary files /dev/null and b/swingmusic_mobile/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/swingmusic_mobile/macos/Runner/Base.lproj/MainMenu.xib b/swingmusic_mobile/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..80e867a4 --- /dev/null +++ b/swingmusic_mobile/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swingmusic_mobile/macos/Runner/Configs/AppInfo.xcconfig b/swingmusic_mobile/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 00000000..4a0512d1 --- /dev/null +++ b/swingmusic_mobile/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 = swingmusic_mobile + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.dvorinka.swingmusic.swingmusicMobile + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2026 com.dvorinka.swingmusic. All rights reserved. diff --git a/swingmusic_mobile/macos/Runner/Configs/Debug.xcconfig b/swingmusic_mobile/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 00000000..36b0fd94 --- /dev/null +++ b/swingmusic_mobile/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/swingmusic_mobile/macos/Runner/Configs/Release.xcconfig b/swingmusic_mobile/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 00000000..dff4f495 --- /dev/null +++ b/swingmusic_mobile/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/swingmusic_mobile/macos/Runner/Configs/Warnings.xcconfig b/swingmusic_mobile/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 00000000..42bcbf47 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/Runner/DebugProfile.entitlements b/swingmusic_mobile/macos/Runner/DebugProfile.entitlements new file mode 100644 index 00000000..dddb8a30 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/Runner/Info.plist b/swingmusic_mobile/macos/Runner/Info.plist new file mode 100644 index 00000000..4789daa6 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/Runner/MainFlutterWindow.swift b/swingmusic_mobile/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 00000000..3cc05eb2 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/macos/Runner/Release.entitlements b/swingmusic_mobile/macos/Runner/Release.entitlements new file mode 100644 index 00000000..852fa1a4 --- /dev/null +++ b/swingmusic_mobile/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/swingmusic_mobile/macos/RunnerTests/RunnerTests.swift b/swingmusic_mobile/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..61f3bd1f --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/pubspec.lock b/swingmusic_mobile/pubspec.lock new file mode 100644 index 00000000..880668d6 --- /dev/null +++ b/swingmusic_mobile/pubspec.lock @@ -0,0 +1,999 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + url: "https://pub.dev" + source: hosted + version: "67.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + url: "https://pub.dev" + source: hosted + version: "6.4.1" + archive: + dependency: transitive + description: + name: archive + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" + source: hosted + version: "3.6.1" + 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: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + audio_session: + dependency: "direct main" + 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" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: bf05f6e12cfea92d3c09308d7bcdab1906cd8a179b023269eed00c071004b957 + url: "https://pub.dev" + source: hosted + version: "4.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" + url: "https://pub.dev" + source: hosted + version: "2.4.13" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 + url: "https://pub.dev" + source: hosted + version: "7.3.2" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: "6ae8a6435a8c6520c7077b107e77f1fb4ba7009633259a4d49a8afd8e7efc5e9" + url: "https://pub.dev" + source: hosted + version: "8.12.4" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + 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" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "6a6cab2ba4680d6423f34a9b972a4c9a94ebe1b62ecec4e1a1f2cba91fd1319d" + url: "https://pub.dev" + source: hosted + version: "4.11.1" + 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" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + url: "https://pub.dev" + source: hosted + version: "2.3.6" + dio: + dependency: "direct main" + description: + name: dio + sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c + url: "https://pub.dev" + source: hosted + version: "5.9.2" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "2f9e64323a7c3c7ef69567d5c800424a11f8337b8b228bad02524c9fb3c1f340" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: "3e0141505477fd8ad55d6eb4e7776d3fe8430be8e497ccb1521370c3f21a3e2b" + url: "https://pub.dev" + source: hosted + version: "2.0.8" + 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" + 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_audio_waveforms: + dependency: "direct main" + description: + name: flutter_audio_waveforms + sha256: "425dda9ee5ef9bb2ff2a2000b19ec595593b3baba6a1274da8d1d729846a144b" + url: "https://pub.dev" + source: hosted + version: "1.2.1+8" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_media_metadata: + dependency: "direct main" + description: + name: flutter_media_metadata + sha256: "69cfc76ffd6cd5d546dcc4880584b3844c5e879e435aa54f57f1096c15bd04db" + url: "https://pub.dev" + source: hosted + version: "1.0.0+1" + 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" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.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: c5fa45fa502ee880839e3b2152d987c44abae26d064a2376d4aad434cf0f7b15 + url: "https://pub.dev" + source: hosted + version: "12.1.3" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + hive: + dependency: transitive + description: + name: hive + sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941" + url: "https://pub.dev" + source: hosted + version: "2.2.3" + hive_flutter: + dependency: "direct main" + description: + name: hive_flutter + sha256: dca1da446b1d808a51689fb5d0c6c9510c0a2ba01e22805d492c73b68e33eecc + url: "https://pub.dev" + source: hosted + version: "1.1.0" + hive_generator: + dependency: "direct dev" + description: + name: hive_generator + sha256: "06cb8f58ace74de61f63500564931f9505368f45f98958bd7a6c35ba24159db4" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + hooks: + dependency: transitive + description: + name: hooks + sha256: e79ed1e8e1929bc6ecb6ec85f0cb519c887aa5b423705ded0d0f2d9226def388 + url: "https://pub.dev" + source: hosted + version: "1.0.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + url: "https://pub.dev" + source: hosted + version: "0.20.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + url: "https://pub.dev" + source: hosted + version: "6.8.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" + 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" + lottie: + dependency: "direct main" + description: + name: lottie + sha256: a93542cc2d60a7057255405f62252533f8e8956e7e06754955669fd32fb4b216 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + 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" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" + url: "https://pub.dev" + source: hosted + version: "9.3.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: "direct main" + 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: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e + url: "https://pub.dev" + source: hosted + version: "2.2.22" + 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" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + sha256: "59adad729136f01ea9e35a48f5d1395e25cba6cea552249ddbe9cf950f5d7849" + url: "https://pub.dev" + source: hosted + version: "11.4.0" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + sha256: d3971dcdd76182a0c198c096b5db2f0884b0d4196723d21a866fc4cdea057ebc + url: "https://pub.dev" + source: hosted + version: "12.1.0" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + sha256: f000131e755c54cf4d84a5d8bd6e4149e262cc31c5a8b1d698de1ac85fa41023 + url: "https://pub.dev" + source: hosted + version: "9.4.7" + permission_handler_html: + dependency: transitive + description: + name: permission_handler_html + sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24" + url: "https://pub.dev" + source: hosted + version: "0.1.3+5" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + sha256: eb99b295153abce5d683cac8c02e22faab63e50679b937fa1bf67d58bb282878 + url: "https://pub.dev" + source: hosted + version: "4.3.0" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e" + url: "https://pub.dev" + source: hosted + version: "0.2.1" + 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" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + provider: + dependency: "direct main" + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + retrofit: + dependency: "direct main" + description: + name: retrofit + sha256: "0f629ed26b2c48c66fe54bd548313c6fdf7955be18bff37e08a46dd3f97f8eaf" + url: "https://pub.dev" + source: hosted + version: "4.9.2" + retrofit_generator: + dependency: "direct dev" + description: + name: retrofit_generator + sha256: "9499eb46b3657a62192ddbc208ff7e6c6b768b19e83c1ee6f6b119c864b99690" + url: "https://pub.dev" + source: hosted + version: "7.0.8" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" + url: "https://pub.dev" + source: hosted + version: "0.28.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "8374d6200ab33ac99031a852eba4c8eb2170c4bf20778b3e2c9eccb45384fb41" + url: "https://pub.dev" + source: hosted + version: "2.4.21" + 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: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + 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" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" + url: "https://pub.dev" + source: hosted + version: "1.3.5" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0 + url: "https://pub.dev" + source: hosted + version: "3.4.0" + 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: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + timing: + dependency: transitive + description: + name: timing + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" + source: hosted + version: "2.0.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + uuid: + dependency: "direct main" + 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: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + watcher: + dependency: transitive + description: + name: watcher + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + 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" + workmanager: + dependency: "direct main" + description: + name: workmanager + sha256: ed13530cccd28c5c9959ad42d657cd0666274ca74c56dea0ca183ddd527d3a00 + url: "https://pub.dev" + source: hosted + version: "0.5.2" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.10.4 <4.0.0" + flutter: ">=3.38.4" diff --git a/swingmusic_mobile/pubspec.yaml b/swingmusic_mobile/pubspec.yaml new file mode 100644 index 00000000..59bdd659 --- /dev/null +++ b/swingmusic_mobile/pubspec.yaml @@ -0,0 +1,69 @@ +name: swingmusic_mobile +description: "SwingMusic Mobile - Flutter cross-platform music player" + +publish_to: 'none' + +version: 1.0.0+1 + +environment: + sdk: ^3.10.4 + +dependencies: + flutter: + sdk: flutter + flutter_localizations: + sdk: flutter + provider: ^6.1.1 + go_router: ^12.1.3 + just_audio: ^0.9.46 + audio_session: ^0.1.25 + permission_handler: ^11.4.0 + path_provider: ^2.1.1 + shared_preferences: ^2.2.2 + dio: ^5.3.2 + retrofit: ^4.0.1 + json_annotation: ^4.8.1 + lottie: ^2.7.0 + hive_flutter: ^1.1.0 + + # Media & Metadata + flutter_media_metadata: ^1.0.0 + + # Visualizations + flutter_audio_waveforms: ^1.2.0 + + # Background Processing + workmanager: ^0.5.2 + + # UI Components + cupertino_icons: ^1.0.8 + + # Additional Utilities + equatable: ^2.0.5 + uuid: ^4.2.1 + intl: ^0.20.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # Linting + flutter_lints: ^6.0.0 + + # Code Generation + retrofit_generator: ^7.0.8 + json_serializable: ^6.7.1 + hive_generator: ^2.0.1 + build_runner: ^2.4.7 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + uses-material-design: true + + assets: + - assets/images/ + - assets/audio/ diff --git a/swingmusic_mobile/test/widget_test.dart b/swingmusic_mobile/test/widget_test.dart new file mode 100644 index 00000000..71792436 --- /dev/null +++ b/swingmusic_mobile/test/widget_test.dart @@ -0,0 +1,21 @@ +// 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:swingmusic_mobile/main.dart'; + +void main() { + testWidgets('SwingMusic App smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const SwingMusicApp()); + + // Verify that the app loads + expect(find.byType(MaterialApp), findsOneWidget); + }); +} diff --git a/swingmusic_mobile/windows/.gitignore b/swingmusic_mobile/windows/.gitignore new file mode 100644 index 00000000..d492d0d9 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/CMakeLists.txt b/swingmusic_mobile/windows/CMakeLists.txt new file mode 100644 index 00000000..a72f5c29 --- /dev/null +++ b/swingmusic_mobile/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(swingmusic_mobile 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 "swingmusic_mobile") + +# 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/swingmusic_mobile/windows/flutter/CMakeLists.txt b/swingmusic_mobile/windows/flutter/CMakeLists.txt new file mode 100644 index 00000000..903f4899 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/CMakeLists.txt b/swingmusic_mobile/windows/runner/CMakeLists.txt new file mode 100644 index 00000000..394917c0 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/Runner.rc b/swingmusic_mobile/windows/runner/Runner.rc new file mode 100644 index 00000000..cdc00f58 --- /dev/null +++ b/swingmusic_mobile/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.dvorinka.swingmusic" "\0" + VALUE "FileDescription", "swingmusic_mobile" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "swingmusic_mobile" "\0" + VALUE "LegalCopyright", "Copyright (C) 2026 com.dvorinka.swingmusic. All rights reserved." "\0" + VALUE "OriginalFilename", "swingmusic_mobile.exe" "\0" + VALUE "ProductName", "swingmusic_mobile" "\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/swingmusic_mobile/windows/runner/flutter_window.cpp b/swingmusic_mobile/windows/runner/flutter_window.cpp new file mode 100644 index 00000000..955ee303 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/flutter_window.h b/swingmusic_mobile/windows/runner/flutter_window.h new file mode 100644 index 00000000..6da0652f --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/main.cpp b/swingmusic_mobile/windows/runner/main.cpp new file mode 100644 index 00000000..3aded592 --- /dev/null +++ b/swingmusic_mobile/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"swingmusic_mobile", 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/swingmusic_mobile/windows/runner/resource.h b/swingmusic_mobile/windows/runner/resource.h new file mode 100644 index 00000000..66a65d1e --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/resources/app_icon.ico b/swingmusic_mobile/windows/runner/resources/app_icon.ico new file mode 100644 index 00000000..c04e20ca Binary files /dev/null and b/swingmusic_mobile/windows/runner/resources/app_icon.ico differ diff --git a/swingmusic_mobile/windows/runner/runner.exe.manifest b/swingmusic_mobile/windows/runner/runner.exe.manifest new file mode 100644 index 00000000..153653e8 --- /dev/null +++ b/swingmusic_mobile/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/swingmusic_mobile/windows/runner/utils.cpp b/swingmusic_mobile/windows/runner/utils.cpp new file mode 100644 index 00000000..3a0b4651 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/utils.h b/swingmusic_mobile/windows/runner/utils.h new file mode 100644 index 00000000..3879d547 --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/win32_window.cpp b/swingmusic_mobile/windows/runner/win32_window.cpp new file mode 100644 index 00000000..60608d0f --- /dev/null +++ b/swingmusic_mobile/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/swingmusic_mobile/windows/runner/win32_window.h b/swingmusic_mobile/windows/runner/win32_window.h new file mode 100644 index 00000000..e901dde6 --- /dev/null +++ b/swingmusic_mobile/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_