Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update storyview background for iphone, fix audio bug on arstory #115

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Moco/MocoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct MocoApp: App {
.environment(\.audioViewModel, audioViewModel)
.environment(\.timerViewModel, timerViewModel)
.environment(\.mazePromptViewModel, mazePromptViewModel)
.environment(/*@START_MENU_TOKEN@*//*@PLACEHOLDER=Key Path@*/ \.sizeCategory/*@END_MENU_TOKEN@*/, /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/ .extraExtraLarge/*@END_MENU_TOKEN@*/)
.environmentObject(objectDetectionViewModel)
.environmentObject(arViewModel)
.environmentObject(motionViewModel)
Expand Down
10 changes: 8 additions & 2 deletions Moco/View/Components/Prompts/ARStory/ARStory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct ARStory: View {
}

@State private var isStoryDone: Bool = false
@State private var isMakeSentence: Bool = false

var prompt: PromptModel = .init(
correctAnswer: "honey_jar", // object to be found
Expand Down Expand Up @@ -67,7 +68,7 @@ struct ARStory: View {
var body: some View {
ZStack {
if isTutorialFinished {
if !isStoryDone {
if !isStoryDone && !showLastIsland && !isMakeSentence {
ARCameraView(
clue: prompt,
lastPrompt: lastPrompt,
Expand All @@ -87,6 +88,8 @@ struct ARStory: View {
isStoryDone = true
if !lastPrompt {
doneHandler?()
} else {
isMakeSentence = true
}
}
)
Expand Down Expand Up @@ -114,7 +117,7 @@ struct ARStory: View {
}
}
}
} else if lastPrompt && !showLastIsland {
} else if lastPrompt && !showLastIsland && isMakeSentence {
MakeSentence {
showLastIsland = true
}
Expand Down Expand Up @@ -159,6 +162,9 @@ struct ARStory: View {
arViewModel.pause()
arViewModel.resetSession()
}
.onAppear {
isStoryDone = false
}
.task {
isTutorialFinished = arViewModel.isTutorialDone
}
Expand Down
3 changes: 2 additions & 1 deletion Moco/View/Components/Prompts/ARStory/MakeSentence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct MakeSentence: View {

var prompts: [PromptModel] = [
.init(
correctAnswer: "bebe makan madu",
correctAnswer: "bebe",
startTime: 0,
promptType: PromptType.card,
hints: nil,
Expand Down Expand Up @@ -116,6 +116,7 @@ struct MakeSentence: View {
}
}
.onAppear {
print("cukurukuk")
currentPromptIndex = 0

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
Expand Down
33 changes: 18 additions & 15 deletions Moco/View/Components/Prompts/Card/CardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,25 @@ struct CardView: View {
VStack {
switch state {
case .active:
VStack {
GeometryReader { proxy in
let frame = proxy.frame(in: .local)
Image(getActiveCard())
.resizable()
.scaledToFit()
.onTapGesture {
onTap?()
}
.scaleEffect(minScale: 1.0, maxScale: 1.05)
.pointer(
position: CGPoint(x: frame.midX, y: frame.midY),
isShowing: showPointer
)
Image(getActiveCard())
.resizable()
.scaledToFit()
.overlay {
GeometryReader { proxy in
let frame = proxy.frame(in: .local)
Image(getActiveCard())
.resizable()
.scaledToFit()
.onTapGesture {
onTap?()
}
.scaleEffect(minScale: 1.0, maxScale: 1.05)
.pointer(
position: CGPoint(x: frame.midX, y: frame.midY),
isShowing: showPointer
)
}
}
}
case .inactive:
Image("Story/Prompts/card-inactive")
.resizable()
Expand Down
7 changes: 0 additions & 7 deletions Moco/View/User/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ struct HomeView: View {

@State private var homeViewModel = HomeViewModel()

@State private var isShowing3d = false
@State private var isMakeSentenceTest = true

var body: some View {
ZStack {
Expand Down Expand Up @@ -116,11 +114,6 @@ struct HomeView: View {
homeViewModel.soundLevel = 0.3
homeViewModel.setVolume()
}
if isShowing3d {
ThreeDRenderer {
print("test 3d render selesai!")
}
}
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions Moco/View/User/StoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ struct StoryView: View {

var body: some View {
ZStack {
Color.text.primary
ScrollView(.horizontal) {
LazyHStack(spacing: 0) {
if let stories = episodeViewModel.selectedEpisode!.stories {
ForEach(Array(stories.enumerated()), id: \.offset) { index, _ in
ZStack {
PeelEffectTappable(state: $svvm.peelEffectState, isReverse: svvm.isReversePeel) {
Image(storyViewModel.storyPage!.background)
.resizable()
.scaledToFill()
.frame(width: Screen.width, height: Screen.height, alignment: .center)
.clipped()
if UIDevice.isIPad {
Image(storyViewModel.storyPage!.background)
.resizable()
.scaledToFill()
.frame(width: Screen.width, height: Screen.height, alignment: .center)
.clipped()
} else {
Image(storyViewModel.storyPage!.background)
.resizable()
.scaledToFit()
.scaleEffect(1.4)
.frame(width: Screen.width, height: Screen.height, alignment: .center)
.clipped()
}
} background: {
svvm.peelBackground
} onComplete: {
Expand Down
8 changes: 6 additions & 2 deletions Moco/ViewModel/StoryViewViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ extension StoryViewViewModel {

let nextPageBg = storyViewModel.getPageBackground(scrollPosition! + 1, episode: episodeViewModel.selectedEpisode!)

peelBackground = AnyView(Image(nextPageBg ?? storyViewModel.storyPage!.background)
peelBackground = UIDevice.isIPad ? AnyView(Image(nextPageBg ?? storyViewModel.storyPage!.background)
.resizable()
.scaledToFill()
.frame(width: Screen.width, height: Screen.height, alignment: .center)
.clipped())
.clipped()) : AnyView(Image(nextPageBg ?? storyViewModel.storyPage!.background)
.resizable()
.scaledToFit()
.frame(width: Screen.width, height: Screen.height, alignment: .center)
.clipped())
peelEffectState = .start
toBeExecutedByPeelEffect = {
self.scrollPosition! += 1
Expand Down
Loading