Implemented the DismissableView component for the Profile module.
This commit is contained in:
parent
3d50979d4b
commit
f65ecf556a
60
Modules/Sources/Profile/UI/Components/DismissableView.swift
Normal file
60
Modules/Sources/Profile/UI/Components/DismissableView.swift
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// DismissableView.swift
|
||||||
|
// Profile
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 12/12/2022.
|
||||||
|
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct DismissableView<Content: View>: View {
|
||||||
|
|
||||||
|
// MARK: Environments
|
||||||
|
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
@ViewBuilder let content: Content
|
||||||
|
|
||||||
|
// MARK: Body
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
|
content
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
Button {
|
||||||
|
dismiss()
|
||||||
|
} label: {
|
||||||
|
Image.close
|
||||||
|
.resizable()
|
||||||
|
.scaledToFit()
|
||||||
|
.frame(width: 32)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||||
|
.padding([.top, .trailing], 24)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Images+Constants
|
||||||
|
|
||||||
|
private extension Image {
|
||||||
|
static let close = Image(systemName: "xmark.circle.fill")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Previews
|
||||||
|
|
||||||
|
struct SwiftUIView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
DismissableView {
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user