-
Notifications
You must be signed in to change notification settings - Fork 5
Jw #13
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
Open
wooooooong
wants to merge
9
commits into
develop
Choose a base branch
from
jw
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Jw #13
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fbd4ae3
Merge pull request #6 from TileImageTeamiOS/develop
grohong 7630f0b
Merge pull request #7 from TileImageTeamiOS/develop
grohong 8680d3a
Merge pull request #8 from TileImageTeamiOS/develop
grohong d381377
Merge pull request #9 from TileImageTeamiOS/develop
grohong ea9370a
Merge pull request #10 from TileImageTeamiOS/develop
grohong db6e2dd
[fix]: Pod name
grohong dfa4637
[cofig]: build passing set
grohong ee7d4d3
refactoring minimap
wooooooong 09c26b2
refactoring focused box
wooooooong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -7,45 +7,91 @@ | |
| // | ||
|
|
||
| import UIKit | ||
| import AVFoundation | ||
|
|
||
| open class THMinimapView: UIView { | ||
| public var focusedBorderWidth: CGFloat = 2.0 | ||
| public var focusedBorderColor: CGColor = UIColor.yellow.cgColor | ||
| private var focusedBoxView: UIView = UIView() | ||
| private var scrollView: UIScrollView = UIScrollView() | ||
| private var minimapImageView: UIImageView = UIImageView() | ||
| private var scrollImageView: UIImageView = UIImageView() | ||
| private var downSizeRatio: CGFloat = 4.0 | ||
| private var image = UIImage() | ||
| private var minimapImage: UIImage? | ||
| convenience init(scrollView: UIScrollView, downSizeRatio: CGFloat, image: UIImage) { | ||
| self.init(frame: CGRect.zero) | ||
| setUp(scrollView: scrollView, downSizeRatio: downSizeRatio, image: image, minimapImage: nil) | ||
| } | ||
| convenience init(scrollView: UIScrollView, downSizeRatio: CGFloat, image: UIImage, minimapImage: UIImage) { | ||
| self.init(frame: CGRect.zero) | ||
| setUp(scrollView: scrollView, downSizeRatio: downSizeRatio, image: image, minimapImage: minimapImage) | ||
| } | ||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| } | ||
| required public init?(coder aDecoder: NSCoder) { | ||
| super.init(coder: aDecoder) | ||
| } | ||
| private func setUp(scrollView: UIScrollView, downSizeRatio: CGFloat, image: UIImage, minimapImage: UIImage?) { | ||
| let width = scrollView.frame.width / downSizeRatio | ||
| let height = scrollView.frame.height / downSizeRatio | ||
| self.frame = CGRect(x: width * (downSizeRatio - 1), y: height * (downSizeRatio-1), width: width, height: height) | ||
|
|
||
| private var dataSource: THMinimapDataSource? | ||
|
|
||
| public var minimapImageView: UIImageView? | ||
| public var focusedBoxView: UIView? | ||
|
|
||
| open func set(dataSource: THMinimapDataSource) { | ||
| self.dataSource = dataSource | ||
|
|
||
| scrollView.contentInsetAdjustmentBehavior = .never | ||
| scrollImageView = UIImageView(frame: CGRect(x: 0, y: 0, | ||
| width: scrollView.frame.width, | ||
| height: scrollView.frame.height)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scrollImageView = UIImageView(frame: CGRect(origin: .zero, size: scrollView.frame.size))This style looks better for minimizing code. |
||
| minimapImageView = UIImageView(frame: CGRect(x: 0, y: 0, | ||
| width: dataSource.minimapImageWidth, | ||
| height: dataSource.minimapImageHeight)) | ||
| minimapImageView?.image = dataSource.thumbnailImage | ||
| minimapImageView?.contentMode = .scaleAspectFit | ||
| width: self.frame.width, | ||
| height: self.frame.height)) | ||
|
|
||
| focusedBoxView = UIView(frame: CGRect(x: 0, y: 0, | ||
| width: dataSource.minimapImageWidth, | ||
| height: dataSource.minimapImageHeight)) | ||
| focusedBoxView?.layer.borderWidth = dataSource.borderWidth | ||
| focusedBoxView?.layer.borderColor = dataSource.borderColor.cgColor | ||
| focusedBoxView = UIView() | ||
|
|
||
| self.addSubview(minimapImageView!) | ||
| self.addSubview(focusedBoxView!) | ||
| scrollView.addSubview(scrollImageView) | ||
| self.addSubview(minimapImageView) | ||
| self.addSubview(focusedBoxView) | ||
|
|
||
| updateConstraints() | ||
| scrollImageView.image = image | ||
| if let minimapImage = minimapImage { | ||
| minimapImageView.image = minimapImage | ||
| focusedBoxView.frame = AVMakeRect(aspectRatio: minimapImage.size, insideRect: minimapImageView.bounds) | ||
| } else { | ||
| minimapImageView.image = image | ||
| focusedBoxView.frame = AVMakeRect(aspectRatio: image.size, insideRect: minimapImageView.bounds) | ||
| } | ||
| scrollImageView.contentMode = .scaleAspectFit | ||
| minimapImageView.contentMode = .scaleAspectFit | ||
| focusedBoxView.layer.borderWidth = focusedBorderWidth | ||
| focusedBoxView.layer.borderColor = focusedBorderColor | ||
| } | ||
|
|
||
| open override func updateConstraints() { | ||
| super.updateConstraints() | ||
| self.removeConstraints(self.constraints) | ||
|
|
||
| if let dataSource = dataSource { | ||
| self.heightAnchor.constraint(equalToConstant: dataSource.minimapImageHeight).isActive = true | ||
| self.widthAnchor.constraint(equalToConstant: dataSource.minimapImageWidth).isActive = true | ||
|
|
||
| self.trailingAnchor.constraint(equalTo: dataSource.scrollView.trailingAnchor, constant: 50).isActive = true | ||
| self.bottomAnchor.constraint(equalTo: dataSource.scrollView.bottomAnchor, constant: 50).isActive = true | ||
| public func getScrolledImageView() -> UIImageView { | ||
| return scrollImageView | ||
| } | ||
| public func resize(scrollView: UIScrollView) { | ||
| let scrollBox = AVMakeRect(aspectRatio: (scrollImageView.image?.size)!, insideRect: scrollImageView.frame) | ||
| let box = AVMakeRect(aspectRatio: (minimapImageView.image?.size)!, insideRect: minimapImageView.frame) | ||
| let zoomScale = scrollView.zoomScale | ||
| let widthRatio = box.size.width / scrollBox.size.width | ||
| let heightRatio = box.size.height / scrollBox.size.height | ||
| var newX = (scrollView.contentOffset.x * widthRatio) | ||
| var newY = (scrollView.contentOffset.y * heightRatio) | ||
| var newWidth = minimapImageView.frame.size.width / zoomScale | ||
| var newHeight = minimapImageView.frame.size.height / zoomScale | ||
| if box.origin.x > newX { | ||
| newWidth -= (box.origin.x - newX) | ||
| newX = box.origin.x | ||
| } | ||
| if box.origin.y > newY { | ||
| newHeight -= (box.origin.y - newY) | ||
| newY = box.origin.y | ||
| } | ||
| if (newX + newWidth) > (box.origin.x + box.size.width) { | ||
| newWidth = box.size.width - newX + box.origin.x | ||
| } | ||
| if (newY + newHeight) > (box.origin.y + box.size.height) { | ||
| newHeight = box.size.height - newY + box.origin.y | ||
| } | ||
| focusedBoxView.frame = CGRect(x: newX, y: newY, width: newWidth, height: newHeight) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is
THMinimapViewcan still be used from storyboard withsetUp(scrollView:downSizeRatio:image:minimapImage)?Call default
setUp()function, or you should handle required property from another function.(not from init)For example,