import SwiftUI
struct LeaveHubView: View {
var body: some View {
NavigationStack {
ScrollView {
VStack(spacing: 16) {
// Chat bubble / card
MessageCard()
// Quick action grid
QuickActionGrid()
}
.padding(.horizontal)
.padding(.top, 8)
.background(Color(UIColor.systemGroupedBackground))
}
.navigationTitle("LeaveHub")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
HStack(spacing: 8) {
Image(systemName: "chevron.left")
Image(systemName: "shield.fill")
.foregroundStyle(.tint)
}
}
ToolbarItemGroup(placement: .topBarTrailing) {
Image(systemName: "magnifyingglass")
Image(systemName: "list.bullet")
}
}
}
}
}
// MARK: - Components
private struct MessageCard: View {
var body: some View {
HStack(alignment: .bottom, spacing: 12) {
// Avatar
ZStack {
Circle()
.fill(Color(UIColor.secondarySystemBackground))
Image(systemName: "leaf.circle.fill")
.foregroundStyle(.green)
}
.frame(width: 36, height: 36)
// Bubble
VStack(alignment: .leading, spacing: 12) {
VStack(spacing: 16) {
// Logo + title
VStack(spacing: 8) {
Image(systemName: "leaf.fill")
.font
(.system(size
: 28, weight
: .semibold
)) .foregroundStyle(.green)
Text("LEAVE HUB")
.font
(.system(.headline
, design
: .rounded
)) .tracking(1)
Text("ขออภัยค่ะ")
.font
(.system(.title3
, weight
: .semibold
)) }
VStack(alignment: .center, spacing: 6) {
Text("ท่านได้ลงทะเบียนเรียบร้อยแล้วค่ะ")
.font(.body)
Divider()
Text("ภายใต้ชื่อ Test2 ของ Demo")
.font(.body)
Text("Leavehub เรียบร้อยแล้วค่ะ")
.font(.body)
Divider()
Text("ท่านสามารถแจ้งความประสงค์การลา")
.font(.body)
Text("ได้ในช่องทางนี้ได้เลยค่ะ")
.font(.body)
}
.multilineTextAlignment(.center)
Button(action: {}) {
Text("แจ้งการลา")
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
}
.buttonStyle(.borderedProminent)
.tint(.green)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
}
.padding(16)
.background(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(Color(UIColor.systemBackground))
)
.overlay(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.stroke(Color(UIColor.separator), lineWidth: 0.5)
)
Text("11:53 AM")
.font(.footnote)
.foregroundStyle(.secondary)
.padding(.top, 4)
.frame(maxWidth: .infinity, alignment: .trailing)
}
}
.padding(.trailing) // like a chat layout
}
}
private struct QuickActionGrid: View {
let items: [QuickItem] = [
.init(title: "ลงทะเบียน", subtitle: "ตรวจสอบ วันลา", systemImage: "checklist"),
.init(title: "แจ้งการลา", subtitle: "", systemImage: "laptopcomputer"),
.init(title: "ตรวจสอบ วันหยุด", subtitle: "", systemImage: "calendar"),
.init(title: "ขอสลับวันหยุด", subtitle: "", systemImage: "calendar.badge.exclamationmark")
]
var body: some View {
VStack(spacing: 12) {
LazyVGrid
(columns
: Array(repeating
: GridItem
(.flexible
(), spacing
: 12), count: 2), spacing
: 12) { ForEach(items) { item in
VStack(alignment: .leading, spacing: 8) {
HStack {
Image(systemName: item.systemImage)
Spacer()
}
Text(item.title)
.font
(.system(.title3
, weight
: .semibold
)) if !item.subtitle.isEmpty {
Text(item.subtitle)
.font(.footnote)
.foregroundStyle(.secondary)
}
Spacer(minLength: 0)
}
.padding(14)
.frame(height: 140)
.background(
RoundedRectangle(cornerRadius: 14, style: .continuous)
.fill(Color(UIColor.systemBackground))
)
.overlay(
RoundedRectangle(cornerRadius: 14, style: .continuous)
.stroke(Color(UIColor.separator), lineWidth: 0.5)
)
}
}
.padding(.bottom, 8)
// Bottom app label (like the “LeaveHub ▾” bar in your screenshot)
HStack {
Image(systemName: "ellipsis.rectangle")
Text("LeaveHub")
.font(.body)
Image(systemName: "chevron.down")
Spacer()
}
.padding(.vertical, 10)
.padding(.horizontal, 14)
.background(.ultraThinMaterial, in: Capsule())
}
}
}
private struct QuickItem: Identifiable {
let id = UUID()
let title: String
let subtitle: String
let systemImage: String
}
// MARK: - Preview
#Preview {
LeaveHubView()
}