接入首页位置上报与在线倒计时,并优化上报交互体验。
持久化服务端 expired 过期时间戳以正确恢复倒计时,切换在线/离线与上报时展示定位 Loading,移除重复的成功 Alert,并将 Toast 调整为居中半透明样式。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -62,18 +62,17 @@ final class ToastCenter: ObservableObject {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// 全局 Toast 叠加层修饰器,负责把 Toast 展示到页面顶部。
|
||||
/// 全局 Toast 叠加层修饰器,负责把 Toast 展示到屏幕中央。
|
||||
private struct GlobalToastOverlay: ViewModifier {
|
||||
@EnvironmentObject private var toastCenter: ToastCenter
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.overlay(alignment: .top) {
|
||||
GeometryReader { proxy in
|
||||
.overlay {
|
||||
Group {
|
||||
if let message = toastCenter.message {
|
||||
toastBanner(message, topInset: proxy.safeAreaInsets.top)
|
||||
.transition(.move(edge: .top).combined(with: .opacity))
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||
toastBanner(message)
|
||||
.transition(.opacity)
|
||||
}
|
||||
}
|
||||
.allowsHitTesting(false)
|
||||
@ -81,22 +80,23 @@ private struct GlobalToastOverlay: ViewModifier {
|
||||
.animation(.easeInOut(duration: 0.18), value: toastCenter.message)
|
||||
}
|
||||
|
||||
/// 构建顶部全宽 Toast 横幅。
|
||||
private func toastBanner(_ message: String, topInset: CGFloat) -> some View {
|
||||
HStack {
|
||||
/// 构建屏幕中央的黑色半透明圆角 Toast 卡片。
|
||||
private func toastBanner(_ message: String) -> some View {
|
||||
HStack(spacing: 10) {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.font(.system(size: 16, weight: .semibold))
|
||||
|
||||
Text(message)
|
||||
.font(.system(size: 14, weight: .medium))
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.system(size: 16, weight: .medium))
|
||||
.lineLimit(3)
|
||||
.multilineTextAlignment(.leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
.foregroundStyle(.white)
|
||||
.padding(.horizontal, AppMetrics.Spacing.pageHorizontal)
|
||||
.padding(.top, topInset + AppMetrics.Spacing.small)
|
||||
.padding(.bottom, AppMetrics.Spacing.small)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.background(AppDesign.primary.ignoresSafeArea(edges: .top))
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 14)
|
||||
.background(Color.black.opacity(0.78), in: RoundedRectangle(cornerRadius: 12))
|
||||
.padding(.horizontal, 40)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user