Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tvOS and Mac Catalyst support #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 106 additions & 66 deletions iOS/Inventory.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "e46e5400f3661256bd0197e1612c81282831b17087168009e217d707f188d805",
"originHash" : "09ffcf3308b792bb9a632f175aa47929f479bf53a008132242e1e081b175a854",
"pins" : [
{
"identity" : "cartography",
Expand All @@ -15,26 +15,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/getditto/DittoSwiftPackage",
"state" : {
"revision" : "8f32d91b4a8d903e2e1da9abdae9f685c152f65d",
"version" : "4.7.2"
"revision" : "fb4ee210d85380084f9bdd26cd5bb987db971da2",
"version" : "4.8.0"
}
},
{
"identity" : "dittoswifttools",
"kind" : "remoteSourceControl",
"location" : "https://github.com/getditto/DittoSwiftTools",
"location" : "https://github.com/getditto/DittoSwiftTools.git",
"state" : {
"branch" : "v4",
"revision" : "600e3b82dbdf5d70ee35d1b470f3e47f2b69bb54"
"revision" : "756a3bf761da352646851f7d45481dc4a790d0d2",
"version" : "6.0.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "ee97538f5b81ae89698fd95938896dec5217b148",
"version" : "1.1.1"
"revision" : "9bf03ff58ce34478e66aaee630e491823326fd06",
"version" : "1.1.3"
}
}
],
Expand Down
13 changes: 2 additions & 11 deletions iOS/Inventory/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,17 @@
//

import UIKit
import SwiftUI

@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let navigationController = UINavigationController(rootViewController: MainViewController())
navigationController.navigationBar.prefersLargeTitles = true
window?.tintColor = Constants.Colors.mainColor
window!.rootViewController = navigationController
window!.rootViewController = UIHostingController(rootView: ContentView())
window!.makeKeyAndVisible()
return true
}

func applicationWillResignActive(_ application: UIApplication) {
BackgroundSync.shared.start()
}

func applicationWillEnterForeground(_ application: UIApplication) {
BackgroundSync.shared.stop()
}
}
17 changes: 4 additions & 13 deletions iOS/Inventory/Assets.xcassets/blt.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "blt.png",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
17 changes: 4 additions & 13 deletions iOS/Inventory/Assets.xcassets/brownies.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "brownies.jpg",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
17 changes: 4 additions & 13 deletions iOS/Inventory/Assets.xcassets/coke.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Coke.jpg",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
17 changes: 4 additions & 13 deletions iOS/Inventory/Assets.xcassets/drpepper.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "drpepper.jpeg",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
17 changes: 4 additions & 13 deletions iOS/Inventory/Assets.xcassets/lays.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "lays.jpg",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
1 change: 0 additions & 1 deletion iOS/Inventory/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit

struct Constants {

struct Colors {
static let mainColor = UIColor(red: 0/255, green: 122/255, blue: 255/255, alpha: 1)
static let lightHighlightColor = UIColor(red: 210/255, green: 224/255, blue: 253/255, alpha: 1)
Expand Down
60 changes: 60 additions & 0 deletions iOS/Inventory/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// ContentView.swift
// Inventory
//
// Created by Erik Everson on 9/3/24.
// Copyright © 2024 Ditto. All rights reserved.
//

import SwiftUI
import DittoAllToolsMenu
import DittoSwift

struct ContentView: View {
@ObservedObject var dittoManager = DittoManager.shared

// Items to initially populate data. These will not be used after data has been populated.
private var viewItems: [ItemDittoModel] {
return [
ItemDittoModel(_id: "coke", counter: DittoCounter(), itemId: 0, imageName: "coke", title: "Coca-Cola", price: 2.50, detail: "A Can of Coca-Cola"),
ItemDittoModel(_id: "drpepper", counter: DittoCounter(), itemId: 1, imageName: "drpepper", title: "Dr. Pepper", price: 2.50, detail: "A Can of Dr. Pepper"),
ItemDittoModel(_id: "lays", counter: DittoCounter(), itemId: 2, imageName: "lays", title: "Lay's Classic", price: 3.99, detail: "Original Classic Lay's Bag of Chips"),
ItemDittoModel(_id: "brownies", counter: DittoCounter(), itemId: 3, imageName: "brownies", title: "Brownies", price: 6.50, detail: "Brownies, Diet Sugar Free Version"),
ItemDittoModel(_id: "blt", counter: DittoCounter(), itemId: 4, imageName: "blt", title: "Classic BLT Egg", price: 2.50, detail: "Contains Egg, Meats and Dairy")
]
}

var body: some View {
NavigationView {
List {
ForEach(dittoManager.items) { item in
RowItem(dittoManager: dittoManager, item: item, count: item.counter.value)
}
}
#if os(tvOS)
.listStyle(.grouped)
#else
.listStyle(.insetGrouped)
#endif
.navigationTitle("Inventory")
.toolbar {
ToolbarItem(placement: .topBarLeading) {
NavigationLink {
AllToolsMenu(ditto: DittoManager.shared.ditto)
} label: {
Image(systemName: "info.circle")
}
}
}
.onAppear {
dittoManager.prepopulateItemsIfAbsent(items: viewItems)
dittoManager.subscribeAllInventoryItems()
}
}
.navigationViewStyle(.stack)
}
}

#Preview {
ContentView()
}
48 changes: 0 additions & 48 deletions iOS/Inventory/DittoInfoView/BackgroundSync.swift

This file was deleted.

Loading