Implemented the DismissableView component for the Profile module.

This commit is contained in:
Javier Cicchelli 2022-12-12 21:42:47 +01:00
parent 3d50979d4b
commit f65ecf556a

View 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()
}
}
}