Update button size, add time that's added
This commit is contained in:
@@ -9,12 +9,13 @@ import SwiftUI
|
||||
|
||||
struct AnkiView: View {
|
||||
@EnvironmentObject var model: WordAXModelView
|
||||
@State var showDescription = false
|
||||
@State var showDescription = true
|
||||
var word: WordAX.Word? {
|
||||
model.getWordToDisplay()
|
||||
}
|
||||
var body: some View {
|
||||
if word != nil {
|
||||
GeometryReader { geometry in
|
||||
VStack {
|
||||
WordView(word: word!, showDescription: $showDescription)
|
||||
if showDescription {
|
||||
@@ -22,15 +23,35 @@ struct AnkiView: View {
|
||||
// .font(.subheadline)
|
||||
// .foregroundStyle(.gray)
|
||||
HStack(alignment: .center) {
|
||||
NextRepetitionButtonView(buttonText: "Novice", nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: word!.nextSpacedRepetitionMilestone)), wordId: word!.id, showDescription: $showDescription)
|
||||
// .padding(.leading)
|
||||
NextRepetitionButtonView(buttonText: "Expert", nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: word!.nextSpacedRepetitionMilestone), wordId: word!.id, showDescription: $showDescription)
|
||||
NextRepetitionButtonView(buttonText: "Master", nextMilestone: word!.nextSpacedRepetitionMilestone, wordId: word!.id, showDescription: $showDescription)
|
||||
// .padding(.trailing)
|
||||
NextRepetitionButtonView(
|
||||
buttonText: "Easy",
|
||||
nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: word!.nextSpacedRepetitionMilestone)),
|
||||
wordId: word!.id,
|
||||
width: geometry.size.width,
|
||||
color: .green,
|
||||
geometry: geometry,
|
||||
showDescription: $showDescription)
|
||||
NextRepetitionButtonView(
|
||||
buttonText: "Normal",
|
||||
nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.getNext(milestone: word!.nextSpacedRepetitionMilestone),
|
||||
wordId: word!.id,
|
||||
width:geometry.size.width,
|
||||
color: .orange,
|
||||
geometry: geometry,
|
||||
showDescription: $showDescription)
|
||||
NextRepetitionButtonView(
|
||||
buttonText: "Hard",
|
||||
nextMilestone: word!.nextSpacedRepetitionMilestone,
|
||||
wordId: word!.id,
|
||||
width: geometry.size.width,
|
||||
color: .red,
|
||||
geometry: geometry,
|
||||
showDescription: $showDescription)
|
||||
}
|
||||
.padding([.bottom, .trailing, .leading])
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("There is no word to display, come back later")
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ struct NextRepetitionButtonView: View {
|
||||
let buttonText: String
|
||||
let nextMilestone: WordAX.SpacedRepetitionMilestoneEnum?
|
||||
let wordId: Int
|
||||
let width: CGFloat
|
||||
let color: Color
|
||||
let geometry: GeometryProxy
|
||||
let newText: String = "1h"
|
||||
// { colorScheme == .light ? .cyan : .darkCyan }
|
||||
@Binding var showDescription: Bool
|
||||
@EnvironmentObject var model: WordAXModelView
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@@ -19,12 +24,19 @@ struct NextRepetitionButtonView: View {
|
||||
model.ankiButtonClicked(wordId: wordId, milestone: nextMilestone)
|
||||
self.showDescription = false
|
||||
}) {
|
||||
VStack {
|
||||
Text(buttonText)
|
||||
.padding()
|
||||
.foregroundColor(colorScheme == .light ? .black : .white)
|
||||
.background(colorScheme == .light ? .cyan : .darkCyan)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 50))
|
||||
Text(">" + newText)
|
||||
.font(.footnote)
|
||||
.bold()
|
||||
}
|
||||
.padding(.vertical, geometry.size.height / 80)
|
||||
.foregroundColor(colorScheme == .light ? .black : .white)
|
||||
.frame(maxWidth: width)
|
||||
}
|
||||
.background(color)
|
||||
.buttonStyle(.plain)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +47,8 @@ extension ShapeStyle where Self == Color {
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
@State var showDescription = false
|
||||
return NextRepetitionButtonView(buttonText: "Excellent", nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, wordId: 0, showDescription: $showDescription)
|
||||
.environmentObject(WordAXModelView())
|
||||
}
|
||||
//#Preview {
|
||||
// @State var showDescription = false
|
||||
// return NextRepetitionButtonView(buttonText: "Excellent", nextMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, wordId: 0, showDescription: $showDescription)
|
||||
// .environmentObject(WordAXModelView())
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user