Skip to content
This repository was archived by the owner on Aug 18, 2023. It is now read-only.
Draft
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
60 changes: 58 additions & 2 deletions BrainMarksWidgets/BrainMarksWidgets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import WidgetKit
import SwiftUI
import Intents

struct Provider: TimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
Expand All @@ -19,6 +20,7 @@ struct Provider: TimelineProvider {
}

func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {

var entries: [SimpleEntry] = []

// Generate a timeline consisting of five entries an hour apart, starting from the current date.
Expand All @@ -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()
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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))
}
}
10 changes: 10 additions & 0 deletions BrainMarksWidgetsExtension.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.suzgupta.brainmarks</string>
</array>
</dict>
</plist>
27 changes: 27 additions & 0 deletions LocalCategoryModel.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
58 changes: 40 additions & 18 deletions brain-marks.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
14F5BDE61EAA4A2DB9030734 /* AmplifyModels.swift */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.swift; name = AmplifyModels.swift; path = amplify/generated/models/AmplifyModels.swift; sourceTree = "<group>"; };
1E886624D4EE4F64B9160A75 /* amplifytools.xcconfig */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = text.xcconfig; path = amplifytools.xcconfig; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
2A7C408728EFCC3700F73DF5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2A7C408928EFCC3700F73DF5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2AE728C32912DB6900785853 /* brain-marks.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "brain-marks.entitlements"; sourceTree = "<group>"; };
45B4425328EF5AC800FB0B27 /* AppIconSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconSettings.swift; sourceTree = "<group>"; };
45B4425628EF5EA300FB0B27 /* 8 Rainbow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "8 Rainbow.png"; sourceTree = "<group>"; };
45B4425828EF5EA300FB0B27 /* 4 Beach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "4 Beach.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -249,6 +258,7 @@
children = (
2A7C408028EFCC3600F73DF5 /* WidgetKit.framework */,
2A7C408228EFCC3600F73DF5 /* SwiftUI.framework */,
2A2B5DEF290F4BEF0066D29A /* Intents.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -409,6 +419,8 @@
FF39432A262FD05700A3623B /* Categories */ = {
isa = PBXGroup;
children = (
2A41044A29156A4F00EFB98B /* LocalCategoryModel.swift */,
2A41044D29156BB600EFB98B /* LocalTweetModel.swift */,
FF39432C262FD07D00A3623B /* Views */,
FF6DCBF12623530400EC366F /* CategoryListViewModel.swift */,
940E3C61272648310038D6AC /* CategorySheetViewModel.swift */,
Expand Down Expand Up @@ -458,6 +470,7 @@
FFEBBB2D26223F75000F475F = {
isa = PBXGroup;
children = (
2A2DD2BB2926FCAD00FB71C9 /* BrainMarksWidgetsExtension.entitlements */,
6940242370A54E53B82BF75C /* AmplifyModels */,
6D7FDBA2D37342B39C7F1C69 /* AmplifyConfig */,
FFEBBB3826223F75000F475F /* brain-marks */,
Expand All @@ -483,6 +496,7 @@
FFEBBB3826223F75000F475F /* brain-marks */ = {
isa = PBXGroup;
children = (
2AE728C32912DB6900785853 /* brain-marks.entitlements */,
FF3942FF262E847000A3623B /* Add */,
FF39430E262E863000A3623B /* AmplifyModelExtensions */,
FF39432A262FD05700A3623B /* Categories */,
Expand Down Expand Up @@ -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;
};
Expand All @@ -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 */,
Expand All @@ -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 */,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -1091,15 +1113,15 @@
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 = (
"$(inherited)",
"@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";
Expand All @@ -1113,15 +1135,15 @@
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 = (
"$(inherited)",
"@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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ extension AWSTweet {
userVerified: false)
]
}

Loading