This file contains hidden or 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
| WaitingForNewRidleView( | |
| viewModel: viewModel.waitingForNewRidleViewModel | |
| ) | |
| .halfTransparentBg() |
This file contains hidden or 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
| class WaitingForNewRidleViewModel: ObservableObject { | |
| @Published var availableAfter: String = "" | |
| private let unavailableUntil: String | |
| private var timer: Timer? | |
| init(unavailableUntil: String) { | |
| self.unavailableUntil = unavailableUntil | |
| self.calculateAvailableAfterTime() | |
| } |
This file contains hidden or 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
| struct WaitingForNewRidleView: View { | |
| @StateObject var viewModel: WaitingForNewRidleViewModel | |
| var body: some View { | |
| VStack(spacing: 8) { | |
| Text("Новое слово будет\nдоступно через: ") | |
| .multilineTextAlignment(.center) | |
| .font(Font.title3) | |
| .padding(.top, 12) |
This file contains hidden or 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
| switch viewModel.gameState { | |
| case .win: | |
| WinMsgView(onNewGame: { | |
| viewModel.onNextRiddle() | |
| }) | |
| .halfTransparentBg() | |
| case .lose: | |
| LoseMsgView(word: viewModel.riddle.answer, onNewGame: { | |
| viewModel.onNextRiddle() | |
| }) |
This file contains hidden or 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
| struct HalfTransparentBg: ViewModifier { | |
| func body(content: Content) -> some View { | |
| ZStack { | |
| Color(white: 0, opacity: 0.5).ignoresSafeArea() | |
| content | |
| } | |
| } | |
| } | |
| extension View { |
This file contains hidden or 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
| struct WinMsgView: View { | |
| var onNewGame: () -> Void | |
| var body: some View { | |
| VStack(spacing: 8) { | |
| Text("Ура, слово отгадано!") | |
| .font(Font.title3) | |
| .padding(.top, 12) | |
| .padding(.horizontal, 16) |
This file contains hidden or 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
| struct LoseMsgView: View { | |
| let word: String | |
| let onNewGame: () -> Void | |
| var body: some View { | |
| VStack(spacing: 8) { | |
| Text(word) | |
| .font(Font.title) | |
| .padding(.top, 12) | |
| Text("Упс, вы исчерпали все попытки!") |
This file contains hidden or 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
| private func shimmers(width: CGFloat) -> some View { | |
| VStack { | |
| BoardShimmerView() | |
| .padding(.horizontal, 26) | |
| Spacer(minLength: 0) | |
| KeyboardShimmerView(keys: viewModel.keys, | |
| width: width - 8) | |
| .padding(.horizontal, 4) | |
| }.padding(.vertical, 16) | |
| } |
This file contains hidden or 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
| struct KeyboardShimmerView: View { | |
| let keys: Keys | |
| let width: CGFloat | |
| var body: some View { | |
| let width = shimmerSize(width: width, keys: keys) | |
| VStack(spacing: 4) { | |
| ForEach(keys.rows.indices, id: \.self) { rowIndex in | |
| HStack(spacing: 4) { |
This file contains hidden or 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
| struct BoardShimmerView: View { | |
| var body: some View { | |
| VStack(spacing: 6) { | |
| ForEach((0...5), id: \.self) { index in | |
| HStack(spacing: 6) { | |
| ForEach((0..<5), id: \.self) { index in | |
| ShimmerView() | |
| .aspectRatio(1, contentMode: .fit) | |
| .cornerRadius(4) | |
| } |
NewerOlder