-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All Swift from the ingredient list view down #49
base: master
Are you sure you want to change the base?
Conversation
* General project changes: * Changed the target iOS version to 16. Our analytics shows that the oldest version of iOS used by our users in the recent past is 16.2. * Our project seemed to have no consistent structure with regards to XCode groups and directory structure. I aligned both XCode groups and directory structure with the following: - UI: layout of views. - Design Language: the design conventions used throughout the app. If we ever want to reskin the app, it should be possible to do so by merely changing things inside this folder. - Model: describes the data that powers the app. - Misc Utils: utilities used broadly throughout the app, such as facilities for assertion checking. Both Swift and ObjC sourcecode lives in this hierarchy, but I put ObjC code within groups/directories named `ObjC` within the hierarchy. * The old UIKit-based `CSIngredientListVC` written in ObjC has been replaced with SwiftUI-based `IngredientListView`. Although our usecase is seemingly basic, I've found it difficult to do _exactly_ what we want. I assume this might be much easier for you guys, so I sprinkled a bunch of O&A questions in there. Almost everything downstream of IngredientListView is now in Swift. The sole exception that I can think of is CSGlassView. * The model has almost fully migrated to Swift. Structs are used to represent ingredient groups, ingredients and other aspects of the model. IngredientsStore is the sole class in the data model and represents the entrypoint into the persistence layer. A couple of ObjC model classes remain to support some legacy ObjC UI code: * `CSIngredient` - `Ingredient` struct is bridged to `CSIngredient` by use of a dictionary. * `CSUnit` - used across both ObjC and Swift code. * Colors have moved into our assetcatalog for smoother support of dark mode or other reskinning. `CSColor` enum was created to facilitate access to the assetcatalog. Eventually, we should get to the point where colors are accessed exclusively through `CSColor`. * All text styling has been centralized under the `CSTextStyle` struct. Facilities have been introduced to apply `CSTextStyle` to SwiftUI's `Text` as well as UIKit's `UILabel`, `UIButton` and `UITextField`. There is no styling of text outside of `CSTextStyle`, though this isn't currently automatically enforced.
24f0113
to
2d0b579
Compare
case accent = "AccentColor" | ||
case subheadingText = "SubheadingTextColor" | ||
case contentText = "ContentTextColor" | ||
case clear = "Clear" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these reference the names in xcasset catalog?
|
||
// TODO: There should be no reference to any color except through this enum | ||
|
||
enum CSColor: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait why are there 2 CSColor enums?
struct IngredientRef { | ||
let storedIngredientGroupIndex: Int | ||
let ingredientIndex: Int | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow all this to add your own ingredients? do we have logging for how many people actually use that feature? idk how useful it is.
} | ||
} | ||
.listStyle(PlainListStyle()) | ||
// O&A Question: There's apparently no way to customize the appearance of the search bar... what do you suggest? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I've never used ".searchable". We could just add our own search bar I guess. Are we just trying to style it like the rest of the app?
// Even with this, the tap hit box for editing ingredients is still not perfect :( | ||
// Also, it turns out that for some reason long-tapping anywhere in the cell triggers this action :( | ||
.overlay( | ||
NavigationLink( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk, again, I've never used NavigationLink. All the navigation I've done has been custom Airbnb stuff, so idk what we have out of the box.
ObjC
within the hierarchy. The top-level groups/directories are:CSIngredientListVC
written in ObjC has been replaced with SwiftUI-basedIngredientListView
. Although our usecase is seemingly basic, I've found it difficult to do exactly what we want. I assume this might be much easier for you guys, so I sprinkled a bunch of O&A questions in there. Almost everything downstream of IngredientListView is now in Swift. The sole exception that I can think of is CSGlassView.CSIngredient
-Ingredient
struct is bridged toCSIngredient
by use of a dictionary.CSUnit
- used across both ObjC and Swift code.CSColor
enum was created to facilitate access to the assetcatalog. Eventually, we should get to the point where colors are accessed exclusively throughCSColor
.CSTextStyle
struct. Facilities have been introduced to applyCSTextStyle
to SwiftUI'sText
as well as UIKit'sUILabel
,UIButton
andUITextField
. There is no styling of text outside ofCSTextStyle
, though this isn't currently automatically enforced.