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