Skip to content

Commit

Permalink
Various UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimillian committed May 20, 2020
1 parent f79da05 commit 2e875a8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 38 deletions.
4 changes: 2 additions & 2 deletions ACHNBrowserUI/ACHNBrowserUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@
CODE_SIGN_ENTITLEMENTS = ACHNBrowserUI/ACHNBrowserUI.entitlements;
CODE_SIGN_IDENTITY = "Apple Development: Thomas Ricouard (7MB55D6BJ5)";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 052012020;
CURRENT_PROJECT_VERSION = 052042020;
DEVELOPMENT_ASSET_PATHS = "\"ACHNBrowserUI/Preview Content\"";
DEVELOPMENT_TEAM = Z6P74P6T99;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1538,7 +1538,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 052012020;
CURRENT_PROJECT_VERSION = 052042020;
DEVELOPMENT_ASSET_PATHS = "\"ACHNBrowserUI/Preview Content\"";
DEVELOPMENT_TEAM = Z6P74P6T99;
ENABLE_PREVIEWS = YES;
Expand Down
4 changes: 2 additions & 2 deletions ACHNBrowserUI/ACHNBrowserUI/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ You can cancel anytime with your iTunes account settings. Any unused portion of
"Squirrel" = "Écureuil";
"Tiger" = "Tigre";
"Wolf" = "Loup";
"Like" = "Aime"
"Gifts ideas" = "Idées de cadeaux"
"Like" = "Aime";
"Gifts ideas" = "Idées de cadeaux";

// ListingRow
"Make an Offer" = "Faire une offre";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,20 @@ public class Items: ObservableObject {
if let likes = villagersLike.values.first(where: { $0.id == villager })?.likes {
return Deferred {
Future { [weak self] resolve in
var categories = Category.APIFurnitures()
categories.append(contentsOf: Category.wardrobe())
var categories = Category.villagersGifts()
guard let weakself = self else {
return resolve(.success([]))
}

var results: [Item] = []
for (_, dic) in weakself.categories.enumerated() where categories.contains(dic.key) {
let items = dic.value
.filter{ $0.colors?.isEmpty == false }
var added = 0
.filter{ $0.colors?.isEmpty == false && $0.styles?.isEmpty == false }
for item in items {
let colorsMatch = item.colors!.filter{ likes.contains($0.lowercased()) }
if colorsMatch.count >= 2 {
let styleMatch = item.styles!.filter{ likes.contains($0.lowercased()) }
if colorsMatch.count >= 1 && styleMatch.count >= 1 {
results.append(item)
added += 1
}
if added >= 4 {
break
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class UserCollection: ObservableObject {
private let encoder = JSONEncoder()
private let decoder = JSONDecoder()

private static let recordZone = "UserZone"
private static let recordType = "UserCollection"
private static let recordId = CKRecord.ID(recordName: "CurrentUserCollection")
private static let assetKey = "data"
Expand Down Expand Up @@ -136,19 +135,8 @@ public class UserCollection: ObservableObject {
}

private func subscribeToCloudKit() {
let zone = CKRecordZone(zoneName: Self.recordZone)
cloudKitDatabase?.save(zone) { (_, _) in }

cloudKitDatabase?.fetchAllSubscriptions { (sub, _) in
if let sub = sub?.first {
let notif = CKSubscription.NotificationInfo()
notif.shouldSendContentAvailable = true
sub.notificationInfo = notif

let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [sub],
subscriptionIDsToDelete: nil)
self.cloudKitDatabase?.add(operation)
} else {
cloudKitDatabase?.fetchAllSubscriptions { (subs, _) in
if subs == nil || subs?.isEmpty == true {
self.createSubscription()
}
}
Expand All @@ -166,14 +154,20 @@ public class UserCollection: ObservableObject {

public func reloadFromCloudKit() {
cloudKitDatabase?.fetch(withRecordID: Self.recordId) { (record, error) in
self.currentRecord = record
if let asset = record?[Self.assetKey] as? CKAsset,
let url = asset.fileURL {
if record == nil {
DispatchQueue.main.async {
self.isSynched = true
_ = self.loadCollection(file: url)
try? FileManager.default.removeItem(at: self.filePath)
try? FileManager.default.copyItem(at: url, to: self.filePath)
self.save()
}
} else {
self.currentRecord = record
if let asset = record?[Self.assetKey] as? CKAsset,
let url = asset.fileURL {
DispatchQueue.main.async {
self.isSynched = true
_ = self.loadCollection(file: url)
try? FileManager.default.removeItem(at: self.filePath)
try? FileManager.default.copyItem(at: url, to: self.filePath)
}
}
}
}
Expand All @@ -197,8 +191,10 @@ public class UserCollection: ObservableObject {
record[Self.assetKey] = asset

cloudKitDatabase?.save(record) { (record, error) in
self.currentRecord = record
self.isSynched = true
DispatchQueue.main.async {
self.currentRecord = record
self.isSynched = true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ public enum Category: String, CaseIterable {
}

public static func nature() -> [Category] {
return [.fish, .bugs, .fossils]
[.fish, .bugs, .fossils]
}

public static func icons() -> [Category] {
return [.housewares, .recipes, .floors, .rugs, .wallpapers, .posters,
[.housewares, .recipes, .floors, .rugs, .wallpapers, .posters,
.fencing, .music, .tools, .nookmiles, .construction, .tops,
.bottoms, .dressup, .headwear, .accessories, .socks, .bags, .umbrellas,
.fish, .bugs, .fossils]
}

public static func villagersGifts() -> [Category] {
[.tops, .dressup, .headwear, .accessories]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public struct Item: Codable, Equatable, Identifiable, Hashable {
public let activeTimes: [[String: Int]]?
public let set: String?
public let tag: String?
public let styles: [String]?
public let themes: [String]?
public let colors: [String]?
}
Expand Down Expand Up @@ -176,5 +177,6 @@ public let static_item = Item(name: "Acoustic guitar",
activeTimes: nil,
set: nil,
tag: "Instrument",
styles: nil,
themes: nil,
colors: nil)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct TodayCollectionProgressSection: View {
shareButton.padding(.top, 12)
} else {
RowLoadingView(isLoading: .constant(true))
.frame(height: 100)
}
}
.animation(.interactiveSpring())
Expand Down

0 comments on commit 2e875a8

Please sign in to comment.