Skip to content
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

Add sharing selected target view and slide in / out animation #31

Merged
merged 7 commits into from
Mar 29, 2019

Conversation

eJamesLin
Copy link
Contributor

@eJamesLin eJamesLin commented Mar 28, 2019

About

  • Add sharing selected target view
  • Add slide in / out animation

Note

  • remove the mocked entry button later

@eJamesLin eJamesLin changed the title Add sharing selected target view slide and in out animation Add sharing selected target view and slide in / out animation Mar 28, 2019
@eJamesLin eJamesLin force-pushed the feature/selected-share-target-view branch from e009096 to 298e624 Compare March 28, 2019 16:04
@eJamesLin eJamesLin changed the base branch from feature/share-table-view-controller to v5.2 March 28, 2019 16:04
@codecov-io
Copy link

codecov-io commented Mar 28, 2019

Codecov Report

Merging #31 into v5.2 will decrease coverage by 1.09%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             v5.2      #31     +/-   ##
=========================================
- Coverage   80.57%   79.48%   -1.1%     
=========================================
  Files         163      164      +1     
  Lines        6385     6473     +88     
=========================================
  Hits         5145     5145             
- Misses       1240     1328     +88
Impacted Files Coverage Δ
LineSDK/LineSDK/SharingUI/SelectedTargetView.swift 0% <0%> (ø)
...ineSDK/LineSDK/SharingUI/ShareViewController.swift 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d50086...7a5e2f2. Read the comment docs.

enum Design {
static let height = CGFloat(79)
static let bgColor = "#F7F8FA"
static let borderColor = "#E6E7EA"
Copy link
Member

Choose a reason for hiding this comment

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

Can you change the Design as the ones in #30

  1. Use a var getter instead of let stored property (to make the memory a bit cleaner)
  2. Use UIColor(hex6:) for colors instead of String (to make it more efficient)
  3. Add all design style related things here, like borderWidth, backgroundColor, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. let me modified.

@objc
func foo() {
selectedTargetView.mode = (selectedTargetView.mode == .show) ? .hide : .show
selectedTargetView.updateLayout(withAnimated: true)
Copy link
Member

Choose a reason for hiding this comment

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

It seems that every mode changing is bound to a call of updateLayout(withAnimated:). Can we combine these two, hide both mode and updateLayout as private, then provide an easier API like setMode(_ mode: Mode, animated: Bool)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍


var mode = Mode.hide

func updateLayout(withAnimated animated: Bool) {
Copy link
Member

@onevcat onevcat Mar 29, 2019

Choose a reason for hiding this comment

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

The API name is not common. Maybe updateLayout(animated flag: Bool) would be more swifty. See the similar one from Apple.

Copy link
Member

Choose a reason for hiding this comment

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

Or you can call it "withAnimation:", but that indicates that you want to pass an animation object which can define what exactly the animation is. For a Bool, I guess it is proper to use xxx(animated:)

yAnchor = view.safeAreaLayoutGuide.bottomAnchor
} else {
yAnchor = bottomLayoutGuide.topAnchor
}
Copy link
Member

Choose a reason for hiding this comment

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

static let borderColor = "#E6E7EA"
}

private var slideAnimationViewTopConstraint: NSLayoutConstraint?
Copy link
Member

Choose a reason for hiding this comment

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

Since slideAnimationViewTopConstraint would be always there unless a programmer error happens. So let's change it to NSLayoutConstraint! to make the failure explicitly.

… to make the memory a bit cleaner, applied UIColor(hex6:)
self.alpha = alpha
self.layoutIfNeeded()
}
}
Copy link
Member

@onevcat onevcat Mar 29, 2019

Choose a reason for hiding this comment

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

I guess if animated == false, the alpha is not getting updated now. Maybe we also need the case for non-animated?

Copy link
Member

Choose a reason for hiding this comment

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

And I suggest also call layoutIfNeeded() in the animated == false statement, to trigger an immediate layout. Otherwise, any code depends on the layout would not work until the next main run loop, which causes confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I missed the alpha setup in no animation case.
Agree. the layoutIfNeeded in animated == false will be more clear.

Copy link
Member

@onevcat onevcat left a comment

Choose a reason for hiding this comment

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

Review is done. Please check the comments before it can be merged.

@onevcat onevcat merged commit 81fa5d4 into v5.2 Mar 29, 2019
@onevcat onevcat deleted the feature/selected-share-target-view branch March 29, 2019 09:43
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