add app icon, starting to do card views

This commit is contained in:
june 2025-02-24 19:02:35 +13:00
parent 63eacbb378
commit d7c99b5ac5
Signed by untrusted user who does not match committer: breadone
GPG Key ID: FDC19FE143200483
11 changed files with 55 additions and 11 deletions

BIN
Gastrack_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
Gastrack_icon.pxd Normal file

Binary file not shown.

BIN
Gastrack_icon_bw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,6 +1,7 @@
{ {
"images" : [ "images" : [
{ {
"filename" : "Gastrack_icon.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "ios", "platform" : "ios",
"size" : "1024x1024" "size" : "1024x1024"
@ -12,6 +13,7 @@
"value" : "dark" "value" : "dark"
} }
], ],
"filename" : "Gastrack_icon_transparent.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "ios", "platform" : "ios",
"size" : "1024x1024" "size" : "1024x1024"
@ -23,6 +25,7 @@
"value" : "tinted" "value" : "tinted"
} }
], ],
"filename" : "Gastrack_icon_bw.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "ios", "platform" : "ios",
"size" : "1024x1024" "size" : "1024x1024"

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -16,9 +16,9 @@ struct ContentView: View {
var body: some View { var body: some View {
NavigationSplitView { NavigationSplitView {
List { ScrollView {
ForEach(entries) { e in ForEach(entries) { e in
Text("Entry: \(e.odo)") EntryCardView(entry: e)
} }
} }
.sheet(isPresented: $addEntry) { .sheet(isPresented: $addEntry) {
@ -28,14 +28,16 @@ struct ContentView: View {
} }
.toolbar { .toolbar {
ToolbarItem(placement: .bottomBar) { ToolbarItem(placement: .bottomBar) {
Text("") Button(action: addItem) {
Label("Add Item", systemImage: "plus.circle.fill")
}
} }
ToolbarItem(placement: .status) { ToolbarItem(placement: .status) {
Text("Placeholder") Text("Placeholder")
.frame(alignment: .center) .frame(alignment: .center)
} }
ToolbarItem(placement: .bottomBar) { ToolbarItem(placement: .bottomBar) {
Button(action: addItem) { Button(action: { addEntry.toggle() }) {
Label("Add Item", systemImage: "plus") Label("Add Item", systemImage: "plus")
} }
} }
@ -46,12 +48,11 @@ struct ContentView: View {
} }
private func addItem() { private func addItem() {
addEntry.toggle() withAnimation {
// withAnimation { let newItem = Entry(odo: 75239, cost: 92.19, quantity: 36.34, fuelType: "91")
// let newItem = Entry(odo: 75239, cost: 92.19, quantity: 36.34, fuelType: "91") modelContext.insert(newItem)
// modelContext.insert(newItem) try? modelContext.save()
// try? modelContext.save() }
// }
} }
private func deleteItems(offsets: IndexSet) { private func deleteItems(offsets: IndexSet) {

View File

@ -12,16 +12,22 @@ import SwiftData
final class Entry { final class Entry {
var id: UUID var id: UUID
var date: Date
var odo: Int var odo: Int
var cost: Double var cost: Double
var quantity: Double var quantity: Double
var fuelType: String var fuelType: String
public init(odo: Int, cost: Double, quantity: Double, fuelType: String) { public init(date: Date = Date(), odo: Int, cost: Double, quantity: Double, fuelType: String) {
self.id = UUID() self.id = UUID()
self.date = date
self.odo = odo self.odo = odo
self.cost = cost self.cost = cost
self.quantity = quantity self.quantity = quantity
self.fuelType = fuelType self.fuelType = fuelType
} }
public func getFormattedDate() -> String {
return self.date.formatted(date: .numeric, time: .omitted)
}
} }

View File

@ -0,0 +1,34 @@
//
// EntryCardView.swift
// gastrack
//
// Created by Pradyun Setti on 24/02/2025.
//
import SwiftUI
struct EntryCardView: View {
let entry: Entry
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(entry.getFormattedDate())
.font(.system(.caption, design: .default, weight: .medium))
Text(String(format: "$%.2f", entry.cost))
.font(.system(.headline, design: .default, weight: .bold))
.foregroundStyle(.green)
Text(String(format: "%.3f L", entry.quantity))
}
Spacer()
}
.padding()
.background(Color.secondary.opacity(0.3))
.clipShape(RoundedRectangle(cornerRadius: 12))
.padding(.horizontal)
}
}
//#Preview {
// EntryCardView()
//}