|
|
|
@ -8,37 +8,6 @@ |
|
|
|
import SwiftUI |
|
|
|
import SwiftUI |
|
|
|
import LeStorage |
|
|
|
import LeStorage |
|
|
|
|
|
|
|
|
|
|
|
struct ArrowView: View { |
|
|
|
|
|
|
|
var direction: ArrowDirection // Enum for left or right direction |
|
|
|
|
|
|
|
var isActive: Bool // Whether the arrow is visible |
|
|
|
|
|
|
|
var color: Color |
|
|
|
|
|
|
|
@State private var isAnimating = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum ArrowDirection { |
|
|
|
|
|
|
|
case left, right |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
|
|
Image(systemName: direction == .left ? "arrow.left" : "arrow.right") |
|
|
|
|
|
|
|
.font(.title) |
|
|
|
|
|
|
|
.foregroundColor(isActive ? color : .clear) // Arrow visible only when active |
|
|
|
|
|
|
|
.opacity(isAnimating ? 1.0 : 0.4) // Animate opacity between 1.0 and 0.4 |
|
|
|
|
|
|
|
.offset(x: isAnimating ? (direction == .left ? -5 : 5) : 0) // Slight left/right movement |
|
|
|
|
|
|
|
.animation( |
|
|
|
|
|
|
|
Animation.easeInOut(duration: 0.7).repeatForever(autoreverses: true), |
|
|
|
|
|
|
|
value: isAnimating |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.onAppear { |
|
|
|
|
|
|
|
isAnimating = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.onDisappear { |
|
|
|
|
|
|
|
isAnimating = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.padding() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EditScoreView: View { |
|
|
|
struct EditScoreView: View { |
|
|
|
|
|
|
|
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
@ -46,11 +15,6 @@ struct EditScoreView: View { |
|
|
|
@StateObject var matchDescriptor: MatchDescriptor |
|
|
|
@StateObject var matchDescriptor: MatchDescriptor |
|
|
|
@Binding var confirmScoreEdition: Bool |
|
|
|
@Binding var confirmScoreEdition: Bool |
|
|
|
@Environment(\.dismiss) private var dismiss |
|
|
|
@Environment(\.dismiss) private var dismiss |
|
|
|
@State private var showSetInputView: Bool = true |
|
|
|
|
|
|
|
@State private var showTieBreakInputView: Bool = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let colorTeamOne: Color = .teal |
|
|
|
|
|
|
|
let colorTeamTwo: Color = .indigo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init(match: Match, confirmScoreEdition: Binding<Bool>) { |
|
|
|
init(match: Match, confirmScoreEdition: Binding<Bool>) { |
|
|
|
let matchDescriptor = MatchDescriptor(match: match) |
|
|
|
let matchDescriptor = MatchDescriptor(match: match) |
|
|
|
@ -90,7 +54,7 @@ struct EditScoreView: View { |
|
|
|
.bold() |
|
|
|
.bold() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.listRowView(isActive: teamOneSetupIsActive, color: colorTeamOne, hideColorVariation: false) |
|
|
|
.listRowView(isActive: matchDescriptor.teamOneSetupIsActive, color: matchDescriptor.colorTeamOne, hideColorVariation: false) |
|
|
|
HStack { |
|
|
|
HStack { |
|
|
|
Spacer() |
|
|
|
Spacer() |
|
|
|
VStack(alignment: .trailing) { |
|
|
|
VStack(alignment: .trailing) { |
|
|
|
@ -101,7 +65,7 @@ struct EditScoreView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.listRowView(isActive: teamTwoSetupIsActive, color: colorTeamTwo, hideColorVariation: false, alignment: .trailing) |
|
|
|
.listRowView(isActive: matchDescriptor.teamTwoSetupIsActive, color: matchDescriptor.colorTeamTwo, hideColorVariation: false, alignment: .trailing) |
|
|
|
} header: { |
|
|
|
} header: { |
|
|
|
if let roundTitle = matchDescriptor.match?.roundAndMatchTitle() { |
|
|
|
if let roundTitle = matchDescriptor.match?.roundAndMatchTitle() { |
|
|
|
Text(roundTitle) |
|
|
|
Text(roundTitle) |
|
|
|
@ -133,7 +97,7 @@ struct EditScoreView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ForEach($matchDescriptor.setDescriptors) { $setDescriptor in |
|
|
|
ForEach($matchDescriptor.setDescriptors) { $setDescriptor in |
|
|
|
SetInputView(setDescriptor: $setDescriptor, showSetInputView: $showSetInputView, showTieBreakInputView: $showTieBreakInputView) |
|
|
|
SetInputView(setDescriptor: $setDescriptor) |
|
|
|
.onChange(of: setDescriptor.hasEnded) { |
|
|
|
.onChange(of: setDescriptor.hasEnded) { |
|
|
|
if setDescriptor.hasEnded { |
|
|
|
if setDescriptor.hasEnded { |
|
|
|
if matchDescriptor.hasEnded == false { |
|
|
|
if matchDescriptor.hasEnded == false { |
|
|
|
@ -144,7 +108,7 @@ struct EditScoreView: View { |
|
|
|
matchDescriptor.setDescriptors = Array(matchDescriptor.setDescriptors[0...index]) |
|
|
|
matchDescriptor.setDescriptors = Array(matchDescriptor.setDescriptors[0...index]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.tint(getColor()) |
|
|
|
.tint(matchDescriptor.getColor()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if matchDescriptor.hasEnded { |
|
|
|
if matchDescriptor.hasEnded { |
|
|
|
@ -191,66 +155,4 @@ struct EditScoreView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var teamOneSetupIsActive: Bool { |
|
|
|
|
|
|
|
if matchDescriptor.hasEnded && showSetInputView == false && showTieBreakInputView == false { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guard let setDescriptor = matchDescriptor.setDescriptors.last else { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if setDescriptor.valueTeamOne == nil { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} else if setDescriptor.valueTeamTwo == nil { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} else if setDescriptor.tieBreakValueTeamOne == nil, setDescriptor.shouldTieBreak { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} else if setDescriptor.tieBreakValueTeamTwo == nil, setDescriptor.shouldTieBreak { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var teamTwoSetupIsActive: Bool { |
|
|
|
|
|
|
|
if matchDescriptor.hasEnded && showSetInputView == false && showTieBreakInputView == false { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
guard let setDescriptor = matchDescriptor.setDescriptors.last else { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if setDescriptor.valueTeamOne == nil { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} else if setDescriptor.valueTeamTwo == nil { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} else if setDescriptor.tieBreakValueTeamOne == nil, setDescriptor.shouldTieBreak { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} else if setDescriptor.tieBreakValueTeamTwo == nil, setDescriptor.shouldTieBreak { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getColor() -> Color { |
|
|
|
|
|
|
|
guard let setDescriptor = matchDescriptor.setDescriptors.last else { |
|
|
|
|
|
|
|
return .master |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if setDescriptor.valueTeamOne == nil { |
|
|
|
|
|
|
|
return colorTeamOne |
|
|
|
|
|
|
|
} else if setDescriptor.valueTeamTwo == nil { |
|
|
|
|
|
|
|
return colorTeamTwo |
|
|
|
|
|
|
|
} else if setDescriptor.tieBreakValueTeamOne == nil, setDescriptor.shouldTieBreak { |
|
|
|
|
|
|
|
return colorTeamOne |
|
|
|
|
|
|
|
} else if setDescriptor.tieBreakValueTeamTwo == nil, setDescriptor.shouldTieBreak { |
|
|
|
|
|
|
|
return colorTeamTwo |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return colorTeamTwo |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|