refactor(Share): improve code of sharing feature
* When trying to work on but cannot fix the initial issue. At
least these improvements can be merged
MODIFY
ACHNBrowserUI/ACHNBrowserUI.xcodeproj/project.pbxproj
ACHNBrowserUI/ACHNBrowserUI.xcodeproj/project.pbxproj
3D9AB093248257DF00B47041 /* CustomTaskFormViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9AB092248257DF00B47041 /* CustomTaskFormViewModel.swift */; };
3DECE21B2483BC83001F24BA /* EditMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DECE21A2483BC82001F24BA /* EditMode.swift */; };
4C16FB41247AC9B0009F24E3 /* GridStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C16FB40247AC9B0009F24E3 /* GridStack.swift */; };
+ 4C30BFC3249627FD003E96A2 /* Sequence+Unique.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C30BFC2249627FC003E96A2 /* Sequence+Unique.swift */; };
4C6E95FD24842F690074433B /* Collection+SafeDirectAccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C6E95FC24842F690074433B /* Collection+SafeDirectAccess.swift */; };
4C7F555D248B91C80089F26C /* TodayVillagerVisitsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C7F555C248B91C80089F26C /* TodayVillagerVisitsSection.swift */; };
690A72C924752BF4001E7294 /* villagersLikes in Resources */ = {isa = PBXBuildFile; fileRef = 690A72C824752BF4001E7294 /* villagersLikes */; };
4C2D6773245F4EA2005831C4 /* TurnipsChartAverageCurve.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartAverageCurve.swift; sourceTree = "<group>"; };
4C2D6775245F4F55005831C4 /* TurnipsChartMinMaxCurves.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartMinMaxCurves.swift; sourceTree = "<group>"; };
4C2D6777245F4FE8005831C4 /* TurnipsChartMinBuyPriceCurve.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartMinBuyPriceCurve.swift; sourceTree = "<group>"; };
+ 4C30BFC2249627FC003E96A2 /* Sequence+Unique.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Sequence+Unique.swift"; sourceTree = "<group>"; };
4C382EE7244E418800F446BA /* DismissingKeyboardOnSwipe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissingKeyboardOnSwipe.swift; sourceTree = "<group>"; };
4C6E95FC24842F690074433B /* Collection+SafeDirectAccess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+SafeDirectAccess.swift"; sourceTree = "<group>"; };
4C7F2F772461F10300930928 /* TurnipsChartVerticalLegend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnipsChartVerticalLegend.swift; sourceTree = "<group>"; };
693E2BC7246697FC00B85CB8 /* Image.swift */,
3DECE21A2483BC82001F24BA /* EditMode.swift */,
4C6E95FC24842F690074433B /* Collection+SafeDirectAccess.swift */,
+ 4C30BFC2249627FC003E96A2 /* Sequence+Unique.swift */,
);
path = extensions;
sourceTree = "<group>";
69157BC92471A5A1005B9002 /* TurnipsChartGrid.swift in Sources */,
4C7F555D248B91C80089F26C /* TodayVillagerVisitsSection.swift in Sources */,
69157BCA2471A5A1005B9002 /* CollectionRowView.swift in Sources */,
+ 4C30BFC3249627FD003E96A2 /* Sequence+Unique.swift in Sources */,
AE0B5B5C247AD7590075CF16 /* DesignFormViewModel.swift in Sources */,
AE51C2E324801D5D00F074EC /* ChoreListRowView.swift in Sources */,
69E67EF0249376DF00ED7AC8 /* DodoCodeRow.swift in Sources */,

MODIFY
ACHNBrowserUI/ACHNBrowserUI/representables/ActivityControllerView.swift
ACHNBrowserUI/ACHNBrowserUI/representables/ActivityControllerView.swift
@@ -11,18 +11,19 @@ import SwiftUI
#if !os(tvOS)
public struct ActivityControllerView: UIViewControllerRepresentable {
-
- public let activityItems: [Any]
- public let applicationActivities: [UIActivity]?
-
- public init(activityItems: [Any], applicationActivities: [UIActivity]?) {
- self.activityItems = activityItems
- self.applicationActivities = applicationActivities
- }
+ @Environment(\.presentationMode) var presentation
+ public var activityItems: [Any]
+ public var applicationActivities: [UIActivity]?
public func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityControllerView>) -> UIActivityViewController {
- return UIActivityViewController(activityItems: activityItems,
- applicationActivities: applicationActivities)
+ let controller = UIActivityViewController(
+ activityItems: activityItems,
+ applicationActivities: applicationActivities
+ )
+ controller.completionWithItemsHandler = { _, _, _, _ in
+ self.presentation.wrappedValue.dismiss()
+ }
+ return controller
}
public func updateUIViewController(_ uiViewController: UIActivityViewController,

MODIFY
ACHNBrowserUI/ACHNBrowserUI/viewModels/VillagerDetailViewModel.swift
ACHNBrowserUI/ACHNBrowserUI/viewModels/VillagerDetailViewModel.swift
@@ -37,7 +37,10 @@ public class VillagerDetailViewModel: ObservableObject {
self?.preferredItems = items
})
- self.likes = Array(Set(Items.shared.villagersLike.values.first(where: { $0.id == filename })!.likes))
+ self.likes = Items.shared.villagersLike.values
+ .first(where: { $0.id == filename })?
+ .likes
+ .unique()
} else {
self.villagerItems = nil

MODIFY
ACHNBrowserUI/ACHNBrowserUI/views/items/detail/ItemDetailSource.swift
ACHNBrowserUI/ACHNBrowserUI/views/items/detail/ItemDetailSource.swift
@@ -32,7 +32,6 @@ class ItemDetailSource: NSObject, UIActivityItemSource {
metadata.title = name
metadata.imageProvider = NSItemProvider(object: image)
- metadata.imageProvider = NSItemProvider(object: image)
return metadata
}

MODIFY
ACHNBrowserUI/ACHNBrowserUI/views/shared/Sheet.swift
ACHNBrowserUI/ACHNBrowserUI/views/shared/Sheet.swift
@@ -11,7 +11,8 @@ import Backend
struct Sheet: View {
enum SheetType: Identifiable {
- case safari(URL), share(content: [Any])
+ case safari(URL)
+ case share(content: [Any])
case about
case userListForm(editingList: UserList?)
case customTasks(collection: UserCollection)

refactor(Share): improve code of sharing feature (#260)

* When trying to work on #251, but cannot fix the initial issue. At
least these improvements can be merged