Skip to content

Commit

Permalink
Merge branch 'develop' into dev/trello.com/c/CdfJ7GTd
Browse files Browse the repository at this point in the history
  • Loading branch information
just-software-dev committed Oct 14, 2024
2 parents 9662f93 + 6f46bc7 commit f4b298f
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 10 deletions.
6 changes: 4 additions & 2 deletions Adamant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@
93A2A8602CB4733800DBC75E /* MainThreadAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A2A85F2CB4733800DBC75E /* MainThreadAssembly.swift */; };
93A2A8662CB4A1EE00DBC75E /* UnsafeSendableExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A2A8652CB4A1EE00DBC75E /* UnsafeSendableExtensions.swift */; };
93A91FD1297972B7001DB1F8 /* ChatScrollDownButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A91FD0297972B7001DB1F8 /* ChatScrollDownButton.swift */; };
93A91FD1297972B7001DB1F8 /* ChatScrollButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A91FD0297972B7001DB1F8 /* ChatScrollButton.swift */; };
93A91FD329799298001DB1F8 /* ChatStartPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A91FD229799298001DB1F8 /* ChatStartPosition.swift */; };
93ADE0712ACA66AF008ED641 /* VibrationSelectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93ADE06E2ACA66AF008ED641 /* VibrationSelectionViewModel.swift */; };
93ADE0722ACA66AF008ED641 /* VibrationSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93ADE06F2ACA66AF008ED641 /* VibrationSelectionView.swift */; };
Expand Down Expand Up @@ -1039,6 +1040,7 @@
93A2A85F2CB4733800DBC75E /* MainThreadAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainThreadAssembly.swift; sourceTree = "<group>"; };
93A2A8652CB4A1EE00DBC75E /* UnsafeSendableExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsafeSendableExtensions.swift; sourceTree = "<group>"; };
93A91FD0297972B7001DB1F8 /* ChatScrollDownButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatScrollDownButton.swift; sourceTree = "<group>"; };
93A91FD0297972B7001DB1F8 /* ChatScrollButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatScrollButton.swift; sourceTree = "<group>"; };
93A91FD229799298001DB1F8 /* ChatStartPosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatStartPosition.swift; sourceTree = "<group>"; };
93ADE06E2ACA66AF008ED641 /* VibrationSelectionViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VibrationSelectionViewModel.swift; sourceTree = "<group>"; };
93ADE06F2ACA66AF008ED641 /* VibrationSelectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VibrationSelectionView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2016,7 +2018,7 @@
413AD21A29CDDD750025F255 /* ChatReply */,
9377FBE0296C2AB700C9211B /* ChatTransaction */,
938F7D652955C966001915CA /* ChatInputBar.swift */,
93A91FD0297972B7001DB1F8 /* ChatScrollDownButton.swift */,
93A91FD0297972B7001DB1F8 /* ChatScrollButton.swift */,
9371130E2996EDA900F64CF9 /* ChatRefreshMock.swift */,
93996A962968209C008D080B /* ChatMessagesCollection.swift */,
9382F61229DEC0A3005E6216 /* ChatModelView.swift */,
Expand Down Expand Up @@ -3572,7 +3574,7 @@
E9FAE5DA203DBFEF008D3A6B /* Comparable+clamped.swift in Sources */,
93A91FD329799298001DB1F8 /* ChatStartPosition.swift in Sources */,
3A2F55F92AC6F308000A3F26 /* CoinTransaction+CoreDataClass.swift in Sources */,
93A91FD1297972B7001DB1F8 /* ChatScrollDownButton.swift in Sources */,
93A91FD1297972B7001DB1F8 /* ChatScrollButton.swift in Sources */,
3AA3880A2B69173500125684 /* DashNetworkInfoDTO.swift in Sources */,
41C1698C29E7F34900FEB3CB /* RichTransactionReplyService.swift in Sources */,
9390C5032976B42800270CDF /* ChatDialogManager.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,8 @@ private extension ChatViewController {
// MARK: Making entities

private extension ChatViewController {
func makeScrollDownButton() -> ChatScrollDownButton {
let button = ChatScrollDownButton()
func makeScrollDownButton() -> ChatScrollButton {
let button = ChatScrollButton(position: .down)
button.action = { [weak self] in
guard let id = self?.viewModel.getTempOffset(visibleIndex: self?.messagesCollectionView.indexPathsForVisibleItems.last?.section)
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,43 @@
import UIKit
import SnapKit

final class ChatScrollDownButton: UIView {
enum Position {
case up
case down
}

final class ChatScrollButton: UIView {
private lazy var button: UIButton = {
let button = UIButton(type: .custom)
button.setImage(.asset(named: "ScrollDown"), for: .normal)
button.alpha = 0.5
switch position {
case .up:
button.setImage(.asset(named: "scrollUp"), for: .normal)
case .down:
button.setImage(.asset(named: "ScrollDown"), for: .normal)
}
button.addTarget(self, action: #selector(onTap), for: .touchUpInside)
return button
}()

private let position: Position

var action: (() -> Void)?

override init(frame: CGRect) {
init(frame: CGRect = .zero, position: Position) {
self.position = position
super.init(frame: frame)
configure()
}

required init?(coder: NSCoder) {
self.position = .down
super.init(coder: coder)
configure()
}
}

private extension ChatScrollDownButton {
private extension ChatScrollButton {
func configure() {
addSubview(button)
button.snp.makeConstraints {
Expand Down
26 changes: 25 additions & 1 deletion Adamant/Modules/ChatsList/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ final class ChatListViewController: KeyboardObservingViewController {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var newChatButton: UIBarButtonItem!

private lazy var scrollUpButton = ChatScrollButton(position: .up)

// MARK: Properties
var chatsController: NSFetchedResultsController<Chatroom>?
var unreadController: NSFetchedResultsController<ChatTransaction>?
Expand Down Expand Up @@ -187,7 +189,8 @@ final class ChatListViewController: KeyboardObservingViewController {
busyIndicatorView.layer.cornerRadius = 14
busyIndicatorView.clipsToBounds = true

addObservers()
configureScrollUpButton()
addObservers()
setColors()
}

Expand Down Expand Up @@ -259,6 +262,22 @@ final class ChatListViewController: KeyboardObservingViewController {
tableView.tableHeaderView = UIView()
}

func configureScrollUpButton() {
view.addSubview(scrollUpButton)

scrollUpButton.isHidden = true

scrollUpButton.action = { [weak self] in
self?.tableView.scrollToRow(at: IndexPath(row: .zero, section: .zero), at: .top, animated: true)
}

scrollUpButton.snp.makeConstraints { make in
make.trailing.equalToSuperview().offset(-20)
make.top.equalTo(view.safeAreaLayoutGuide).offset(20)
make.size.equalTo(30)
}
}

// MARK: Add Observers

private func addObservers() {
Expand Down Expand Up @@ -570,6 +589,11 @@ extension ChatListViewController: UITableViewDelegate, UITableViewDataSource {
}
}
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y + scrollView.safeAreaInsets.top
scrollUpButton.isHidden = offsetY < cellHeight * 0.75
}
}

// MARK: - UITableView Cells
Expand Down
2 changes: 1 addition & 1 deletion Adamant/Modules/NodesEditor/NodesListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ final class NodesListViewController: FormViewController {
self.nodesAdditionalParamsStorage = nodesAdditionalParamsStorage
self.apiService = apiService
self.socketService = socketService
super.init(nibName: nil, bundle: nil)
super.init(style: .insetGrouped)
}

required init?(coder aDecoder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "scrollUp.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f4b298f

Please sign in to comment.