mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
|
2 years ago
|
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||
|
|
|
||
|
|
import SwiftUI
|
||
|
|
|
||
|
|
public struct Toast: View {
|
||
|
|
@State var dismiss: Bool = false
|
||
|
|
|
||
|
|
let message: String
|
||
|
|
|
||
|
|
static let width: CGFloat = 320
|
||
|
|
static let height: CGFloat = 44
|
||
|
|
|
||
|
|
public init(_ message: String) {
|
||
|
|
self.message = message
|
||
|
|
}
|
||
|
|
|
||
|
|
public var body: some View {
|
||
|
|
VStack {
|
||
|
|
Spacer()
|
||
|
|
|
||
|
|
if !dismiss {
|
||
|
|
ZStack {
|
||
|
|
Capsule()
|
||
|
|
.foregroundColor(themeColor: .toast_background)
|
||
|
|
|
||
|
|
Text(message)
|
||
|
|
.font(.system(size: Values.verySmallFontSize))
|
||
|
|
.foregroundColor(themeColor: .textPrimary)
|
||
|
|
.multilineTextAlignment(.center)
|
||
|
|
.frame(maxWidth: .infinity)
|
||
|
|
.padding(.horizontal, Values.mediumSpacing)
|
||
|
|
}
|
||
|
|
.frame(
|
||
|
|
width: Self.width,
|
||
|
|
height: Self.height
|
||
|
|
)
|
||
|
|
.padding(.bottom, Values.smallSpacing)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.onAppear {
|
||
|
|
Timer.scheduledTimerOnMainThread(withTimeInterval: 5) { _ in
|
||
|
|
withAnimation(.easeOut(duration: 0.5)) {
|
||
|
|
dismiss.toggle()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
struct Toast_Previews: PreviewProvider {
|
||
|
|
static var previews: some View {
|
||
|
|
Toast("This QR code does not contain a Recovery Password.")
|
||
|
|
}
|
||
|
|
}
|