Skip to content

Commit

Permalink
Version 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hbiede committed Oct 4, 2023
1 parent 3c077ba commit 9ed418e
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 54 deletions.
12 changes: 8 additions & 4 deletions What's Next/Shared/Intents/ShortcutRecTypeAppEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ import AppIntents
import Foundation

@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
enum ShortcutRecTypeAppEnum: String, AppEnum {
enum ShortcutRecTypeAppEnum: String, AppEnum, ExpressibleByNilLiteral {
init(nilLiteral: ()) {
self = .movie
}

case movie
case tvShow
case book

static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Recommendation Type")
static var caseDisplayRepresentations: [Self: DisplayRepresentation] = [
.movie: .init(stringLiteral: ShortcutRecTypeAppEnum.movie.rawValue),
.tvShow: .init(stringLiteral: ShortcutRecTypeAppEnum.tvShow.rawValue),
.book: .init(stringLiteral: ShortcutRecTypeAppEnum.book.rawValue)
.movie: .init(title: "movie"),
.tvShow: .init(title: "tvShow"),
.book: .init(title: "book")
]

var description: String {
Expand Down
6 changes: 5 additions & 1 deletion What's Next/Shared/QuickActionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Foundation

class QuickActionSettings: ObservableObject {
class QuickActionSettings: Equatable, ObservableObject {
static func == (lhs: QuickActionSettings, rhs: QuickActionSettings) -> Bool {
lhs.quickAction == rhs.quickAction
}


enum ShortcutAction: String {
case ADD_REC = "AddRec"
Expand Down
6 changes: 3 additions & 3 deletions What's Next/Shared/Screens/ItemDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ItemDetailView: View {
}

@Environment(\.managedObjectContext) private var viewContext
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
@Environment(\.dismiss) var dismiss

@State private var name: String = ""
@State private var author: String = ""
Expand Down Expand Up @@ -151,7 +151,7 @@ struct ItemDetailView: View {
didSave = true
}

if didSave {
if didSave && viewContext.hasChanges {
do {
try viewContext.save()
saveItemCounts(context: viewContext)
Expand All @@ -167,7 +167,7 @@ struct ItemDetailView: View {
try viewContext.save()
} catch {}
viewContext.reset()
self.presentationMode.wrappedValue.dismiss()
self.dismiss()
}

// MARK: Undo
Expand Down
4 changes: 2 additions & 2 deletions What's Next/Shared/Screens/ItemListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CoreData

struct ItemListView: View {
@Environment(\.managedObjectContext) private var viewContext
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
@Environment(\.dismiss) var dismiss

@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Item.recommendationDate, ascending: true)],
Expand Down Expand Up @@ -63,7 +63,7 @@ struct ItemListView: View {
saveItemCounts(context: viewContext)
if items.count == 0 {
// Go back if list is empty
self.presentationMode.wrappedValue.dismiss()
self.dismiss()
}
} catch {
let nsError = error as NSError
Expand Down
70 changes: 45 additions & 25 deletions What's Next/Shared/Screens/MainScreenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@ struct MainScreenView: View {
@FetchRequest(sortDescriptors: [])
private var items: FetchedResults<Item>

@State private var showGetRec = false
@State private var showAddRec = false
@State private var showList = false

func handleQuickAction (_ newAction: QuickActionSettings.ShortcutAction?) {
if let newAction = newAction {
switch newAction {
case .ADD_REC:
showAddRec = true
case .GET_REC:
showGetRec = true
case .SHOW_LIST:
showList = true
}
}
}

// MARK: Body
var body: some View {
NavigationView {
NavigationStack {
ZStack {
Background()

Expand All @@ -32,11 +49,9 @@ struct MainScreenView: View {
.lineLimit(1)
Spacer()
Spacer()
NavigationLink(
destination: UpNextScreen().environment(\.managedObjectContext, viewContext),
tag: QuickActionSettings.ShortcutAction.GET_REC,
selection: $quickActionSettings.quickAction
) {
Button {
showGetRec = true
} label: {
Text("whats-next-menu-button", comment: "Button to get to the Up Next page")
.font(.largeTitle)
.fontWeight(.bold)
Expand All @@ -51,11 +66,9 @@ struct MainScreenView: View {
.padding(.bottom, 10)
.opacity(items.isEmpty ? 0.4 : 1)
.disabled(items.isEmpty)
NavigationLink(
destination: AddRecScreen(),
tag: QuickActionSettings.ShortcutAction.ADD_REC,
selection: $quickActionSettings.quickAction
) {
Button {
showAddRec = true
} label: {
Text("add-menu-button", comment: "Button to get to the Add Recommendation page")
.font(.title)
.fontWeight(.semibold)
Expand All @@ -64,15 +77,12 @@ struct MainScreenView: View {
.padding()
.padding(.horizontal, 20)
.background(Color.white)

}
.clipShape(Capsule())
.padding(.bottom, 10)
NavigationLink(
destination: ItemListView().environment(\.managedObjectContext, viewContext),
tag: QuickActionSettings.ShortcutAction.SHOW_LIST,
selection: $quickActionSettings.quickAction
) {
.clipShape(Capsule())
.padding(.bottom, 10)
Button {
showList = true
} label: {
Text("see-list-menu-button", comment: "Button to get to the See List page")
.font(.title)
.fontWeight(.semibold)
Expand All @@ -83,21 +93,31 @@ struct MainScreenView: View {
.background(Color.white)

}
.clipShape(Capsule())
.opacity(items.isEmpty ? 0.4 : 1)
.disabled(items.isEmpty)
.clipShape(Capsule())
.opacity(items.isEmpty ? 0.4 : 1)
.disabled(items.isEmpty)
Spacer()
}
}
.navigationDestination(isPresented: $showGetRec) {
UpNextScreen().environment(\.managedObjectContext, viewContext)
}
.navigationDestination(isPresented: $showAddRec) {
AddRecScreen()
}
.navigationDestination(isPresented: $showList) {
ItemListView().environment(\.managedObjectContext, viewContext)
}
}
.onAppear() {
handleQuickAction(quickActionSettings.quickAction)
}
#if os(iOS)
.navigationViewStyle(StackNavigationViewStyle())
#endif
.onChange(of: phase) { newPhase in
if newPhase == .background || newPhase == .inactive {
addQuickActions()
}
}
.onChange(of: quickActionSettings.quickAction, perform: handleQuickAction)
.onOpenURL { url in
quickActionSettings.quickAction =
url.absoluteString == QuickActionSettings.ShortcutAction.ADD_REC.rawValue
Expand Down
2 changes: 1 addition & 1 deletion What's Next/Shared/Screens/UpNextScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct UpNextScreen: View {
.cornerRadius(8)
.padding()

if items.filter { $0.type == selectedType.description }.count > 1 {
if items.filter({ $0.type == selectedType.description }).count > 1 {
Section {
Button("refresh-button-label", action: {
// Get new `currentItem`
Expand Down
28 changes: 16 additions & 12 deletions What's Next/What's Next.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -407,7 +407,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1410;
LastUpgradeCheck = 1400;
LastUpgradeCheck = 1500;
ORGANIZATIONNAME = com.hbiede;
TargetAttributes = {
3EA215562919F02200633654 = {
Expand Down Expand Up @@ -625,7 +625,7 @@
INFOPLIST_FILE = Widget/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "What's Next";
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 com.hbiede. All rights reserved.";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -656,7 +656,7 @@
INFOPLIST_FILE = Widget/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "What's Next";
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2022 com.hbiede. All rights reserved.";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -740,8 +740,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
BUILD_NUMBER = 16;
BUILD_VERSION = 1.3.0;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
BUILD_NUMBER = 17;
BUILD_VERSION = 1.4.0;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -777,6 +778,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -805,8 +807,9 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
BUILD_NUMBER = 16;
BUILD_VERSION = 1.3.0;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
BUILD_NUMBER = 17;
BUILD_VERSION = 1.4.0;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -842,6 +845,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -872,7 +876,7 @@
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iOS/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -901,7 +905,7 @@
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iOS/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -938,7 +942,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = $BUILD_VERSION;
PRODUCT_BUNDLE_IDENTIFIER = com.hbiede.WhatsNext;
PRODUCT_NAME = "What's Next";
Expand Down Expand Up @@ -967,7 +971,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = $BUILD_VERSION;
PRODUCT_BUNDLE_IDENTIFIER = com.hbiede.WhatsNext;
PRODUCT_NAME = "What's Next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
3 changes: 1 addition & 2 deletions What's Next/Widget/CombinedWidget/CombinedWidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ struct WhatsNextCombinedWidgetEntryView: View {

do {
guard let countsDict =
try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(testcreateEvent as Data) as?
NSMutableDictionary else {
try NSKeyedUnarchiver.unarchivedObject(ofClass: NSMutableDictionary.self, from: testcreateEvent as Data) else {
fatalError("Cannot load countsDict")
}

Expand Down
2 changes: 1 addition & 1 deletion What's Next/Widget/SingleWidget/SingleWidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct WhatsNextSingleWidgetEntryView: View {

do {
guard let countsDict =
try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(testcreateEvent as Data) as? NSMutableDictionary else {
try NSKeyedUnarchiver.unarchivedObject(ofClass: NSMutableDictionary.self, from: testcreateEvent as Data) else {
fatalError("Cannot load countsDict")
}

Expand Down

0 comments on commit 9ed418e

Please sign in to comment.