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

[iOS] Add Speaker View #604

Merged
merged 7 commits into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ios-base/DroidKaigi 2020/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} else {
let window = UIWindow(frame: UIScreen.main.bounds)
UINavigationBar.appearance().isTranslucent = false
Copy link
Member

Choose a reason for hiding this comment

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

Please add this 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙇


let backButtonBackgroundImage = #imageLiteral(resourceName: "ic_back")
Copy link
Member

Choose a reason for hiding this comment

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

👍

UINavigationBar.appearance().backIndicatorImage = backButtonBackgroundImage
UINavigationBar.appearance().backIndicatorTransitionMaskImage = backButtonBackgroundImage

let vc = FilterViewController()
let nvc = NavigationController(rootViewController: vc)
let root = NavigationDrawerController(rootViewController: nvc, leftViewController: SidebarViewController.instantiate(rootViewController: nvc))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_back.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
5 changes: 5 additions & 0 deletions ios-base/DroidKaigi 2020/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let windowScene = (scene as? UIWindowScene) else { return }
let window = UIWindow(windowScene: windowScene)
UINavigationBar.appearance().isTranslucent = false

let backButtonBackgroundImage = #imageLiteral(resourceName: "ic_back")
UINavigationBar.appearance().backIndicatorImage = backButtonBackgroundImage
UINavigationBar.appearance().backIndicatorTransitionMaskImage = backButtonBackgroundImage

let vc = FilterViewController()
let nvc = NavigationController(rootViewController: vc)
let root = NavigationDrawerController(rootViewController: nvc, leftViewController: SidebarViewController.instantiate(rootViewController: nvc))
Expand Down
16 changes: 14 additions & 2 deletions ios-base/DroidKaigi 2020/Session/Views/Cells/SessionCell.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import MaterialComponents
import Nuke
import UIKit
import RxCocoa
import RxSwift

final class SessionCell: UICollectionViewCell {
static let identifier = "SessionCell"
Expand Down Expand Up @@ -30,14 +32,16 @@ final class SessionCell: UICollectionViewCell {
@IBOutlet weak var minutesAndRoomLabel: UILabel!
@IBOutlet weak var speakersStackView: UIStackView!

private var disposeBag = DisposeBag()

override func awakeFromNib() {
super.awakeFromNib()
translatesAutoresizingMaskIntoConstraints = false
widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width).isActive = true
}

func addSpeakerView(imageURL: URL?, speakerName: String) {
let view = UIView()
func addSpeakerView(imageURL: URL?, speakerName: String, speakerTapHandler: @escaping () -> ()) {
let view = UIControl()
let speakerIconView = UIImageView()
if let imageURL = imageURL {
let options = ImageLoadingOptions(transition: .fadeIn(duration: 0.3))
Expand Down Expand Up @@ -68,11 +72,19 @@ final class SessionCell: UICollectionViewCell {

speakerIconView.layer.cornerRadius = 16
speakerIconView.clipsToBounds = true

view.rx.controlEvent(.touchDown)
.subscribe(onNext: {
speakerTapHandler()
})
.disposed(by: disposeBag)
}

override func prepareForReuse() {
super.prepareForReuse()

disposeBag = DisposeBag()

speakersStackView.subviews.forEach { subview in
subview.removeFromSuperview()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ final class FilterViewController: UIViewController {
embeddedView?.frame = containerView.bounds
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

navigationController?.navigationBar.barTintColor = ApplicationScheme.shared.colorScheme.primaryColor
navigationController?.navigationBar.tintColor = ApplicationScheme.shared.colorScheme.onPrimaryColor
}

private func frameForEmbeddedController() -> CGRect {
var embeddedFrame = view.bounds
var insetHeader = UIEdgeInsets()
Expand Down Expand Up @@ -78,9 +85,8 @@ final class FilterViewController: UIViewController {
action: nil)
navigationItem.leftBarButtonItems = [menuItem, logoItem]
navigationItem.rightBarButtonItems = [searchItem]
navigationController?.navigationBar.barTintColor = ApplicationScheme.shared.colorScheme.primaryColor
navigationController?.navigationBar.tintColor = ApplicationScheme.shared.colorScheme.onPrimaryColor
navigationController?.navigationBar.shadowImage = UIImage()
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
edgesForExtendedLayout = []

menuItem.rx.tap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ final class SessionViewController: UIViewController {
}
})
.disposed(by: disposeBag)
dataSource.onTapSpeaker
.emit(onNext: { [weak self] speaker in
self?.navigationController?.pushViewController(SpeakerViewController.instantiate(speaker: speaker), animated: true)
})
.disposed(by: disposeBag)
}

func showSuggestView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ final class SessionViewDataSource: NSObject, UICollectionViewDataSource {
typealias Element = [Session]
var items: Element = []

var onTapSpeaker: Signal<Speaker> {
return onTapSpeakerRelay.asSignal()
}

private var previousTimeString = ""
private let disposeBag = DisposeBag()
private let onTapSpeakerRelay = PublishRelay<Speaker>()

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
Expand All @@ -28,7 +34,9 @@ final class SessionViewDataSource: NSObject, UICollectionViewDataSource {
speakers = speechSession.speakers
}
speakers.forEach { speaker in
cell.addSpeakerView(imageURL: URL(string: speaker.imageUrl ?? ""), speakerName: speaker.name)
cell.addSpeakerView(imageURL: URL(string: speaker.imageUrl ?? ""), speakerName: speaker.name) { [weak self] in
self?.onTapSpeakerRelay.accept(speaker)
}
}

if previousTimeString != session.startTimeText {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="uOd-Md-Mqj">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Speaker View Controller-->
<scene sceneID="bmM-5m-QN8">
<objects>
<viewController id="uOd-Md-Mqj" customClass="SpeakerViewController" customModule="DroidKaigi_2020" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Aci-wR-Oop">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="amj-hh-azz">
<rect key="frame" x="24" y="44" width="366" height="818"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zxq-Au-f6x">
<rect key="frame" x="0.0" y="0.0" width="366" height="688"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="XWk-lo-a4J">
<rect key="frame" x="133" y="8" width="100" height="100"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="hzT-1Y-3ma"/>
<constraint firstAttribute="height" constant="100" id="uUr-Fx-2bY"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0C4-aA-7aL">
<rect key="frame" x="91" y="132" width="184" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="184" id="Bhi-Ji-EU4"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O53-5d-nTd">
<rect key="frame" x="91" y="177" width="184" height="487"/>
<constraints>
<constraint firstAttribute="width" constant="184" id="daI-hr-dtb"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="0.0" alpha="0.37538512323943662" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="O53-5d-nTd" firstAttribute="centerX" secondItem="zxq-Au-f6x" secondAttribute="centerX" id="474-V0-znd"/>
<constraint firstItem="XWk-lo-a4J" firstAttribute="centerX" secondItem="zxq-Au-f6x" secondAttribute="centerX" id="6w5-c7-Vlu"/>
<constraint firstItem="0C4-aA-7aL" firstAttribute="top" secondItem="XWk-lo-a4J" secondAttribute="bottom" constant="24" id="Bw9-xE-tog"/>
<constraint firstItem="O53-5d-nTd" firstAttribute="top" secondItem="0C4-aA-7aL" secondAttribute="bottom" constant="16" id="XWb-CF-C88"/>
<constraint firstItem="0C4-aA-7aL" firstAttribute="centerX" secondItem="zxq-Au-f6x" secondAttribute="centerX" id="gHl-S0-JIo"/>
<constraint firstAttribute="bottom" secondItem="O53-5d-nTd" secondAttribute="bottom" constant="24" id="qRj-Mn-1PG"/>
<constraint firstItem="XWk-lo-a4J" firstAttribute="top" secondItem="zxq-Au-f6x" secondAttribute="top" constant="8" id="spC-xq-Ghh"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Yuv-dy-Of5">
<rect key="frame" x="0.0" y="688" width="366" height="1"/>
<color key="backgroundColor" white="0.0" alpha="0.3753851232" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="jWz-AI-sAM"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Xnd-YB-s88">
<rect key="frame" x="0.0" y="689" width="366" height="128"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2FB-qi-ed3">
<rect key="frame" x="0.0" y="24" width="366" height="80"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="2FB-qi-ed3" secondAttribute="bottom" constant="24" id="LXo-Xj-zu5"/>
<constraint firstAttribute="trailing" secondItem="2FB-qi-ed3" secondAttribute="trailing" id="x1V-1u-gaM"/>
<constraint firstItem="2FB-qi-ed3" firstAttribute="top" secondItem="Xnd-YB-s88" secondAttribute="top" constant="24" id="xZ6-UI-CjJ"/>
<constraint firstItem="2FB-qi-ed3" firstAttribute="leading" secondItem="Xnd-YB-s88" secondAttribute="leading" id="xyE-m1-zqc"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hzH-WS-AjJ">
<rect key="frame" x="0.0" y="817" width="366" height="1"/>
<color key="backgroundColor" white="0.0" alpha="0.3753851232" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="ZOE-DA-v6a"/>
</constraints>
</view>
<view contentMode="scaleToFill" id="esp-sf-8kz">
<rect key="frame" x="0.0" y="818" width="366" height="0.0"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="smL-fu-Mf4"/>
</view>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="amj-hh-azz" firstAttribute="bottom" secondItem="61B-TN-rWe" secondAttribute="bottom" id="PQD-BF-Gdw"/>
<constraint firstItem="61B-TN-rWe" firstAttribute="trailing" secondItem="amj-hh-azz" secondAttribute="trailing" constant="24" id="QPF-tW-E5C"/>
<constraint firstItem="amj-hh-azz" firstAttribute="top" secondItem="61B-TN-rWe" secondAttribute="top" id="kEc-Fl-7I2"/>
<constraint firstItem="amj-hh-azz" firstAttribute="leading" secondItem="61B-TN-rWe" secondAttribute="leading" constant="24" id="tIp-y8-oS1"/>
</constraints>
<viewLayoutGuide key="safeArea" id="61B-TN-rWe"/>
</view>
<connections>
<outlet property="biographyLabel" destination="2FB-qi-ed3" id="pW2-wM-rlB"/>
<outlet property="tagLabel" destination="O53-5d-nTd" id="bsn-OI-a0q"/>
<outlet property="userImageView" destination="XWk-lo-a4J" id="35q-bk-mlm"/>
<outlet property="userNameLabel" destination="0C4-aA-7aL" id="9Ct-6a-uEe"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="anN-R6-2hD" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="166.66666666666669" y="135.9375"/>
</scene>
</scenes>
</document>
49 changes: 49 additions & 0 deletions ios-base/DroidKaigi 2020/Speaker/Views/SpeakerViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Foundation
import ios_combined
import Nuke
import UIKit

final class SpeakerViewController: UIViewController {
@IBOutlet weak var userImageView: UIImageView! {
didSet {
userImageView.clipsToBounds = true
userImageView.layer.cornerRadius = userImageView.bounds.width / 2
}
}

@IBOutlet weak var userNameLabel: UILabel!
@IBOutlet weak var tagLabel: UILabel!
@IBOutlet weak var biographyLabel: UILabel!

private var speaker: Speaker!

static func instantiate(speaker: Speaker) -> SpeakerViewController {
guard let viewController = UIStoryboard(name: "SpeakerViewController", bundle: .main).instantiateInitialViewController() as? SpeakerViewController else { fatalError() }
viewController.speaker = speaker
return viewController
}

override func viewDidLoad() {
super.viewDidLoad()

setupUI()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

navigationController?.navigationBar.barTintColor = .white
navigationController?.navigationBar.tintColor = .black
}

private func setupUI() {
if
let imageUrl = speaker.imageUrl,
let url = URL(string: imageUrl) {
Nuke.loadImage(with: url, into: userImageView)
}
userNameLabel.text = speaker.name
tagLabel.text = speaker.tagLine
biographyLabel.text = speaker.bio
}
}