This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Labels to TaxonomiesService and Product view
Labels were partially implemented but still needed to be incorporated into the API Models and Network Services. In doing so, it was discovered that the Taxonomies weren't being downloaded to Realm on first launch of the app as intended. After fixing that and adding the Label taxonomy to Models, they were successfully retrieved and stored. Then, to allow Labels to be displayed by ProductDetailViewController, they were included in the OFFJson mapping. The downloaded taxonomies were then used to translate Labels and code was added to fix translation of Categories. Lastly, the functionality to link link Labels to their OFF urls was added. Closes #719
- Loading branch information
1 parent
6d770aa
commit 0578263
Showing
13 changed files
with
146 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Label.swift | ||
// OpenFoodFacts | ||
// | ||
// Created by Alexander Scott Beaty on 8/23/20. | ||
// | ||
|
||
import Foundation | ||
import RealmSwift | ||
import ObjectMapper | ||
|
||
class Label: Object { | ||
|
||
@objc dynamic var code = "" | ||
|
||
let parents = List<String>() | ||
let children = List<String>() | ||
let names = List<Tag>() | ||
|
||
@objc dynamic var mainName = "" // name in the language of the app, for sorting | ||
@objc dynamic var indexedNames = "" // all names concatenated, for search | ||
|
||
convenience init(code: String, parents: [String], children: [String], names: [Tag]) { | ||
self.init() | ||
self.code = code | ||
|
||
self.parents.removeAll() | ||
self.parents.append(objectsIn: parents) | ||
|
||
self.children.removeAll() | ||
self.children.append(objectsIn: children) | ||
|
||
self.names.removeAll() | ||
self.names.append(objectsIn: names) | ||
|
||
self.mainName = names.chooseForCurrentLanguage()?.value ?? "" | ||
self.indexedNames = names.map({ (tag) -> String in | ||
return tag.languageCode.appending(":").appending(tag.value) | ||
}).joined(separator: " ||| ") // group all names to be able to query on only one field, independently of language | ||
} | ||
|
||
override static func primaryKey() -> String? { | ||
return "code" | ||
} | ||
|
||
override static func indexedProperties() -> [String] { | ||
return ["mainName", "indexedNames"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters