Skip to content
Open
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
36 changes: 36 additions & 0 deletions DoSport/DoSport.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@
65EEB96025EA023400821F8F /* SettingsDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65EEB95F25EA023400821F8F /* SettingsDataSource.swift */; };
65EEE91925B626290023168D /* AppConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65EEE91825B626290023168D /* AppConfiguration.swift */; };
65FFFD632604AFB400CD1CB5 /* NetworkErrorResponseType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65FFFD622604AFB400CD1CB5 /* NetworkErrorResponseType.swift */; };
6D625F3A268E3908000389D9 /* DSRatingStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D625F39268E3908000389D9 /* DSRatingStackView.swift */; };
6D625F47268E39F1000389D9 /* FeedBackAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D625F42268E39F1000389D9 /* FeedBackAssembly.swift */; };
6D625F48268E39F1000389D9 /* FeedBackCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D625F43268E39F1000389D9 /* FeedBackCoordinator.swift */; };
6D625F49268E39F1000389D9 /* FeedBackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D625F45268E39F1000389D9 /* FeedBackViewController.swift */; };
6D625F4A268E39F1000389D9 /* FeedbackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D625F46268E39F1000389D9 /* FeedbackView.swift */; };
A6A7FD60C795722CE2BC7D68 /* Pods_DoSport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4B2C80E4358F104D909040B /* Pods_DoSport.framework */; };
CE0A6B39258F89F5007E02CC /* SFProDisplay-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = CEDEB889258CE7F2007B2BCA /* SFProDisplay-Regular.ttf */; };
CE0A6B58258FBA26007E02CC /* CustomPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0A6B57258FBA26007E02CC /* CustomPageControl.swift */; };
Expand Down Expand Up @@ -576,6 +581,11 @@
65EEB95F25EA023400821F8F /* SettingsDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsDataSource.swift; sourceTree = "<group>"; };
65EEE91825B626290023168D /* AppConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfiguration.swift; sourceTree = "<group>"; };
65FFFD622604AFB400CD1CB5 /* NetworkErrorResponseType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkErrorResponseType.swift; sourceTree = "<group>"; };
6D625F39268E3908000389D9 /* DSRatingStackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSRatingStackView.swift; sourceTree = "<group>"; };
6D625F42268E39F1000389D9 /* FeedBackAssembly.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedBackAssembly.swift; sourceTree = "<group>"; };
6D625F43268E39F1000389D9 /* FeedBackCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedBackCoordinator.swift; sourceTree = "<group>"; };
6D625F45268E39F1000389D9 /* FeedBackViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedBackViewController.swift; sourceTree = "<group>"; };
6D625F46268E39F1000389D9 /* FeedbackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedbackView.swift; sourceTree = "<group>"; };
CE0A6B57258FBA26007E02CC /* CustomPageControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPageControl.swift; sourceTree = "<group>"; };
CE2B5DBF25FBB55B007E5EEA /* LoginAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginAPI.swift; sourceTree = "<group>"; };
CE2B5DC425FBB626007E5EEA /* WKWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKWebView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -981,6 +991,7 @@
6568F8DC25B4F85C00225043 /* Feed */ = {
isa = PBXGroup;
children = (
6D625F41268E39F1000389D9 /* Feedback */,
653179D625D112B3001DBA4B /* DateSelection */,
65EAAA9425CD59A9005E0131 /* Event */,
6531791D25D10DF6001DBA4B /* EventCreate */,
Expand Down Expand Up @@ -1094,6 +1105,7 @@
659DCA1225D933FA00D56193 /* DSSegmentedControl.swift */,
65C67E6625D557C600ABC58B /* DSSeparatorView.swift */,
658F851325E8D79600EBE6A1 /* DSSubscribtionCountView.swift */,
6D625F39268E3908000389D9 /* DSRatingStackView.swift */,
65CD771425EB301B00D042FD /* DSSwitch.swift */,
65CC2CEB25DA899A009D6B4B /* Buttons */,
654D707D25E89EA700B37AD3 /* EventCard */,
Expand Down Expand Up @@ -1438,6 +1450,25 @@
path = Settings;
sourceTree = "<group>";
};
6D625F41268E39F1000389D9 /* Feedback */ = {
isa = PBXGroup;
children = (
6D625F42268E39F1000389D9 /* FeedBackAssembly.swift */,
6D625F43268E39F1000389D9 /* FeedBackCoordinator.swift */,
6D625F44268E39F1000389D9 /* View */,
);
path = Feedback;
sourceTree = "<group>";
};
6D625F44268E39F1000389D9 /* View */ = {
isa = PBXGroup;
children = (
6D625F45268E39F1000389D9 /* FeedBackViewController.swift */,
6D625F46268E39F1000389D9 /* FeedbackView.swift */,
);
path = View;
sourceTree = "<group>";
};
ADF7D3308F59CB7E81C5F884 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1960,6 +1991,7 @@
buildActionMask = 2147483647;
files = (
CE4C91E02613934D00A1B6BC /* MainSportTypeSelectionTableCell.swift in Sources */,
6D625F3A268E3908000389D9 /* DSRatingStackView.swift in Sources */,
CE4C91DF2613934500A1B6BC /* UIStackView+addArrangedSubviews.swift in Sources */,
CE4C91DC2613933A00A1B6BC /* CollectionViewSportTypeCell.swift in Sources */,
CE4C91D92613932C00A1B6BC /* DSAvatartImageView.swift in Sources */,
Expand Down Expand Up @@ -2029,6 +2061,7 @@
6503F4E325B5CDD60002BC27 /* Event.swift in Sources */,
65EAAA8A25CD4010005E0131 /* CollectionViewEventCardCellFooterView.swift in Sources */,
65CDF89A25DB12080049F711 /* SportGroundSelectionListViewController.swift in Sources */,
6D625F4A268E39F1000389D9 /* FeedbackView.swift in Sources */,
65D973FB25B4731800769653 /* SportTypeGridViewController.swift in Sources */,
65430BEE260F98100044F57C /* FeedModel.swift in Sources */,
659C61AD2593DB5A00C33D05 /* SignUpView.swift in Sources */,
Expand Down Expand Up @@ -2088,6 +2121,7 @@
658E0AA825D7DDEA0013DFF5 /* UIDevide+getDeviceModel.swift in Sources */,
65B6D98726060B870099BC08 /* DSModels+SportType.swift in Sources */,
655B514225D5C007004FE90F /* SelectionCell.swift in Sources */,
6D625F48268E39F1000389D9 /* FeedBackCoordinator.swift in Sources */,
6531799925D111FE001DBA4B /* RegionListViewModel.swift in Sources */,
65AAB2D925ACA0D000A86730 /* HideKeyboardWithAction.swift in Sources */,
653179BB25D1124C001DBA4B /* SubwayListViewController.swift in Sources */,
Expand All @@ -2108,6 +2142,7 @@
65CD77E025EB588F00D042FD /* UserReportMessageView.swift in Sources */,
655B513D25D5BFFC004FE90F /* TextViewCell.swift in Sources */,
65C080A425E1AFB200BF353B /* UISearchBar+textField.swift in Sources */,
6D625F49268E39F1000389D9 /* FeedBackViewController.swift in Sources */,
65EEB93725E9E36300821F8F /* UserSubscriberListDataSource.swift in Sources */,
65D9742B25B487AF00769653 /* UICollectionView+cellForRow.swift in Sources */,
6587051825920A0100EFF7C7 /* SignInCoordinator.swift in Sources */,
Expand All @@ -2118,6 +2153,7 @@
654D706725E8903D00B37AD3 /* EventCardTableCell.swift in Sources */,
CECEE2642610BCEB00B9AF16 /* NSNotifications.swift in Sources */,
651FBF2925FE01070018C6B1 /* MainSportTypeSelectionCoordinator.swift in Sources */,
6D625F47268E39F1000389D9 /* FeedBackAssembly.swift in Sources */,
65B6D96426060B1D0099BC08 /* DSEnums+FeedFilterType.swift in Sources */,
6587053E2592493400EFF7C7 /* Coordinator.swift in Sources */,
653179E725D112D4001DBA4B /* DateSelectionAssembly.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// DSRatingStackView.swift
// DoSport
//
// Created by Dmitrii Diadiushkin on 10.06.2021.
//

import UIKit

enum DSRatingStackViewState {
case unrated, rated
}

protocol DSRatingStackViewDelegate: AnyObject {
func ratingViewTapped()
}

final class DSRatingStackView: UIStackView {

weak var delegate: DSRatingStackViewDelegate?

private var stackViewState: DSRatingStackViewState = .unrated

//MARK: Init

init() {
super.init(frame: .zero)

axis = .horizontal
spacing = 20
distribution = .equalCentering
alignment = .center
isUserInteractionEnabled = true

addArrangedSubviews(makeRatingImageViews(imageCount: 5))
translatesAutoresizingMaskIntoConstraints = false
}

required init(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

extension DSRatingStackView {

func bind(state: DSRatingStackViewState) {
stackViewState = state
}

func getState() -> DSRatingStackViewState {
return stackViewState
}
}

private extension DSRatingStackView {

func makeRatingImageViews(imageCount: Int) -> [UIImageView] {
var imageViewStack: [UIImageView] = []
for tag in 1...imageCount {
let starImageView = UIImageView()
starImageView.image = UIImage(named: "star")
starImageView.frame.size.height = 20
starImageView.frame.size.width = 20
starImageView.tag = tag
starImageView.isUserInteractionEnabled = true
let starImageViewInteractionGesture = UITapGestureRecognizer(target: self, action: #selector(stackViewTapped))
starImageView.addGestureRecognizer(starImageViewInteractionGesture)
imageViewStack.append(starImageView)
}
return imageViewStack
}

@objc func stackViewTapped(sender: UITapGestureRecognizer) {
guard let tappedTag = sender.view?.tag else {return}
userRated(tappedTag)
if getState() == .unrated {
self.bind(state: .rated)
self.delegate?.ratingViewTapped()
}
}

private func userRated(_ rating: Int) {
for (index, item) in self.subviews.enumerated() {
let imageView = item as! UIImageView
if index < rating {
imageView.image = UIImage(named: "star.filled")
} else {
imageView.image = UIImage(named: "star")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ extension UIStackView {
func addArrangedSubviews(_ subviews: UIView...) {
subviews.forEach(self.addArrangedSubview)
}

func addArrangedSubviews(_ subviews: [UIView]) {
subviews.forEach(self.addArrangedSubview)
}
}

16 changes: 16 additions & 0 deletions DoSport/DoSport/Flow/Feed/Feedback/FeedBackAssembly.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// FeedBackAssembly.swift
// DoSport
//
// Created by Dmitrii Diadiushkin on 31.05.2021.
//

import Foundation

final class FeedBackAssembly: Assembly {

func makeModule() -> FeedBackViewController {
let viewController = FeedBackViewController()
return viewController
}
}
32 changes: 32 additions & 0 deletions DoSport/DoSport/Flow/Feed/Feedback/FeedBackCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// FeedBackCoordinator.swift
// DoSport
//
// Created by Dmitrii Diadiushkin on 31.05.2021.
//

import UIKit

final class FeedBackCoordinator: Coordinator {

let rootViewController: FeedBackViewController

var childCoordinators: [Coordinator] = []
var navigationController: UINavigationController?

init(navController: UINavigationController?) {
let assembly = FeedBackAssembly()
self.rootViewController = assembly.makeModule()
self.navigationController = navController
}

func start() {
rootViewController.coordinator = self
navigationController?.pushViewController(rootViewController, animated: true)
}

func goBack() {
navigationController?.dismiss(animated: true, completion: nil)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// FeedBackViewController.swift
// DoSport
//
// Created by Dmitrii Diadiushkin on 31.05.2021.
//

import UIKit

final class FeedBackViewController: UIViewController {

weak var coordinator: FeedBackCoordinator?
private lazy var feedBackView = view as! FeedbackView

// MARK: Life Cycle

override func loadView() {
let view = FeedbackView()
self.view = view
}

override func viewDidLoad() {
super.viewDidLoad()

setupNavBar()
}

}

//MARK: - Private API

private extension FeedBackViewController {
func setupNavBar() {
title = Texts.FeedBack.navTitle
navigationController?.navigationBar.titleTextAttributes = [
NSAttributedString.Key.font: Fonts.sfProRegular(size: 18),
NSAttributedString.Key.foregroundColor: Colors.mainBlue
]

navigationItem.setHidesBackButton(true, animated: true)
let button = UIButton(type: .system)
button.setImage(Icons.EventCreate.cancel, for: .normal)
button.tintColor = Colors.mainBlue
button.addTarget(self, action: #selector(handleCancelButton), for: .touchUpInside)
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: button)
}
}

//MARK: Actions

@objc private extension FeedBackViewController {

func handleCancelButton() {
coordinator?.goBack()
}
}
Loading