-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from twilio/spike/uikit-pip
Merging picture-in-picture support from spike/uikit-pip into master
- Loading branch information
Showing
11 changed files
with
522 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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
91 changes: 91 additions & 0 deletions
91
VideoApp/VideoApp/PictureInPicture/PIPPlaceholderView.swift
This file contains 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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// PIPPlaceholderView.swift | ||
// VideoApp | ||
// | ||
// Created by Tim Rozum on 8/25/22. | ||
// Copyright © 2022 Twilio, Inc. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class PIPPlaceholderView: UIView { | ||
let label = UILabel() | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError() | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
backgroundColor = UIColor(named: "BackgroundStronger") | ||
|
||
addSubview(label) | ||
|
||
label.textColor = .white | ||
label.textAlignment = .center | ||
} | ||
|
||
override func didMoveToSuperview() { | ||
guard let superview = superview else { return } | ||
|
||
translatesAutoresizingMaskIntoConstraints = false | ||
let constraints = [ | ||
leadingAnchor.constraint(equalTo: superview.leadingAnchor), | ||
trailingAnchor.constraint(equalTo: superview.trailingAnchor), | ||
topAnchor.constraint(equalTo: superview.topAnchor), | ||
bottomAnchor.constraint(equalTo: superview.bottomAnchor) | ||
] | ||
NSLayoutConstraint.activate(constraints) | ||
|
||
label.translatesAutoresizingMaskIntoConstraints = false | ||
let labelConstraints = [ | ||
leadingAnchor.constraint(equalTo: label.leadingAnchor), | ||
trailingAnchor.constraint(equalTo: label.trailingAnchor), | ||
topAnchor.constraint(equalTo: label.topAnchor), | ||
bottomAnchor.constraint(equalTo: label.bottomAnchor) | ||
] | ||
NSLayoutConstraint.activate(labelConstraints) | ||
} | ||
|
||
func configure(particiipant: ParticipantViewModel) { | ||
label.text = particiipant.displayName | ||
} | ||
} | ||
|
||
import UIKit | ||
|
||
class PIPContainerView: UIView { | ||
let placeholder = PIPPlaceholderView() | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError() | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
addSubview(placeholder) | ||
|
||
} | ||
|
||
override func didMoveToSuperview() { | ||
guard let superview = superview else { return } | ||
|
||
translatesAutoresizingMaskIntoConstraints = false | ||
|
||
let constraints = [ | ||
leadingAnchor.constraint(equalTo: superview.leadingAnchor), | ||
trailingAnchor.constraint(equalTo: superview.trailingAnchor), | ||
topAnchor.constraint(equalTo: superview.topAnchor), | ||
bottomAnchor.constraint(equalTo: superview.bottomAnchor) | ||
] | ||
|
||
NSLayoutConstraint.activate(constraints) | ||
} | ||
|
||
func configure(particiipant: ParticipantViewModel) { | ||
placeholder.configure(particiipant: particiipant) | ||
|
||
} | ||
} |
Oops, something went wrong.