Implemented the ListItemEmpty component in the app target.
This commit is contained in:
parent
a12354d613
commit
364fa4f3d5
61
Piper/Sources/UI/Components/ListItemEmpty.swift
Normal file
61
Piper/Sources/UI/Components/ListItemEmpty.swift
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// ListItemEmpty.swift
|
||||
// Piper ~ App
|
||||
//
|
||||
// Created by Javier Cicchelli on 06/10/2024.
|
||||
// Copyright © 2024 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ListItemEmpty: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let title: LocalizedStringKey
|
||||
let button: LocalizedStringKey
|
||||
let onAction: () -> Void
|
||||
|
||||
// MARK: Body
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
Color.clear
|
||||
.overlay {
|
||||
VStack(spacing: 16) {
|
||||
Text(title)
|
||||
.font(.title)
|
||||
.foregroundStyle(.secondary)
|
||||
.frame(maxWidth: .infinity)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Button(action: onAction) {
|
||||
Text(button)
|
||||
.font(.body)
|
||||
.fontWeight(.semibold)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
.foregroundStyle(.primary)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, proxy.size.width * 0.2)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
#Preview("List Item Empty component with title and button") {
|
||||
List {
|
||||
ListItemEmpty(
|
||||
title: "Some title text goes here...",
|
||||
button: "Some button text goes here..."
|
||||
) {
|
||||
// ...
|
||||
}
|
||||
.frame(height: 300)
|
||||
}
|
||||
.frame(width: 400, height: 300)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user