fix
This commit is contained in:
parent
cb0a8f249e
commit
4442dfc821
@ -10,7 +10,7 @@ import Combine
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
class LoginViewModel: ObservableObject {
|
class LoginViewModel: ObservableObject {
|
||||||
@AppStorage("appIsBlocked") private var isAppBlocked: Bool = false
|
// @AppStorage("appIsBlocked") private var isAppBlocked: Bool = false
|
||||||
|
|
||||||
@Published var username: String = ""
|
@Published var username: String = ""
|
||||||
@Published var userId: String = ""
|
@Published var userId: String = ""
|
||||||
@ -137,8 +137,7 @@ class LoginViewModel: ObservableObject {
|
|||||||
self?.socketService.disconnect()
|
self?.socketService.disconnect()
|
||||||
}
|
}
|
||||||
self?.isLoading = false
|
self?.isLoading = false
|
||||||
if self?.isAppBlocked == false{
|
self?.isInitialLoading = false
|
||||||
self?.isInitialLoading = false}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct ForceUpdateView: View {
|
|
||||||
let title: String
|
|
||||||
let message: String
|
|
||||||
let onUpdate: () -> Void
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
ZStack {
|
|
||||||
Color.black.opacity(0.6)
|
|
||||||
.ignoresSafeArea()
|
|
||||||
|
|
||||||
VStack(spacing: 16) {
|
|
||||||
Text(title)
|
|
||||||
.font(.title3.weight(.semibold))
|
|
||||||
.multilineTextAlignment(.center)
|
|
||||||
.foregroundColor(.primary)
|
|
||||||
|
|
||||||
Text(message)
|
|
||||||
.font(.body)
|
|
||||||
.multilineTextAlignment(.center)
|
|
||||||
.foregroundColor(.primary)
|
|
||||||
|
|
||||||
Button(action: onUpdate) {
|
|
||||||
Text(NSLocalizedString("Обновить приложение", comment: ""))
|
|
||||||
.font(.headline)
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.padding()
|
|
||||||
.background(Color.accentColor)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.cornerRadius(12)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.padding(24)
|
|
||||||
.background(.ultraThinMaterial)
|
|
||||||
.cornerRadius(20)
|
|
||||||
.padding(32)
|
|
||||||
}
|
|
||||||
.zIndex(2)
|
|
||||||
.accessibilityElement(children: .contain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ForceUpdateView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
ForceUpdateView(title: "Требуется обновление",
|
|
||||||
message: "Эта версия приложения устарела и больше не поддерживается.",
|
|
||||||
onUpdate: {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
62
yobble/Views/NeedUpdateView.swift
Normal file
62
yobble/Views/NeedUpdateView.swift
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct NeedUpdateView: View {
|
||||||
|
let title: String
|
||||||
|
let message: String
|
||||||
|
let onUpdate: () -> Void
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
|
LinearGradient(
|
||||||
|
colors: [Color(.systemBackground), Color(.systemGray6)],
|
||||||
|
startPoint: .top,
|
||||||
|
endPoint: .bottom
|
||||||
|
)
|
||||||
|
.ignoresSafeArea()
|
||||||
|
|
||||||
|
VStack(spacing: 24) {
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Image(systemName: "exclamationmark.triangle.fill")
|
||||||
|
.font(.system(size: 56, weight: .bold))
|
||||||
|
.foregroundColor(.orange)
|
||||||
|
.accessibilityHidden(true)
|
||||||
|
|
||||||
|
VStack(spacing: 12) {
|
||||||
|
Text(title)
|
||||||
|
.font(.title2.weight(.semibold))
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
|
||||||
|
Text(message)
|
||||||
|
.font(.body)
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(action: onUpdate) {
|
||||||
|
Text(NSLocalizedString("Обновить приложение", comment: ""))
|
||||||
|
.font(.headline)
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.padding()
|
||||||
|
.background(Color.accentColor)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.cornerRadius(14)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(32)
|
||||||
|
.frame(maxWidth: 480)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
.accessibilityElement(children: .contain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct NeedUpdateView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
NeedUpdateView(title: "Требуется обновление",
|
||||||
|
message: "Эта версия приложения устарела и больше не поддерживается.",
|
||||||
|
onUpdate: {})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,6 +21,14 @@ struct yobbleApp: App {
|
|||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
|
Group {
|
||||||
|
if let notice = updateChecker.needUpdateNotice {
|
||||||
|
NeedUpdateView(
|
||||||
|
title: notice.title,
|
||||||
|
message: notice.message,
|
||||||
|
onUpdate: { updateChecker.openAppStore() }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
Group {
|
Group {
|
||||||
if viewModel.isInitialLoading {
|
if viewModel.isInitialLoading {
|
||||||
@ -60,17 +68,6 @@ struct yobbleApp: App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.environmentObject(messageCenter)
|
|
||||||
.environmentObject(themeManager)
|
|
||||||
.preferredColorScheme(themeManager.theme.colorScheme)
|
|
||||||
.environment(\.managedObjectContext, persistenceController.viewContext)
|
|
||||||
.onAppear {
|
|
||||||
updateChecker.checkForUpdatesIfNeeded()
|
|
||||||
messageCenter.currentUserId = viewModel.userId.isEmpty ? nil : viewModel.userId
|
|
||||||
}
|
|
||||||
.onChange(of: viewModel.userId) { newValue in
|
|
||||||
messageCenter.currentUserId = newValue.isEmpty ? nil : newValue
|
|
||||||
}
|
|
||||||
.alert(item: Binding(
|
.alert(item: Binding(
|
||||||
get: { updateChecker.softUpdateNotice },
|
get: { updateChecker.softUpdateNotice },
|
||||||
set: { newValue in
|
set: { newValue in
|
||||||
@ -90,15 +87,19 @@ struct yobbleApp: App {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.overlay(alignment: .center) {
|
|
||||||
if let notice = updateChecker.needUpdateNotice {
|
|
||||||
ForceUpdateView(
|
|
||||||
title: notice.title,
|
|
||||||
message: notice.message,
|
|
||||||
onUpdate: { updateChecker.openAppStore() }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.environmentObject(messageCenter)
|
||||||
|
.environmentObject(themeManager)
|
||||||
|
.preferredColorScheme(themeManager.theme.colorScheme)
|
||||||
|
.environment(\.managedObjectContext, persistenceController.viewContext)
|
||||||
|
.onAppear {
|
||||||
|
updateChecker.checkForUpdatesIfNeeded()
|
||||||
|
messageCenter.currentUserId = viewModel.userId.isEmpty ? nil : viewModel.userId
|
||||||
|
}
|
||||||
|
.onChange(of: viewModel.userId) { newValue in
|
||||||
|
messageCenter.currentUserId = newValue.isEmpty ? nil : newValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user