-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from DeveloperAcademy-POSTECH/feat/132-loadin…
…g-view [#132] 맵뷰로 넘어가기 전에 로딩 화면 제공
- Loading branch information
Showing
17 changed files
with
225 additions
and
28 deletions.
There are no files selected for viewing
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
TMT/TMT/Assets.xcassets/Image/Loading/LoadingCompare.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" : "loading2_1x.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "loading2_2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "loading2_3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+24.5 KB
TMT/TMT/Assets.xcassets/Image/Loading/LoadingCompare.imageset/loading2_1x.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
+51.6 KB
TMT/TMT/Assets.xcassets/Image/Loading/LoadingCompare.imageset/loading2_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
+81.4 KB
TMT/TMT/Assets.xcassets/Image/Loading/LoadingCompare.imageset/loading2_3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
TMT/TMT/Assets.xcassets/Image/Loading/LoadingDynamic.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" : "loading1_1x.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "loading1_2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "loading1_3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+5.18 KB
TMT/TMT/Assets.xcassets/Image/Loading/LoadingDynamic.imageset/loading1_1x.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
+11.2 KB
TMT/TMT/Assets.xcassets/Image/Loading/LoadingDynamic.imageset/loading1_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
+18 KB
TMT/TMT/Assets.xcassets/Image/Loading/LoadingDynamic.imageset/loading1_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
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,25 @@ | ||
// | ||
// LoadingViewEnum.swift | ||
// TMT | ||
// | ||
// Created by 김유빈 on 12/4/24. | ||
// | ||
|
||
enum Loading: CaseIterable { | ||
case loadingDynamic | ||
case loadingCompare | ||
|
||
var description: String { | ||
switch self { | ||
case .loadingDynamic: return "Match with\nDynamic Island" | ||
case .loadingCompare: return "Compare\nRomanization" | ||
} | ||
} | ||
|
||
var loadingImage: String { | ||
switch self { | ||
case .loadingDynamic: return "LoadingDynamic" | ||
case .loadingCompare: return "LoadingCompare" | ||
} | ||
} | ||
} |
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,70 @@ | ||
// | ||
// LoadingView.swift | ||
// TMT | ||
// | ||
// Created by 김유빈 on 12/4/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct LoadingView: View { | ||
@State private var currentLoading: Loading = .loadingDynamic | ||
@State private var timer: Timer? = nil | ||
|
||
var body: some View { | ||
VStack(spacing: 0) { | ||
HStack { | ||
Text(currentLoading.description) | ||
.foregroundStyle(.textDefault) | ||
.font(.system(size: 28, weight: .bold)) | ||
|
||
Spacer() | ||
} | ||
.padding(.horizontal, 16) | ||
.padding(.top, 150) | ||
|
||
Spacer() | ||
|
||
Image(currentLoading.loadingImage) | ||
|
||
} | ||
.background { | ||
Color.brandBackground | ||
} | ||
.ignoresSafeArea(.all) | ||
.onAppear { | ||
startAlternating() | ||
} | ||
.onDisappear { | ||
stopAlternating() | ||
} | ||
} | ||
|
||
private func startAlternating() { | ||
timer = Timer.scheduledTimer(withTimeInterval: 1.5, repeats: true) { _ in | ||
withAnimation { | ||
switchToNextLoading() | ||
} | ||
} | ||
} | ||
|
||
private func stopAlternating() { | ||
timer?.invalidate() | ||
timer = nil | ||
} | ||
|
||
private func switchToNextLoading() { | ||
if let currentIndex = Loading.allCases.firstIndex(of: currentLoading) { | ||
let nextIndex = (currentIndex + 1) % Loading.allCases.count | ||
currentLoading = Loading.allCases[nextIndex] | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
LoadingView() | ||
} | ||
|
||
#Preview { | ||
LoadingView() | ||
} |
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
Oops, something went wrong.