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

Selected events without data #36

Open
wants to merge 45 commits into
base: bottomSheet
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
27b148a
SelectedEventsNoData
May 23, 2023
0602124
first step
v0blaa May 24, 2023
1b6aa2e
add stuff list logic done
v0blaa May 24, 2023
1d114d1
fixed stuff bug
v0blaa May 24, 2023
121f6f7
stuff lists done
v0blaa May 25, 2023
79805f9
added stuff list sort
v0blaa May 25, 2023
c90e497
added localizaition
v0blaa May 25, 2023
29771d5
addUserId
May 25, 2023
fd2a3b2
some fixes
v0blaa May 27, 2023
8a3122b
Merge pull request #30 from iOS-vk-education/sem2
v0blaa May 27, 2023
5b4aa94
review fix
v0blaa May 27, 2023
21ac438
Merge branch 'dev' into tech/JRNS-28
v0blaa May 27, 2023
1d68096
Merge pull request #37 from iOS-vk-education/tech/JRNS-28
v0blaa May 27, 2023
ae705f6
fixed theme bugs
v0blaa May 27, 2023
d07c744
reloading map and user location
May 28, 2023
ab81c0a
open EventVC on tap MapCell
May 28, 2023
2e2570c
added account photo
v0blaa May 28, 2023
f2259c2
Merge branch 'dev' into tech/JRNS-48
v0blaa May 28, 2023
d56fa82
fixed dark theme and weather collection view reload bug
v0blaa May 28, 2023
0fa6969
Merge pull request #38 from iOS-vk-education/tech/themeBugFix
v0blaa May 28, 2023
b723563
first step
v0blaa May 28, 2023
920a4af
fixed swiftlint
v0blaa May 28, 2023
a01be4d
Merge pull request #40 from iOS-vk-education/tech/JRNS-48
v0blaa May 28, 2023
65b3807
finished alerts localization
v0blaa May 28, 2023
d192204
fixed account bug
v0blaa May 28, 2023
c1922cf
merged dev + fixes
v0blaa May 28, 2023
3cb7c0b
configuration favorites
May 29, 2023
b4ed2d2
Merge pull request #41 from iOS-vk-education/bugfix/JRNS-46
v0blaa May 29, 2023
e74ce3e
fixed comments and account bug fix
v0blaa May 29, 2023
001654e
Merge branch 'dev' into tech/JRNS-45
v0blaa May 29, 2023
817dd56
fixed map theme
v0blaa May 29, 2023
5b96628
small fix
v0blaa May 29, 2023
692ce2b
Merge pull request #44 from iOS-vk-education/tech/JRNS-53
v0blaa May 29, 2023
17a6139
deleted bookmarkButton
v0blaa May 29, 2023
b2e8aa4
merge with dev + fixes
v0blaa May 29, 2023
140ea80
Merge pull request #39 from iOS-vk-education/TapOnMapCell
v0blaa May 29, 2023
412c285
fixes
v0blaa May 29, 2023
318f59d
Merge pull request #45 from iOS-vk-education/TapOnMapCell1
v0blaa May 29, 2023
a22e817
merged dev
v0blaa May 29, 2023
bf8d553
Merge pull request #42 from iOS-vk-education/tech/JRNS-45
v0blaa May 29, 2023
fc953d7
support email was changed
v0blaa May 29, 2023
57764bc
selected
May 29, 2023
9c47bec
merved dev
v0blaa May 30, 2023
d2b446a
fixes
May 30, 2023
c459cf5
last changes
May 30, 2023
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
37 changes: 30 additions & 7 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@

included:
- Journeys

disabled_rules:
- trailing_whitespace
- vertical_whitespace
- trailing_newline
- nesting
excluded:
- Pods

- Carthage
- Pods
- SwiftLint/Common/3rdPartyLib
line_length:
warning: 170
warning: 150
error: 200
ignores_function_declarations: true
ignores_comments: true
ignores_urls: true
function_body_length:
warning: 300
error: 500
function_parameter_count:
warning: 6
error: 8
type_body_length:
warning: 300
error: 500
file_length:
warning: 1000
error: 1500
ignore_comment_only_lines: true
cyclomatic_complexity:
warning: 15
error: 25
reporter: "xcode"
119 changes: 112 additions & 7 deletions Journeys.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Journeys/AddingEvent/AddingBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import FirebaseFirestore
// MARK: - EventsModuleBuilder

final class AddingModuleBuilder {
func build(output: AddingModuleOutput, coordinates: GeoPoint?, address: String?) -> UIViewController {
func build(output: AddingModuleOutput, coordinates: GeoPoint?, address: String?, event: Event?, moduleType: AddingPresenter.ModuleType, image: UIImage?) -> UIViewController {
let viewController = AddingEventViewController()
let model = AddingModel()
let presenter = AddingPresenter(view: viewController, model: model, coordinates: coordinates, address: address)
let presenter = AddingPresenter(view: viewController, model: model, coordinates: coordinates, address: address, event: event, moduleType: moduleType, image: image)

viewController.output = presenter

Expand Down
40 changes: 27 additions & 13 deletions Journeys/AddingEvent/AddingEventViewController.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


import UIKit
import FirebaseFirestore

Expand All @@ -25,6 +26,8 @@ final class AddingEventViewController: UIViewController {
makeConstraints()
}

private let loadingView = LoadingView()

private func setupNavBar() {
navigationController?.navigationBar.tintColor = UIColor(asset: Asset.Colors.Text.mainTextColor)

Expand Down Expand Up @@ -52,6 +55,17 @@ final class AddingEventViewController: UIViewController {
let date2 = formatter.string(from: endDate)
return (date1, date2)
}

func showLoadingView() {
view.addSubview(loadingView)
loadingView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.bottom.equalToSuperview()
make.leading.equalToSuperview()
make.trailing.equalToSuperview()
}
view.bringSubviewToFront(loadingView)
}

@objc
func didTapReadyButton() {
Expand All @@ -67,13 +81,13 @@ final class AddingEventViewController: UIViewController {
let eventTypeCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 4)) as? PlacemarkCell
let eventType = eventTypeCell?.returnText()

guard let calendarCellBegin = collectionView.cellForItem(at: IndexPath(row: 0, section: 5)) as? TimeCell else {
guard let calendarCellBegin = collectionView.cellForItem(at: IndexPath(row: 0, section: 6)) as? TimeCell else {
assertionFailure("Error while getting time")
return
}
let startDate = calendarCellBegin.selectedDate()

guard let calendarCellEnd = collectionView.cellForItem(at: IndexPath(row: 0, section: 6)) as? TimeCell else {
guard let calendarCellEnd = collectionView.cellForItem(at: IndexPath(row: 0, section: 7)) as? TimeCell else {
assertionFailure("Error while getting time")
return
}
Expand All @@ -86,10 +100,10 @@ final class AddingEventViewController: UIViewController {
}
let (startDateStr, endDateStr) = formatDate(startDate: startDate, endDate: endDate)

let eventDescriptionCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 7)) as? DescriptionCell
let eventDescriptionCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 8)) as? DescriptionCell
let eventDescription = eventDescriptionCell?.returnText()

let eventUrlCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 9)) as? PlacemarkCell
let eventUrlCell = collectionView.cellForItem(at: IndexPath(row: 0, section: 5)) as? PlacemarkCell
let eventUrl = eventUrlCell?.returnText()

if floor == "" || ofice == "" || eventName == "" || eventType == "" {
Expand All @@ -98,6 +112,7 @@ final class AddingEventViewController: UIViewController {
present(alert, animated: true, completion: nil)
return
}
showLoadingView()
let post: Event = Event.init(address: self.address(),
startDate: startDateStr,
finishDate: endDateStr,
Expand All @@ -108,10 +123,9 @@ final class AddingEventViewController: UIViewController {
floor: floor ?? " ",
room: ofice ?? " ",
description: eventDescription ?? " ",
isLiked: false)
isLiked: false, userID: "")

output?.saveData(post: post)
output?.openEventsVC()
}

private func setupCollectionView() {
Expand Down Expand Up @@ -170,7 +184,7 @@ extension AddingEventViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
if indexPath.section == 7 || indexPath.section == 8 {
if indexPath.section == 8 || indexPath.section == 9 {
return AddingConstants.photoCellSize
} else {
return AddingConstants.tripCellSize
Expand Down Expand Up @@ -262,7 +276,7 @@ extension AddingEventViewController: UICollectionViewDataSource {
placeholder: L10n.typeOfEvent))
cell = placemarkCell
}
if indexPath.section == 5 {
if indexPath.section == 6 {
guard let placemarkCell = collectionView.dequeueReusableCell(
withReuseIdentifier: "TimeCell",
for: indexPath
Expand All @@ -272,7 +286,7 @@ extension AddingEventViewController: UICollectionViewDataSource {
placemarkCell.configure(data: TimeCellDisplayData(text: L10n.begin))
cell = placemarkCell
}
if indexPath.section == 6 {
if indexPath.section == 7 {
guard let placemarkCell = collectionView.dequeueReusableCell(
withReuseIdentifier: "TimeCell",
for: indexPath
Expand All @@ -283,7 +297,7 @@ extension AddingEventViewController: UICollectionViewDataSource {
cell = placemarkCell
}

if indexPath.section == 8 {
if indexPath.section == 9 {
guard let placemarkCell = collectionView.dequeueReusableCell(
withReuseIdentifier: "ImageEventCell",
for: indexPath
Expand All @@ -293,7 +307,7 @@ extension AddingEventViewController: UICollectionViewDataSource {
placemarkCell.configure(delegate: self)
cell = placemarkCell
}
if indexPath.section == 7 {
if indexPath.section == 8 {
guard let placemarkCell = collectionView.dequeueReusableCell(
withReuseIdentifier: "DescriptionCell",
for: indexPath
Expand All @@ -303,7 +317,7 @@ extension AddingEventViewController: UICollectionViewDataSource {
placemarkCell.configure(isEditable: true, cornerRadius: 10, text: "")
cell = placemarkCell
}
if indexPath.section == 9 {
if indexPath.section == 5 {
guard let placemarkCell = collectionView.dequeueReusableCell(
withReuseIdentifier: "PlacemarkCell",
for: indexPath
Expand Down Expand Up @@ -339,7 +353,7 @@ extension AddingEventViewController: ImageEventCellDelegate {
extension AddingEventViewController: UIImagePickerControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
let cell = collectionView.cellForItem(at: IndexPath(row: 0, section: 8)) as? ImageEventCell
let cell = collectionView.cellForItem(at: IndexPath(row: 0, section: 9)) as? ImageEventCell

cell?.configureAddPhotoButton(image: editedImage)
output?.imageFromView(image: editedImage)
Expand Down
69 changes: 63 additions & 6 deletions Journeys/AddingEvent/AddingModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,63 @@ final class AddingModel {
}

extension AddingModel: AddingModelInput {
func deleteLike(event: Event) {
service.deleteFavoritesData(eventId: event.userID) { [weak self] error in
guard let self else { return }
if error != nil {
self.output?.didRecieveError(error: .deleteDataError)
}
}
}

func deleteEvent(event: Event) {
service.deleteEventData(eventId: event.userID) { [weak self] error in
guard let self else { return }
if error != nil {
self.output?.didRecieveError(error: .deleteDataError)
} else {
self.output?.didDeleteEvent()
}

}
}

func storeEditing(event: Event, eventImage: UIImage) {
service.storeAddingImage(image: eventImage) { result in
switch result {
case .failure:
self.output?.didRecieveError(error: Errors.saveDataError)
case .success(let url):
self.didStoreImageDataCreated(url: url, event: event)
}
}
}

func didStoreImageDataCreated(url: String, event: Event) {
let newEvent = Event(address: event.address,
startDate: event.startDate,
finishDate: event.finishDate,
type: event.type,
name: event.name,
link: event.link,
photoURL: url,
floor: event.floor,
room: event.room,
description: event.description,
isLiked: false,
userID: event.userID)
service.storeEditingData(event: newEvent) { result in
switch result {
case .failure:
self.output?.didRecieveError(error: Errors.saveDataError)
case .success(let eventModel):
self.output?.didSaveAddingData(event: eventModel)
}
}
}



//MARK: - private functions
//MARK: - functions
func storeAddingData(event: Event, eventImage: UIImage, coordinatesId: String) {
Expand All @@ -42,14 +99,14 @@ extension AddingModel: AddingModelInput {
floor: event.floor,
room: event.room,
description: event.description,
isLiked: false)
service.storeAddingData(event: newEvent, coordinatesId: coordinatesId) { [weak self] result in
guard let strongSelf = self else { return }
isLiked: false,
userID: "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Почему в userId всегда какие-то рандомные значения передаются?)

service.storeAddingData(event: newEvent, coordinatesId: coordinatesId) { result in
switch result {
case .failure:
strongSelf.output?.didRecieveError(error: Errors.saveDataError)
case .success(let event):
strongSelf.output?.didSaveAddingData(event: event)
self.output?.didRecieveError(error: Errors.saveDataError)
case .success(let eventModel):
self.output?.didSaveAddingData(event: eventModel)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Journeys/AddingEvent/AddingModelIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import FirebaseFirestore
protocol AddingModelInput: AnyObject {
func storeAddingData(event: Event, eventImage: UIImage, coordinatesId: String)
func createStory(coordinates: Address, event: Event, eventImage: UIImage)
func storeEditing(event: Event, eventImage: UIImage)
func deleteEvent(event: Event)
func deleteLike(event: Event)
}

protocol AddingModelOutput: AnyObject {
func didRecieveError(error: Errors)
func didSaveAddingData(event: Event)
func didStoreImageData(url: String, event: Event, coordinatesId: String)
func didSaveData(address: Address, event: Event)
func didDeleteEvent()
}
3 changes: 2 additions & 1 deletion Journeys/AddingEvent/AddingModuleIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//
// Created by Ангелина Решетникова on 25.04.2023.
//

protocol AddingModuleInput: AnyObject {
}

Expand All @@ -13,4 +12,6 @@ protocol AddingModuleInput: AnyObject {
protocol AddingModuleOutput: AnyObject {
func wantsToOpenEventsVC()
func backToSuggestionVC()
func closeOpenSingleEventVCIfExists()
func wantsToOpenCreatedVC()
}
Loading