[ios] refactor PlacePageInfoViewController

- move all initial setup out from viewDidLoad

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn 2024-06-09 13:51:40 +04:00 committed by Alexander Borsuk
parent 97a0544a55
commit 11c174f254

View file

@ -114,6 +114,9 @@ class PlacePageInfoViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupViews()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
delegate?.viewWillAppear()
@ -207,7 +210,7 @@ class PlacePageInfoViewController: UIViewController {
if let wifi = placePageInfoData.wifiAvailable {
wifiView = createInfoItem(wifi, icon: UIImage(named: "ic_placepage_wifi"))
}
if let atm = placePageInfoData.atm {
atmView = createInfoItem(atm, icon: UIImage(named: "ic_placepage_atm"))
}
@ -215,7 +218,7 @@ class PlacePageInfoViewController: UIViewController {
if let level = placePageInfoData.level {
levelView = createInfoItem(level, icon: UIImage(named: "ic_placepage_level"))
}
if let capacity = placePageInfoData.capacity {
capacityView = createInfoItem(capacity, icon: UIImage(named: "ic_placepage_capacity"))
}
@ -223,11 +226,11 @@ class PlacePageInfoViewController: UIViewController {
if let wheelchair = placePageInfoData.wheelchair {
wheelchairView = createInfoItem(wheelchair, icon: UIImage(named: "ic_placepage_wheelchair"))
}
if let driveThrough = placePageInfoData.driveThrough {
driveThroughView = createInfoItem(driveThrough, icon: UIImage(named: "ic_placepage_drive_through"))
}
if let email = placePageInfoData.email {
emailView = createInfoItem(email,
icon: UIImage(named: "ic_placepage_email"),
@ -239,7 +242,7 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(email)
})
}
if let facebook = placePageInfoData.facebook {
facebookView = createInfoItem(facebook,
icon: UIImage(named: "ic_placepage_facebook"),
@ -251,7 +254,7 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(facebook)
})
}
if let instagram = placePageInfoData.instagram {
instagramView = createInfoItem(instagram,
icon: UIImage(named: "ic_placepage_instagram"),
@ -263,7 +266,7 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(instagram)
})
}
if let twitter = placePageInfoData.twitter {
twitterView = createInfoItem(twitter,
icon: UIImage(named: "ic_placepage_twitter"),
@ -275,7 +278,7 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(twitter)
})
}
if let vk = placePageInfoData.vk {
vkView = createInfoItem(vk,
icon: UIImage(named: "ic_placepage_vk"),
@ -287,7 +290,7 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(vk)
})
}
if let line = placePageInfoData.line {
lineView = createInfoItem(line,
icon: UIImage(named: "ic_placepage_line"),
@ -299,7 +302,7 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(line)
})
}
if let address = placePageInfoData.address {
addressView = createInfoItem(address,
icon: UIImage(named: "ic_placepage_adress"),
@ -307,14 +310,14 @@ class PlacePageInfoViewController: UIViewController {
self?.delegate?.didCopy(address)
})
}
if let kayak = placePageInfoData.kayak {
kayakView = createInfoItem(L("more_on_kayak"),
icon: UIImage(named: "ic_placepage_kayak"),
style: .link,
tapHandler: { [weak self] in
self?.delegate?.didPressKayak()
},
},
longPressHandler: { [weak self] in
self?.delegate?.didCopy(kayak)
})
@ -325,7 +328,7 @@ class PlacePageInfoViewController: UIViewController {
if formatId >= coordFormats.count {
formatId = 0
}
coordinatesView = createInfoItem(coordFormats[formatId],
icon: UIImage(named: "ic_placepage_coordinate"),
tapHandler: { [unowned self] in
@ -344,12 +347,6 @@ class PlacePageInfoViewController: UIViewController {
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
delegate?.viewWillAppear()
}
// MARK: private
private func createInfoItem(_ info: String,
icon: UIImage?,
style: Style = .regular,