diff --git a/BrainMarksWidgets/BrainMarksWidgets.swift b/BrainMarksWidgets/BrainMarksWidgets.swift index b22386b..4e5ac55 100644 --- a/BrainMarksWidgets/BrainMarksWidgets.swift +++ b/BrainMarksWidgets/BrainMarksWidgets.swift @@ -7,6 +7,7 @@ import WidgetKit import SwiftUI +import Intents struct Provider: TimelineProvider { func placeholder(in context: Context) -> SimpleEntry { @@ -19,6 +20,7 @@ struct Provider: TimelineProvider { } func getTimeline(in context: Context, completion: @escaping (Timeline) -> Void) { + var entries: [SimpleEntry] = [] // Generate a timeline consisting of five entries an hour apart, starting from the current date. @@ -35,14 +37,30 @@ struct Provider: TimelineProvider { } struct SimpleEntry: TimelineEntry { - let date: Date + let date: Date + func readContainer() { + guard let URL = FileManager.default.containerURL( + forSecurityApplicationGroupIdentifier: "group.com.suzgupta.brainmarks" + ) else { + return + } + let decoder = JSONDecoder() + if let codeData = try? Data(contentsOf: URL.appendingPathComponent("categories.json")) { + do { + let contents = try decoder.decode([LocalCategory].self, from: codeData) + print(contents) + } catch { + print("Error: Can't decode contents") + } + } + } } struct BrainMarksCreateCategoryEntryView : View { var entry: Provider.Entry var body: some View { - + ZStack { Image("littleLogo") .resizable() @@ -72,12 +90,31 @@ struct BrainMarksAddURLView : View { } } +struct BrainMarksLockScreenEntryView : View { + var entry: Provider.Entry + + var body: some View { + ZStack { + Circle().fill(Color.accentColor).opacity(0.75) + Image(systemName: "gamecontroller") + .font(.largeTitle) + } + .onAppear() { + let entry = SimpleEntry(date: Date()) + entry.readContainer() + } + // will need to pass which category to open as a URL parameter + .widgetURL(URL(string: "brainmarks://openCategory")) + } +} + @main struct BrainMarksWidgetBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { BrainMarksCreateCategory() BrainMarksAddURL() + BrainMarksLockScreenWidget() // more widgets can go here } } @@ -119,3 +156,22 @@ struct BrainMarksCreateCategory_Previews: PreviewProvider { .previewContext(WidgetPreviewContext(family: .systemSmall)) } } +struct BrainMarksLockScreenWidget: Widget { + let kind: String = "BrainMarksLockScreen" + + var body: some WidgetConfiguration { + StaticConfiguration(kind: kind, provider: Provider()) { entry in + BrainMarksLockScreenEntryView(entry: entry) + } + .configurationDisplayName("View Category") + .description("Quickly access a Brain Marks category") + .supportedFamilies([.accessoryCircular]) + } +} + +struct BrainMarksLockScreenWidget_Previews: PreviewProvider { + static var previews: some View { + BrainMarksLockScreenEntryView(entry: SimpleEntry(date: Date())) + .previewContext(WidgetPreviewContext(family: .accessoryCircular)) + } +} diff --git a/BrainMarksWidgetsExtension.entitlements b/BrainMarksWidgetsExtension.entitlements new file mode 100644 index 0000000..1815d24 --- /dev/null +++ b/BrainMarksWidgetsExtension.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.suzgupta.brainmarks + + + diff --git a/LocalCategoryModel.swift b/LocalCategoryModel.swift new file mode 100644 index 0000000..d8424cc --- /dev/null +++ b/LocalCategoryModel.swift @@ -0,0 +1,27 @@ +// +// LocalCategoryModel.swift +// brain-marks +// +// Created by Susannah Skyer Gupta on 11/4/22. +// + +import Foundation + +public struct LocalCategory: Codable { + public let id: String + public var name: String + public var imageName: String? + public var tweets: [LocalTweet]? + public var categoryThumbnail: String? + + public init(id: String = UUID().uuidString, + name: String, + imageName: String? = "folder", + tweets: [LocalTweet] = [] + ) { + self.id = id + self.name = name + self.imageName = imageName + self.tweets = tweets + } +} diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index d2323d1..cf94e66 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -8,6 +8,10 @@ /* Begin PBXBuildFile section */ 20636BDDDBEF4EAE9CCE9D9E /* amplifyconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = ECA1CF04DB754255822691F2 /* amplifyconfiguration.json */; }; + 2A41044B29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */; }; + 2A41044C29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */; }; + 2A41044E29156BB600EFB98B /* LocalTweetModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */; }; + 2A41044F29156BB600EFB98B /* LocalTweetModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */; }; 2A7C408128EFCC3600F73DF5 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */; }; 2A7C408328EFCC3600F73DF5 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */; }; 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */; }; @@ -125,12 +129,17 @@ 0AA54EDF3B34443CA9D530E5 /* AWSTweet.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AWSTweet.swift; path = amplify/generated/models/AWSTweet.swift; sourceTree = ""; }; 14F5BDE61EAA4A2DB9030734 /* AmplifyModels.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AmplifyModels.swift; path = amplify/generated/models/AmplifyModels.swift; sourceTree = ""; }; 1E886624D4EE4F64B9160A75 /* amplifytools.xcconfig */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.xcconfig; path = amplifytools.xcconfig; sourceTree = ""; }; + 2A2B5DEF290F4BEF0066D29A /* Intents.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Intents.framework; path = System/Library/Frameworks/Intents.framework; sourceTree = SDKROOT; }; + 2A2DD2BB2926FCAD00FB71C9 /* BrainMarksWidgetsExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BrainMarksWidgetsExtension.entitlements; sourceTree = ""; }; + 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalCategoryModel.swift; sourceTree = SOURCE_ROOT; }; + 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalTweetModel.swift; sourceTree = ""; }; 2A7C407E28EFCC3600F73DF5 /* BrainMarksWidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BrainMarksWidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; 2A7C408528EFCC3600F73DF5 /* BrainMarksWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrainMarksWidgets.swift; sourceTree = ""; }; 2A7C408728EFCC3700F73DF5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2A7C408928EFCC3700F73DF5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2AE728C32912DB6900785853 /* brain-marks.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "brain-marks.entitlements"; sourceTree = ""; }; 45B4425328EF5AC800FB0B27 /* AppIconSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconSettings.swift; sourceTree = ""; }; 45B4425628EF5EA300FB0B27 /* 8 Rainbow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "8 Rainbow.png"; sourceTree = ""; }; 45B4425828EF5EA300FB0B27 /* 4 Beach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "4 Beach.png"; sourceTree = ""; }; @@ -249,6 +258,7 @@ children = ( 2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */, 2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */, + 2A2B5DEF290F4BEF0066D29A /* Intents.framework */, ); name = Frameworks; sourceTree = ""; @@ -409,6 +419,8 @@ FF39432A262FD05700A3623B /* Categories */ = { isa = PBXGroup; children = ( + 2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */, + 2A41044D29156BB600EFB98B /* LocalTweetModel.swift */, FF39432C262FD07D00A3623B /* Views */, FF6DCBF12623530400EC366F /* CategoryListViewModel.swift */, 940E3C61272648310038D6AC /* CategorySheetViewModel.swift */, @@ -458,6 +470,7 @@ FFEBBB2D26223F75000F475F = { isa = PBXGroup; children = ( + 2A2DD2BB2926FCAD00FB71C9 /* BrainMarksWidgetsExtension.entitlements */, 6940242370A54E53B82BF75C /* AmplifyModels */, 6D7FDBA2D37342B39C7F1C69 /* AmplifyConfig */, FFEBBB3826223F75000F475F /* brain-marks */, @@ -483,6 +496,7 @@ FFEBBB3826223F75000F475F /* brain-marks */ = { isa = PBXGroup; children = ( + 2AE728C32912DB6900785853 /* brain-marks.entitlements */, FF3942FF262E847000A3623B /* Add */, FF39430E262E863000A3623B /* AmplifyModelExtensions */, FF39432A262FD05700A3623B /* Categories */, @@ -745,7 +759,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2A41044C29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */, 2A7C408628EFCC3600F73DF5 /* BrainMarksWidgets.swift in Sources */, + 2A41044F29156BB600EFB98B /* LocalTweetModel.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -762,6 +778,7 @@ FFCB1097263E31D400544309 /* ReturnedTweet.swift in Sources */, DBF50B55272467CF000D8B25 /* SettingsView.swift in Sources */, 5F118BE728EC0BE9003E15F2 /* Logger+Ext.swift in Sources */, + 2A41044B29156A4F00EFB98B /* LocalCategoryModel.swift in Sources */, FF21986F269FE57D00FFB406 /* AsyncImage.swift in Sources */, D3D5E0E5271C811E00752DCD /* InfoViewModel.swift in Sources */, FFEB1B5826A9F9C300682C37 /* Alert.swift in Sources */, @@ -771,6 +788,7 @@ DB64F8A52726BD5D00361E86 /* Contributor.swift in Sources */, A2F449912622829D00725FEA /* CategoryList.swift in Sources */, 896E0E3B28EEE03E009994F4 /* RequestBuilder.swift in Sources */, + 2A41044E29156BB600EFB98B /* LocalTweetModel.swift in Sources */, A2F4498C2622802B00725FEA /* CategoryRow.swift in Sources */, FF5990692622DD61004DF328 /* DataStoreManager.swift in Sources */, FFCB1099263E3E2D00544309 /* CategorySheetView.swift in Sources */, @@ -864,9 +882,10 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = BrainMarksWidgetsExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrainMarksWidgets/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = BrainMarksWidgets; @@ -878,7 +897,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksWidgets; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks.BrainMarksWidgets; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -893,9 +912,10 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_ENTITLEMENTS = BrainMarksWidgetsExtension.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrainMarksWidgets/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = BrainMarksWidgets; @@ -907,7 +927,7 @@ "@executable_path/../../Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks.BrainMarksWidgets; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks.BrainMarksWidgets; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1042,18 +1062,19 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = "brain-marks/brain-marks.entitlements"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"brain-marks/Preview Content\""; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "brain-marks/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1066,18 +1087,19 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = "brain-marks/brain-marks.entitlements"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"brain-marks/Preview Content\""; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = "brain-marks/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MARKETING_VERSION = 1.1; - PRODUCT_BUNDLE_IDENTIFIER = com.mikaelacaron.brainmarks; + PRODUCT_BUNDLE_IDENTIFIER = com.suzgupta.brainmarks; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -1091,7 +1113,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1099,7 +1121,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksTests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1113,7 +1135,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -1121,7 +1143,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksTests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksTests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1134,14 +1156,14 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksUITests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksUITests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1154,14 +1176,14 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Y535846H6P; + DEVELOPMENT_TEAM = N76WE33BQK; INFOPLIST_FILE = "brain-marksUITests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.mikaelacaron.brain-marksUITests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.suzgupta.brain-marksUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift b/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift index 6939155..2b6ee3e 100644 --- a/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift +++ b/brain-marks/AmplifyModelExtensions/AWSTweet+Extension.swift @@ -81,4 +81,3 @@ extension AWSTweet { userVerified: false) ] } - diff --git a/brain-marks/Categories/CategoryListViewModel.swift b/brain-marks/Categories/CategoryListViewModel.swift index fba0ee5..fe53c9d 100644 --- a/brain-marks/Categories/CategoryListViewModel.swift +++ b/brain-marks/Categories/CategoryListViewModel.swift @@ -18,6 +18,27 @@ final class CategoryListViewModel: ObservableObject { init() { getCategoryOrder() } + + func writeToContainer() { + guard let URL = FileManager.default.containerURL( + forSecurityApplicationGroupIdentifier: "group.com.suzgupta.brainmarks" + ) else { + return + } + let widgetContents = categories + let archiveURL = URL + .appendingPathComponent("categories.json") + print(">>> \(archiveURL)") + let encoder = JSONEncoder() + if let dataToSave = try? encoder.encode(widgetContents) { + do { + try dataToSave.write(to: archiveURL) + } catch { + print("Error: Can't write contents") + return + } + } + } func getCategories() { categories = [] @@ -26,7 +47,9 @@ final class CategoryListViewModel: ObservableObject { case .success(let categories): DispatchQueue.main.async { self.categories = self.sortCategories(categories) + self.writeToContainer() } + case .failure(let error): Logger.dataStore.error("Error fetching categories: \(error)") } diff --git a/brain-marks/Categories/LocalTweetModel.swift b/brain-marks/Categories/LocalTweetModel.swift new file mode 100644 index 0000000..bf2b272 --- /dev/null +++ b/brain-marks/Categories/LocalTweetModel.swift @@ -0,0 +1,43 @@ +// +// LocalTweetModel.swift +// brain-marks +// +// Created by Susannah Skyer Gupta on 11/4/22. +// + +import Foundation + +public struct LocalTweet: Codable { + public let id: String + public var tweetID: String + public var text: String? + public var timeStamp: String? + public var authorName: String? + public var authorUsername: String? + public var profileImageURL: String? + public var photosURL: [String]? + public var category: LocalCategory? + public var userVerified: Bool? + + public init(id: String = UUID().uuidString, + tweetID: String, + text: String? = nil, + timeStamp: String? = nil, + authorName: String? = nil, + authorUsername: String? = nil, + profileImageURL: String? = nil, + photosURL: [String]? = [], + category: LocalCategory? = nil, + userVerified: Bool? = nil) { + self.id = id + self.tweetID = tweetID + self.text = text + self.timeStamp = timeStamp + self.authorName = authorName + self.authorUsername = authorUsername + self.profileImageURL = profileImageURL + self.photosURL = photosURL + self.category = category + self.userVerified = userVerified + } +} diff --git a/brain-marks/Categories/Views/CategoryList.swift b/brain-marks/Categories/Views/CategoryList.swift index 4b5cc27..10c7667 100644 --- a/brain-marks/Categories/Views/CategoryList.swift +++ b/brain-marks/Categories/Views/CategoryList.swift @@ -105,6 +105,9 @@ struct CategoryList: View { showingCategorySheet = true case "addTweet": showAddURLView = true + case "openCategory": + print("Test implementation displays TweetList for first saved category") + TweetList(category: viewModel.categories.first!) default: return } diff --git a/brain-marks/Info.plist b/brain-marks/Info.plist index 193eead..54a5519 100644 --- a/brain-marks/Info.plist +++ b/brain-marks/Info.plist @@ -165,6 +165,10 @@ 1 LSRequiresIPhoneOS + NSUserActivityTypes + + ConfigurationIntent + UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/brain-marks/brain-marks.entitlements b/brain-marks/brain-marks.entitlements new file mode 100644 index 0000000..1815d24 --- /dev/null +++ b/brain-marks/brain-marks.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.com.suzgupta.brainmarks + + +