Skip to content

Adding SwiftUI Ingredient List - #21

Draft
alexking124 wants to merge 9 commits into
masterfrom
aking/swift_ingredient_list
Draft

alexking124 wants to merge 9 commits into
masterfrom
aking/swift_ingredient_list

Conversation

@alexking124

Copy link
Copy Markdown
Collaborator

Most of the functionality is broken, but it shows the list of ingredients.

Screen Shot 2020-04-04 at 5 47 53 PM

Comment on lines +214 to +216
if (isnan(newContentOffset.y)) {
return;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some weird crashes that I needed to fix with this. 🤷‍♂ Should be fine once this is converted to Swift

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

}, label: {
Image(systemName: "xmark")
.foregroundColor(SwiftUI.Color(Color.cakeRed))
.font(Font.system(size: 20, weight: .medium, design: .default))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we try Avenir here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why is there font in here at all? This is the closing X thing, right?

Comment on lines +158 to +160
// CSIngredientListVC* ingrListVC = [[CSIngredientListVC alloc] initWithDelegate:self];
// UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:ingrListVC];
// [self presentViewController:nav animated:YES completion:nil];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up the comments.

}

extension CSIngredients {
var ingredientList: [CSIngredientGroup] {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I would name it all or ingredientGroups, because ingredientList kinda looks like [CSIngredient].

static inline CGFloat ptsPerUnit(CSScaleView *scaleView)
{
return (SCALE_TILE_HEIGHT/scaleView.unitsPerTile);
CGFloat pts = (SCALE_TILE_HEIGHT/scaleView.unitsPerTile);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... that sounds like we have some kind of a problem with the view lifecycle. It sounds like this is being called when unitsPerTile is zero?

Comment on lines +214 to +216
if (isnan(newContentOffset.y)) {
return;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

scaleView.delegate = nil;
if (cancelDeceleration)
{
NSLog(@"%f", newContentOffset.y);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up.

NavigationLink(destination: CSEditIngredientVCRepresentable(),
label: { Image(systemName: "plus")
.foregroundColor(SwiftUI.Color(Color.cakeRed))
.font(Font.system(size: 20, weight: .medium, design: .default))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Why do we need a font here at all?

}, label: {
Image(systemName: "pencil.circle")
.foregroundColor(SwiftUI.Color(Color.cakeRed))
.font(Font.system(size: 22, weight: .regular, design: .default))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question regarding font.

.navigationBarTitle("Ingredients")
.navigationBarItems(leading:
Button(action: {
print("Pressed")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fill in the action here.

Text(ingredientName)
Spacer()
Button(action: {
print("Edit Tapped")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fill in action here.

label: { Image(systemName: "plus")
.foregroundColor(SwiftUI.Color(Color.cakeRed))
.font(Font.system(size: 20, weight: .medium, design: .default))
}))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we missing the "Reset to Defaults" button here somewhere?

@alexking124
alexking124 marked this pull request as draft April 26, 2020 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants