Skip to content

Commit 2e875a8

Browse files
committed
Various UI fixes
1 parent f79da05 commit 2e875a8

File tree

7 files changed

+36
-38
lines changed

7 files changed

+36
-38
lines changed

ACHNBrowserUI/ACHNBrowserUI.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@
15071507
CODE_SIGN_ENTITLEMENTS = ACHNBrowserUI/ACHNBrowserUI.entitlements;
15081508
CODE_SIGN_IDENTITY = "Apple Development: Thomas Ricouard (7MB55D6BJ5)";
15091509
CODE_SIGN_STYLE = Manual;
1510-
CURRENT_PROJECT_VERSION = 052012020;
1510+
CURRENT_PROJECT_VERSION = 052042020;
15111511
DEVELOPMENT_ASSET_PATHS = "\"ACHNBrowserUI/Preview Content\"";
15121512
DEVELOPMENT_TEAM = Z6P74P6T99;
15131513
ENABLE_PREVIEWS = YES;
@@ -1538,7 +1538,7 @@
15381538
CODE_SIGN_IDENTITY = "iPhone Developer";
15391539
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
15401540
CODE_SIGN_STYLE = Manual;
1541-
CURRENT_PROJECT_VERSION = 052012020;
1541+
CURRENT_PROJECT_VERSION = 052042020;
15421542
DEVELOPMENT_ASSET_PATHS = "\"ACHNBrowserUI/Preview Content\"";
15431543
DEVELOPMENT_TEAM = Z6P74P6T99;
15441544
ENABLE_PREVIEWS = YES;

ACHNBrowserUI/ACHNBrowserUI/fr.lproj/Localizable.strings

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ You can cancel anytime with your iTunes account settings. Any unused portion of
340340
"Squirrel" = "Écureuil";
341341
"Tiger" = "Tigre";
342342
"Wolf" = "Loup";
343-
"Like" = "Aime"
344-
"Gifts ideas" = "Idées de cadeaux"
343+
"Like" = "Aime";
344+
"Gifts ideas" = "Idées de cadeaux";
345345

346346
// ListingRow
347347
"Make an Offer" = "Faire une offre";

ACHNBrowserUI/ACHNBrowserUI/packages/Backend/Sources/Backend/environments/Items.swift

+4-9
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,20 @@ public class Items: ObservableObject {
147147
if let likes = villagersLike.values.first(where: { $0.id == villager })?.likes {
148148
return Deferred {
149149
Future { [weak self] resolve in
150-
var categories = Category.APIFurnitures()
151-
categories.append(contentsOf: Category.wardrobe())
150+
var categories = Category.villagersGifts()
152151
guard let weakself = self else {
153152
return resolve(.success([]))
154153
}
155154

156155
var results: [Item] = []
157156
for (_, dic) in weakself.categories.enumerated() where categories.contains(dic.key) {
158157
let items = dic.value
159-
.filter{ $0.colors?.isEmpty == false }
160-
var added = 0
158+
.filter{ $0.colors?.isEmpty == false && $0.styles?.isEmpty == false }
161159
for item in items {
162160
let colorsMatch = item.colors!.filter{ likes.contains($0.lowercased()) }
163-
if colorsMatch.count >= 2 {
161+
let styleMatch = item.styles!.filter{ likes.contains($0.lowercased()) }
162+
if colorsMatch.count >= 1 && styleMatch.count >= 1 {
164163
results.append(item)
165-
added += 1
166-
}
167-
if added >= 4 {
168-
break
169164
}
170165
}
171166
}

ACHNBrowserUI/ACHNBrowserUI/packages/Backend/Sources/Backend/environments/UserCollection.swift

+19-23
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class UserCollection: ObservableObject {
3333
private let encoder = JSONEncoder()
3434
private let decoder = JSONDecoder()
3535

36-
private static let recordZone = "UserZone"
3736
private static let recordType = "UserCollection"
3837
private static let recordId = CKRecord.ID(recordName: "CurrentUserCollection")
3938
private static let assetKey = "data"
@@ -136,19 +135,8 @@ public class UserCollection: ObservableObject {
136135
}
137136

138137
private func subscribeToCloudKit() {
139-
let zone = CKRecordZone(zoneName: Self.recordZone)
140-
cloudKitDatabase?.save(zone) { (_, _) in }
141-
142-
cloudKitDatabase?.fetchAllSubscriptions { (sub, _) in
143-
if let sub = sub?.first {
144-
let notif = CKSubscription.NotificationInfo()
145-
notif.shouldSendContentAvailable = true
146-
sub.notificationInfo = notif
147-
148-
let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [sub],
149-
subscriptionIDsToDelete: nil)
150-
self.cloudKitDatabase?.add(operation)
151-
} else {
138+
cloudKitDatabase?.fetchAllSubscriptions { (subs, _) in
139+
if subs == nil || subs?.isEmpty == true {
152140
self.createSubscription()
153141
}
154142
}
@@ -166,14 +154,20 @@ public class UserCollection: ObservableObject {
166154

167155
public func reloadFromCloudKit() {
168156
cloudKitDatabase?.fetch(withRecordID: Self.recordId) { (record, error) in
169-
self.currentRecord = record
170-
if let asset = record?[Self.assetKey] as? CKAsset,
171-
let url = asset.fileURL {
157+
if record == nil {
172158
DispatchQueue.main.async {
173-
self.isSynched = true
174-
_ = self.loadCollection(file: url)
175-
try? FileManager.default.removeItem(at: self.filePath)
176-
try? FileManager.default.copyItem(at: url, to: self.filePath)
159+
self.save()
160+
}
161+
} else {
162+
self.currentRecord = record
163+
if let asset = record?[Self.assetKey] as? CKAsset,
164+
let url = asset.fileURL {
165+
DispatchQueue.main.async {
166+
self.isSynched = true
167+
_ = self.loadCollection(file: url)
168+
try? FileManager.default.removeItem(at: self.filePath)
169+
try? FileManager.default.copyItem(at: url, to: self.filePath)
170+
}
177171
}
178172
}
179173
}
@@ -197,8 +191,10 @@ public class UserCollection: ObservableObject {
197191
record[Self.assetKey] = asset
198192

199193
cloudKitDatabase?.save(record) { (record, error) in
200-
self.currentRecord = record
201-
self.isSynched = true
194+
DispatchQueue.main.async {
195+
self.currentRecord = record
196+
self.isSynched = true
197+
}
202198
}
203199
}
204200
}

ACHNBrowserUI/ACHNBrowserUI/packages/Backend/Sources/Backend/models/Category.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,17 @@ public enum Category: String, CaseIterable {
145145
}
146146

147147
public static func nature() -> [Category] {
148-
return [.fish, .bugs, .fossils]
148+
[.fish, .bugs, .fossils]
149149
}
150150

151151
public static func icons() -> [Category] {
152-
return [.housewares, .recipes, .floors, .rugs, .wallpapers, .posters,
152+
[.housewares, .recipes, .floors, .rugs, .wallpapers, .posters,
153153
.fencing, .music, .tools, .nookmiles, .construction, .tops,
154154
.bottoms, .dressup, .headwear, .accessories, .socks, .bags, .umbrellas,
155155
.fish, .bugs, .fossils]
156156
}
157+
158+
public static func villagersGifts() -> [Category] {
159+
[.tops, .dressup, .headwear, .accessories]
160+
}
157161
}

ACHNBrowserUI/ACHNBrowserUI/packages/Backend/Sources/Backend/models/Item.swift

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public struct Item: Codable, Equatable, Identifiable, Hashable {
8888
public let activeTimes: [[String: Int]]?
8989
public let set: String?
9090
public let tag: String?
91+
public let styles: [String]?
9192
public let themes: [String]?
9293
public let colors: [String]?
9394
}
@@ -176,5 +177,6 @@ public let static_item = Item(name: "Acoustic guitar",
176177
activeTimes: nil,
177178
set: nil,
178179
tag: "Instrument",
180+
styles: nil,
179181
themes: nil,
180182
colors: nil)

ACHNBrowserUI/ACHNBrowserUI/views/todayDashboard/TodayCollectionProgressSection.swift

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct TodayCollectionProgressSection: View {
4040
shareButton.padding(.top, 12)
4141
} else {
4242
RowLoadingView(isLoading: .constant(true))
43+
.frame(height: 100)
4344
}
4445
}
4546
.animation(.interactiveSpring())

0 commit comments

Comments
 (0)