-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preliminary views for Mythic Harmony
- Loading branch information
1 parent
c2820dd
commit 24028b5
Showing
12 changed files
with
223 additions
and
3 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Mythic/Assets.xcassets/Harmony+AppIcon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Mythic + Harmony.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "Mythic + Harmony@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "Mythic + Harmony@3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.76 MB
Mythic/Assets.xcassets/Harmony+AppIcon.imageset/Mythic + Harmony@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.79 MB
Mythic/Assets.xcassets/Harmony+AppIcon.imageset/Mythic + Harmony@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Harmony Logo.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "Harmony Logo@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "Harmony Logo@3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// StarRatingView.swift | ||
// Mythic | ||
// | ||
// Created by vapidinfinity (esi) on 16/1/2025. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
struct StarRatingView: View { | ||
@Binding var rating: Int | ||
@Binding var hoveringOverIndex: Int | ||
@State var isInteractive: Bool = true | ||
|
||
var body: some View { | ||
HStack { | ||
ForEach(1..<6) { index in | ||
Image(systemName: "star") | ||
.symbolVariant(hoveringOverIndex >= index ? .fill : .none) | ||
.shadow(color: .secondary, radius: hoveringOverIndex == index ? 10 : 0) | ||
.onHover { hovering in | ||
if isInteractive { | ||
withAnimation { | ||
hoveringOverIndex = hovering ? index : hoveringOverIndex | ||
} | ||
} | ||
} | ||
.onTapGesture { | ||
if isInteractive { | ||
withAnimation { | ||
rating = index | ||
} | ||
} | ||
} | ||
} | ||
} | ||
.onAppear { | ||
withAnimation { | ||
hoveringOverIndex = rating | ||
} | ||
} | ||
.onHover { hovering in | ||
withAnimation { | ||
hoveringOverIndex = hovering ? hoveringOverIndex : rating | ||
} | ||
} | ||
.imageScale(.large) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// HarmonyRatingView.swift | ||
// Mythic | ||
// | ||
// Created by vapidinfinity (esi) on 16/1/2025. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
struct HarmonyRatingView: View { | ||
@Binding var isPresented: Bool | ||
@Binding var game: Game | ||
|
||
@State private var rating: Game.Compatibility? | ||
@State private var hoveringOverIndex: Int = 0 | ||
|
||
@State private var isConfirmationPresented: Bool = false | ||
|
||
@State private var isUploading: Bool = false | ||
|
||
func uploadCompatibilityData() { | ||
withAnimation { isUploading = true } | ||
|
||
// TODO: handle upload w/ UUID of Mythic spam protection and whatnot | ||
|
||
// TODO: if success | ||
isPresented = false | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
Text("How well did \"\(game.title)\" run?") | ||
.font(.title) | ||
|
||
Text("This will be uploaded to Harmony, Mythic's game compatibility database.") | ||
.foregroundStyle(.placeholder) | ||
} | ||
.padding() | ||
.fixedSize() | ||
|
||
StarRatingView( | ||
rating: .init( | ||
get: { rating.flatMap { Game.Compatibility.allCases.firstIndex(of: $0).map { $0 + 1 } } ?? 0 }, | ||
set: { rating = Game.Compatibility.allCases[$0 - 1] } | ||
), | ||
hoveringOverIndex: $hoveringOverIndex | ||
) | ||
|
||
Form { | ||
if hoveringOverIndex > 0 { | ||
Text(Game.Compatibility.allCases[hoveringOverIndex - 1].rawValue) | ||
} else { | ||
Text("Please choose a rating.") | ||
} | ||
} | ||
.formStyle(.grouped) | ||
|
||
HStack { | ||
Button("Cancel", role: .cancel) { | ||
isConfirmationPresented = true | ||
} | ||
.alert(isPresented: $isConfirmationPresented) { | ||
Alert( | ||
title: .init("Are you sure you want to proceed without rating?"), | ||
message: .init("Harmony ratings help every Mythic user understand how well a game runs."), | ||
primaryButton: .cancel(), | ||
secondaryButton: .default(.init("OK")) { | ||
isPresented = false | ||
} | ||
) | ||
} | ||
|
||
Spacer() | ||
|
||
HStack { | ||
if isUploading { | ||
ProgressView() | ||
.controlSize(.small) | ||
.padding(0.5) | ||
} | ||
|
||
Button("Done") { | ||
uploadCompatibilityData() | ||
} | ||
.buttonStyle(.borderedProminent) | ||
.disabled(rating == nil) | ||
} | ||
} | ||
.padding([.horizontal, .bottom]) | ||
} | ||
} | ||
|
||
#Preview { | ||
Color.clear | ||
.sheet(isPresented: .constant(true)) { | ||
HarmonyRatingView( | ||
isPresented: .constant(true), | ||
game: .constant(.init(source: .epic, title: "poop"))) | ||
} | ||
} |