Skip to content

Commit

Permalink
Merge pull request #7 from nonstrict-hq/update
Browse files Browse the repository at this point in the history
Refactor internals
  • Loading branch information
tomlokhorst authored Apr 20, 2023
2 parents c33bfaa + 73ff736 commit 3570021
Show file tree
Hide file tree
Showing 48 changed files with 377 additions and 634 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"images" : [
{
"idiom" : "tv"
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// CloudStorage_Example2App.swift
// Untitled 1
//
// Created by Nonstrict on 2023-04-20.
//

import SwiftUI

@main
struct CloudStorage_Example2App: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// ContentView.swift
// Untitled 1
//
// Created by Nonstrict on 2023-04-20.
//

import SwiftUI
import CloudStorage

struct ContentView: View {

var body: some View {
NavigationStack {
NavigationLink("Detail") {
DetailView()
}
}
}
}


struct DetailView: View {


var body: some View {
VStack {
TopView()
Divider()
MiddleView()
Divider()
BottomView()
}
.padding()
}
}


struct TopView: View {
@CloudStorage("myBool") var myBool = false

var body: some View {
Toggle("My Bool", isOn: $myBool)
}
}

struct MiddleView: View {
@CloudStorage("myBool") var myBool = false

var body: some View {
Toggle("My Bool", isOn: $myBool)
}
}

struct BottomView: View {
@StateObject var viewModel = ViewModel()

var body: some View {
Toggle("My Bool", isOn: $viewModel.myBool)

Button("Toggle") { viewModel.myBool.toggle() }
}
}

class ViewModel: ObservableObject {
@CloudStorage("myBool") var myBool = false
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
E20EC87424B0639E006C9FB8 /* CloudStorage-iOS13.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CloudStorage-iOS13.app"; sourceTree = BUILT_PRODUCTS_DIR; };
E20EC87424B0639E006C9FB8 /* CloudStorage-iOS14.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CloudStorage-iOS14.app"; sourceTree = BUILT_PRODUCTS_DIR; };
E20EC87724B0639E006C9FB8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
E20EC87924B0639E006C9FB8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
E20EC87B24B0639E006C9FB8 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
E20EC87D24B0639E006C9FB8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E20EC88024B0639E006C9FB8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
E20EC88324B0639E006C9FB8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
E20EC88524B0639E006C9FB8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E22E35F724B212160023F35A /* CloudStorage-iOS13.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "CloudStorage-iOS13.entitlements"; sourceTree = "<group>"; };
E22E35F724B212160023F35A /* CloudStorage-iOS14.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "CloudStorage-iOS14.entitlements"; sourceTree = "<group>"; };
E25CFD8924C2EE5000EBA240 /* MyColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyColor.swift; sourceTree = "<group>"; };
E25CFD8D24C3173E00EBA240 /* CloudStorage */ = {isa = PBXFileReference; lastKnownFileType = folder; name = CloudStorage; path = ../..; sourceTree = "<group>"; };
E25CFD9224C3242D00EBA240 /* CloudStorage+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CloudStorage+Codable.swift"; sourceTree = "<group>"; };
Expand All @@ -49,7 +49,7 @@
isa = PBXGroup;
children = (
E25CFD8D24C3173E00EBA240 /* CloudStorage */,
E20EC87624B0639E006C9FB8 /* CloudStorage-iOS13 */,
E20EC87624B0639E006C9FB8 /* CloudStorage-iOS14 */,
E20EC87524B0639E006C9FB8 /* Products */,
E25CFD8E24C31F5000EBA240 /* Frameworks */,
);
Expand All @@ -58,12 +58,12 @@
E20EC87524B0639E006C9FB8 /* Products */ = {
isa = PBXGroup;
children = (
E20EC87424B0639E006C9FB8 /* CloudStorage-iOS13.app */,
E20EC87424B0639E006C9FB8 /* CloudStorage-iOS14.app */,
);
name = Products;
sourceTree = "<group>";
};
E20EC87624B0639E006C9FB8 /* CloudStorage-iOS13 */ = {
E20EC87624B0639E006C9FB8 /* CloudStorage-iOS14 */ = {
isa = PBXGroup;
children = (
E25CFD9124C322B200EBA240 /* Resources */,
Expand All @@ -72,7 +72,7 @@
E25CFD8924C2EE5000EBA240 /* MyColor.swift */,
E25CFD9224C3242D00EBA240 /* CloudStorage+Codable.swift */,
);
path = "CloudStorage-iOS13";
path = "CloudStorage-iOS14";
sourceTree = "<group>";
};
E20EC87F24B0639E006C9FB8 /* Preview Content */ = {
Expand All @@ -93,7 +93,7 @@
E25CFD9124C322B200EBA240 /* Resources */ = {
isa = PBXGroup;
children = (
E22E35F724B212160023F35A /* CloudStorage-iOS13.entitlements */,
E22E35F724B212160023F35A /* CloudStorage-iOS14.entitlements */,
E20EC87724B0639E006C9FB8 /* AppDelegate.swift */,
E20EC87924B0639E006C9FB8 /* SceneDelegate.swift */,
E20EC87D24B0639E006C9FB8 /* Assets.xcassets */,
Expand All @@ -106,9 +106,9 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
E20EC87324B0639E006C9FB8 /* CloudStorage-iOS13 */ = {
E20EC87324B0639E006C9FB8 /* CloudStorage-iOS14 */ = {
isa = PBXNativeTarget;
buildConfigurationList = E20EC88824B0639E006C9FB8 /* Build configuration list for PBXNativeTarget "CloudStorage-iOS13" */;
buildConfigurationList = E20EC88824B0639E006C9FB8 /* Build configuration list for PBXNativeTarget "CloudStorage-iOS14" */;
buildPhases = (
E20EC87024B0639E006C9FB8 /* Sources */,
E20EC87124B0639E006C9FB8 /* Frameworks */,
Expand All @@ -118,12 +118,12 @@
);
dependencies = (
);
name = "CloudStorage-iOS13";
name = "CloudStorage-iOS14";
packageProductDependencies = (
E25CFD8F24C31F5000EBA240 /* CloudStorage */,
);
productName = "CloudStorage-iOS13";
productReference = E20EC87424B0639E006C9FB8 /* CloudStorage-iOS13.app */;
productName = "CloudStorage-iOS14";
productReference = E20EC87424B0639E006C9FB8 /* CloudStorage-iOS14.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand All @@ -140,7 +140,7 @@
};
};
};
buildConfigurationList = E20EC86F24B0639E006C9FB8 /* Build configuration list for PBXProject "CloudStorage-iOS13" */;
buildConfigurationList = E20EC86F24B0639E006C9FB8 /* Build configuration list for PBXProject "CloudStorage-iOS14" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
Expand All @@ -155,7 +155,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
E20EC87324B0639E006C9FB8 /* CloudStorage-iOS13 */,
E20EC87324B0639E006C9FB8 /* CloudStorage-iOS14 */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -251,7 +251,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.5;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -306,7 +306,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.5;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -320,18 +320,18 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "CloudStorage-iOS13/Resources/CloudStorage-iOS13.entitlements";
CODE_SIGN_ENTITLEMENTS = "CloudStorage-iOS14/Resources/CloudStorage-iOS14.entitlements";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"CloudStorage-iOS13/Preview Content\"";
DEVELOPMENT_ASSET_PATHS = "\"CloudStorage-iOS14/Preview Content\"";
DEVELOPMENT_TEAM = "";
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = NO;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "CloudStorage-iOS13/Resources/Info.plist";
INFOPLIST_FILE = "CloudStorage-iOS14/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.example.CloudStorage-iOS13";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.CloudStorage-iOS14";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -343,18 +343,18 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "CloudStorage-iOS13/Resources/CloudStorage-iOS13.entitlements";
CODE_SIGN_ENTITLEMENTS = "CloudStorage-iOS14/Resources/CloudStorage-iOS14.entitlements";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"CloudStorage-iOS13/Preview Content\"";
DEVELOPMENT_ASSET_PATHS = "\"CloudStorage-iOS14/Preview Content\"";
DEVELOPMENT_TEAM = "";
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = NO;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "CloudStorage-iOS13/Resources/Info.plist";
INFOPLIST_FILE = "CloudStorage-iOS14/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.example.CloudStorage-iOS13";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.CloudStorage-iOS14";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -365,7 +365,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
E20EC86F24B0639E006C9FB8 /* Build configuration list for PBXProject "CloudStorage-iOS13" */ = {
E20EC86F24B0639E006C9FB8 /* Build configuration list for PBXProject "CloudStorage-iOS14" */ = {
isa = XCConfigurationList;
buildConfigurations = (
E20EC88624B0639E006C9FB8 /* Debug */,
Expand All @@ -374,7 +374,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
E20EC88824B0639E006C9FB8 /* Build configuration list for PBXNativeTarget "CloudStorage-iOS13" */ = {
E20EC88824B0639E006C9FB8 /* Build configuration list for PBXNativeTarget "CloudStorage-iOS14" */ = {
isa = XCConfigurationList;
buildConfigurations = (
E20EC88924B0639E006C9FB8 /* Debug */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// CloudStorage+Codable.swift
// CloudStorage-iOS14
//
// Created by Tom Lokhorst on 2020-07-18.
//

import SwiftUI
import CloudStorage

private let sync = CloudStorageSync.shared

extension CloudStorage where Value: Codable {
public init(wrappedValue: Value, _ key: String) {
func syncGet() -> Value {
guard let data = sync.data(for: key) else { return wrappedValue }
do {
let decoder = PropertyListDecoder()
let value = try decoder.decode(Value.self, from: data)
return value
} catch {
assertionFailure("\(error)")
return wrappedValue
}
}
func syncSet(_ newValue: Value) {
do {
let encoder = PropertyListEncoder()
let data = try encoder.encode(newValue)
sync.set(data, for: key)
} catch {
assertionFailure("\(error)")
}
}
self.init(keyName: key, syncGet: syncGet, syncSet: syncSet)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ContentView.swift
// CloudStorage-iOS13
// CloudStorage-iOS14
//
// Created by Tom Lokhorst on 2020-07-04.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// MyColor.swift
// CloudStorage-iOS13
// CloudStorage-iOS14
//
// Created by Tom Lokhorst on 2020-07-18.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AppDelegate.swift
// CloudStorage-iOS13
// CloudStorage-iOS14
//
// Created by Tom Lokhorst on 2020-07-04.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SceneDelegate.swift
// CloudStorage-iOS13
// CloudStorage-iOS14
//
// Created by Tom Lokhorst on 2020-07-04.
//
Expand Down
Loading

0 comments on commit 3570021

Please sign in to comment.