-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentViewSwiftUi24.swift
52 lines (48 loc) · 1.55 KB
/
ContentViewSwiftUi24.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// ContentView.swift
// JRNLSwiftUI
//
// Created by iOS17Programming on 16/10/2023.
//
import SwiftUI
struct ContentView: View {
var journalEntries: [JournalEntry] = testData
var body: some View {
NavigationStack {
List(journalEntries) { journalEntry in
JournalCell(journalEntry: journalEntry)
}.navigationTitle("Journal List")
.navigationDestination(for: JournalEntry.self) {
journalEntry in
JournalEntryDetail(selectedJournalEntry: journalEntry)
}
}
}
}
#Preview {
ContentView()
}
struct JournalCell: View {
var journalEntry: JournalEntry
var body: some View {
NavigationLink(value: journalEntry) {
VStack {
HStack {
Image(uiImage: journalEntry.photo ?? UIImage(systemName: "face.smiling")!)
.resizable()
.frame(width: 90, height: 90)
VStack {
Text(journalEntry.date.formatted(.dateTime.day().month().year()))
.font(.title)
.fontWeight(.bold)
.frame(maxWidth: .infinity, alignment: .leading)
Text(journalEntry.entryTitle)
.font(.title2)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
}
}
}
}
}
}