-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
285 additions
and
22 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
25 changes: 25 additions & 0 deletions
25
Flat/Assets.xcassets/Common/triangle_down.imageset/Contents.json
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,25 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+375 Bytes
Flat/Assets.xcassets/Common/triangle_down.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+497 Bytes
Flat/Assets.xcassets/Common/triangle_down.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
140 changes: 140 additions & 0 deletions
140
Flat/Modules/Home/HistoryJoinRoomPickerViewController.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,140 @@ | ||
// | ||
// HistoryJoinRoomPickerViewController.swift | ||
// Flat | ||
// | ||
// Created by xuyunshi on 2023/11/21. | ||
// Copyright © 2023 agora.io. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class HistoryJoinRoomPickerViewController: UIViewController { | ||
var items = ClassroomCoordinator.shared.joinRoomHisotryItems | ||
|
||
var roomIdConfirmHandler: ((String) ->Void)? | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setupViews() | ||
} | ||
|
||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
dismiss(animated: true) | ||
} | ||
|
||
func setupViews() { | ||
view.backgroundColor = UIColor.black.withAlphaComponent(0.3) | ||
|
||
let operationStack = UIStackView(arrangedSubviews: [clearButton, UIView(), confirmButton]) | ||
operationStack.addLine(direction: .bottom, color: .borderColor, width: commonBorderWidth, inset: .init(top: 0, left: 14, bottom: 0, right: 14)) | ||
operationStack.axis = .horizontal | ||
|
||
let stack = UIStackView(arrangedSubviews: [operationStack, picker, cancelButton]) | ||
stack.backgroundColor = .color(type: .background) | ||
stack.axis = .vertical | ||
view.addSubview(stack) | ||
operationStack.snp.makeConstraints { make in | ||
make.height.equalTo(44) | ||
} | ||
stack.snp.makeConstraints { make in | ||
make.left.right.bottom.equalTo(view.safeAreaLayoutGuide) | ||
} | ||
picker.snp.makeConstraints { make in | ||
make.height.equalTo(144) | ||
} | ||
cancelButton.snp.makeConstraints { $0.height.equalTo(44) } | ||
fillBottomSafeAreaWith(color: .color(type: .background)) | ||
} | ||
|
||
@objc func onCancel() { | ||
dismiss(animated: true) | ||
} | ||
|
||
@objc func onConfirm() { | ||
let row = picker.selectedRow(inComponent: 0) | ||
if row + 1 > items.count { | ||
dismiss(animated: true) | ||
return | ||
} | ||
let item = items[row] | ||
dismiss(animated: true) | ||
roomIdConfirmHandler?(item.roomInviteId) | ||
} | ||
|
||
@objc func onClear() { | ||
ClassroomCoordinator.shared.clearJoinRoomHistoryItem() | ||
items = [] | ||
picker.reloadAllComponents() | ||
} | ||
|
||
lazy var picker: UIPickerView = { | ||
let view = UIPickerView() | ||
view.backgroundColor = .color(type: .background) | ||
view.delegate = self | ||
view.dataSource = self | ||
return view | ||
}() | ||
|
||
lazy var clearButton: UIButton = { | ||
let btn = UIButton(type: .system) | ||
btn.setTitle(localizeStrings("ClearHistory"), for: .normal) | ||
btn.addTarget(self, action: #selector(onClear), for: .touchUpInside) | ||
btn.tintColor = .color(type: .text) | ||
btn.contentEdgeInsets = .init(top: 0, left: 14, bottom: 0, right: 14) | ||
return btn | ||
}() | ||
|
||
lazy var confirmButton: UIButton = { | ||
let btn = UIButton(type: .system) | ||
btn.setTitle(localizeStrings("Confirm"), for: .normal) | ||
btn.addTarget(self, action: #selector(onConfirm), for: .touchUpInside) | ||
btn.tintColor = .color(type: .primary) | ||
btn.contentEdgeInsets = .init(top: 0, left: 14, bottom: 0, right: 14) | ||
return btn | ||
}() | ||
|
||
lazy var cancelButton: UIButton = { | ||
let btn = UIButton(type: .system) | ||
btn.setTitle(localizeStrings("Cancel"), for: .normal) | ||
btn.addTarget(self, action: #selector(onCancel), for: .touchUpInside) | ||
btn.tintColor = .color(type: .text) | ||
return btn | ||
}() | ||
} | ||
|
||
extension HistoryJoinRoomPickerViewController: UIPickerViewDelegate, UIPickerViewDataSource { | ||
func numberOfComponents(in pickerView: UIPickerView) -> Int { | ||
1 | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { | ||
items.count | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { | ||
let view = UIView(frame: .zero) | ||
let leftLabel = UILabel() | ||
leftLabel.font = .systemFont(ofSize: 14) | ||
leftLabel.textColor = .color(type: .text) | ||
leftLabel.text = items[row].roomName | ||
leftLabel.textAlignment = .left | ||
|
||
let rightLabel = UILabel() | ||
rightLabel.font = .systemFont(ofSize: 14) | ||
rightLabel.textColor = .color(type: .text) | ||
rightLabel.text = items[row].roomInviteId.formatterInviteCode | ||
rightLabel.textAlignment = .right | ||
|
||
let stack = UIStackView(arrangedSubviews: [leftLabel, rightLabel]) | ||
stack.axis = .horizontal | ||
view.addSubview(stack) | ||
stack.snp.makeConstraints { make in | ||
make.edges.equalToSuperview().inset(UIEdgeInsets(top: 0, left: 14, bottom: 0, right: 14)) | ||
} | ||
return view | ||
} | ||
|
||
func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { | ||
44 | ||
} | ||
} |
Oops, something went wrong.