Skip to content

Commit

Permalink
Merge pull request #7 from qwite/develop
Browse files Browse the repository at this point in the history
DateFormatter + CreateAd module changes
  • Loading branch information
qwite authored Jul 30, 2022
2 parents 19bc3e3 + d4778d0 commit 3e7df0a
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 162 deletions.
8 changes: 4 additions & 4 deletions store-platform-mvp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
1F227DA02836682D00F736F1 /* ImagePickerCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F227D9F2836682D00F736F1 /* ImagePickerCoordinator.swift */; };
1F227DA72836822100F736F1 /* ImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F227DA62836822100F736F1 /* ImagePickerController.swift */; };
1F227DA92836824200F736F1 /* ImagePickerPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F227DA82836824200F736F1 /* ImagePickerPresenter.swift */; };
1F2333752880938C005ED749 /* Date + Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2333742880938C005ED749 /* Date + Extension.swift */; };
1F29DE152842A57C00811F48 /* BaseCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F29DE142842A57C00811F48 /* BaseCoordinator.swift */; };
1F29DE182842D4D900811F48 /* FavoritesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F29DE172842D4D900811F48 /* FavoritesView.swift */; };
1F29DE1B2842D54600811F48 /* FavoriteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F29DE1A2842D54600811F48 /* FavoriteCell.swift */; };
Expand Down Expand Up @@ -61,6 +60,7 @@
1F4781D2285DD5EB00047317 /* Order.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4781D1285DD5EB00047317 /* Order.swift */; };
1F4781D5285DDFDC00047317 /* UserOrdersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4781D4285DDFDC00047317 /* UserOrdersViewController.swift */; };
1F4781D7285DDFE200047317 /* UserOrdersPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4781D6285DDFE200047317 /* UserOrdersPresenter.swift */; };
1F54FDEB289521F5009A2D07 /* DateFormatter + Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F54FDEA289521F5009A2D07 /* DateFormatter + Extension.swift */; };
1F5D7FCE282E47BA00255E71 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5D7FCD282E47BA00255E71 /* AppDelegate.swift */; };
1F5D7FD0282E47BA00255E71 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F5D7FCF282E47BA00255E71 /* SceneDelegate.swift */; };
1F5D7FD7282E47BB00255E71 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1F5D7FD6282E47BB00255E71 /* Assets.xcassets */; };
Expand Down Expand Up @@ -257,7 +257,6 @@
1F227D9F2836682D00F736F1 /* ImagePickerCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePickerCoordinator.swift; sourceTree = "<group>"; };
1F227DA62836822100F736F1 /* ImagePickerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePickerController.swift; sourceTree = "<group>"; };
1F227DA82836824200F736F1 /* ImagePickerPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePickerPresenter.swift; sourceTree = "<group>"; };
1F2333742880938C005ED749 /* Date + Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date + Extension.swift"; sourceTree = "<group>"; };
1F29DE142842A57C00811F48 /* BaseCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseCoordinator.swift; sourceTree = "<group>"; };
1F29DE172842D4D900811F48 /* FavoritesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesView.swift; sourceTree = "<group>"; };
1F29DE1A2842D54600811F48 /* FavoriteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -287,6 +286,7 @@
1F4781D1285DD5EB00047317 /* Order.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Order.swift; sourceTree = "<group>"; };
1F4781D4285DDFDC00047317 /* UserOrdersViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserOrdersViewController.swift; sourceTree = "<group>"; };
1F4781D6285DDFE200047317 /* UserOrdersPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserOrdersPresenter.swift; sourceTree = "<group>"; };
1F54FDEA289521F5009A2D07 /* DateFormatter + Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter + Extension.swift"; sourceTree = "<group>"; };
1F5D7FCA282E47BA00255E71 /* store-platform-mvp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "store-platform-mvp.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1F5D7FCD282E47BA00255E71 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1F5D7FCF282E47BA00255E71 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -573,7 +573,7 @@
1F96F59E282E7B8900C0F460 /* UITextField + Extension.swift */,
1F816C1A2837D95100F48CA0 /* UIImage + Extension.swift */,
1FDAC4EB285B839300CD5453 /* RadioButton.swift */,
1F2333742880938C005ED749 /* Date + Extension.swift */,
1F54FDEA289521F5009A2D07 /* DateFormatter + Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1656,6 +1656,7 @@
1F3F382B2847673800228983 /* SizePickerPresenter.swift in Sources */,
1FEB1567284E1A0F00DCCBC7 /* SellerViewController.swift in Sources */,
1F96F5A0282E7B8900C0F460 /* UIStackView + Extension.swift in Sources */,
1F54FDEB289521F5009A2D07 /* DateFormatter + Extension.swift in Sources */,
1FFFFB3D2835996D00E967E7 /* Item.swift in Sources */,
1F8FF0C6284BB15100171B83 /* FillBrandDataPresenter.swift in Sources */,
1FC0D5B4287EFFD200FAB933 /* FavoritesAssembler.swift in Sources */,
Expand Down Expand Up @@ -1683,7 +1684,6 @@
1FF6840A283A524B00E92481 /* GuestViewController.swift in Sources */,
1F1E4DA62838473200C9AC05 /* UserData.swift in Sources */,
1F96F5AD282E904C00C0F460 /* SizeCell.swift in Sources */,
1F2333752880938C005ED749 /* Date + Extension.swift in Sources */,
1FBE20DC285E0AB100E03AF0 /* DetailedProfileView.swift in Sources */,
1F96F5A4282E7B8900C0F460 /* UITextField + Extension.swift in Sources */,
1F5D7FD0282E47BA00255E71 /* SceneDelegate.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions store-platform-mvp/Coordinator/CreateAdCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class CreateAdCoordinator: BaseCoordinator, Coordinator {
}

func finish() {
self.navigationController.popViewController(animated: true)
self.finishFlow?()
// self.navigationController.popViewController(animated: true)
finishFlow?()
}
}

Expand Down
2 changes: 1 addition & 1 deletion store-platform-mvp/Coordinator/FeedCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FeedCoordinator: BaseCoordinator, Coordinator {

deinit {}

var finishFlow: (() -> ())?
var finishFlow: (() -> (Void))?

func start() {
showFeed()
Expand Down
33 changes: 25 additions & 8 deletions store-platform-mvp/Coordinator/OnboardingCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import UIKit

class OnboardingCoordinator: BaseCoordinator, Coordinator {
var navigationController: UINavigationController
var completionHandler: (() -> ())?
var finishFlow: (() -> (Void))?
weak var imageDelegate: ImagePickerDelegate?

func start() {
let module = OnboardingAssembler.buildOnboardingModule(coordinator: self)
Expand All @@ -21,16 +22,32 @@ class OnboardingCoordinator: BaseCoordinator, Coordinator {

self.navigationController.pushViewController(module, animated: true)
}

func hideOnboarding() {
self.navigationController.popToRootViewController(animated: true)
self.navigationController.viewControllers.removeAll()
finishFlow?()
}
}

extension OnboardingCoordinator: ImageCoordinatorProtocol {
func showDetailedImage(data: Data) {
let module = DetailedImageAssembler.buildDetailedImageModule(image: data)

self.navigationController.pushViewController(module, animated: true)
}

func showImagePicker() {
let imagePickerCoordinator = ImagePickerCoordinator(self.navigationController)
self.addDependency(imagePickerCoordinator)
imagePickerCoordinator.finishFlow = { [weak self, weak imagePickerCoordinator] image in
guard let imagePickerCoordinator = imagePickerCoordinator else { return }
self?.removeDependency(imagePickerCoordinator)

guard let image = image else { return }
self?.imageDelegate?.didImageAdded(image: image)
}

addDependency(imagePickerCoordinator)
imagePickerCoordinator.start()
}

func hideOnboarding() {
self.navigationController.popToRootViewController(animated: true)
self.navigationController.viewControllers.removeAll()
completionHandler?()
}
}
30 changes: 15 additions & 15 deletions store-platform-mvp/Coordinator/SellerCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class SellerCoordinator: BaseCoordinator, Coordinator {
weak var imageDelegate: ImagePickerDelegate?

func start() {
checkSellerStatus { status in
checkSellerStatus { [weak self] status in
switch status {
case true:
self.runSellerFlow()
self?.runSellerFlow()
case false:
self.runOnboardingFlow()
self?.runOnboardingFlow()
}
}
}
Expand All @@ -22,9 +22,11 @@ class SellerCoordinator: BaseCoordinator, Coordinator {

private func runOnboardingFlow() {
let onboardingCoordinator = OnboardingCoordinator(navigationController)
onboardingCoordinator.completionHandler = {
self.removeDependency(onboardingCoordinator)
self.runSellerFlow()
onboardingCoordinator.finishFlow = { [weak self, weak onboardingCoordinator] in
guard let onboardingCoordinator = onboardingCoordinator else { return }

self?.removeDependency(onboardingCoordinator)
self?.runSellerFlow()
}

addDependency(onboardingCoordinator)
Expand All @@ -37,20 +39,18 @@ class SellerCoordinator: BaseCoordinator, Coordinator {
self.navigationController.pushViewController(module, animated: true)
}

// public func showMessenger(with id: String, brandId: String) {
// let module = MessengerAssembler.buildMessengerModule(conversationId: id, brandId: brandId, coordinator: self)
//
// self.navigationController.pushViewController(module, animated: true)
// }

// FIXME: Allocation bug
public func showCreateAdScreen() {
let createAdCoordinator = CreateAdCoordinator(navigationController)
addDependency(createAdCoordinator)
createAdCoordinator.start()

createAdCoordinator.finishFlow = { [weak self] in
createAdCoordinator.finishFlow = { [weak self, weak createAdCoordinator] in
guard let createAdCoordinator = createAdCoordinator else { return }

self?.removeDependency(createAdCoordinator)
}

addDependency(createAdCoordinator)
createAdCoordinator.start()
}

public func showSellerOrders() {
Expand Down
85 changes: 0 additions & 85 deletions store-platform-mvp/Extensions/Date + Extension.swift

This file was deleted.

104 changes: 104 additions & 0 deletions store-platform-mvp/Extensions/DateFormatter + Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import UIKit

extension DateFormatter {
static let fullDateMedium: DateFormatter = {
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .medium
df.timeZone = .current
df.locale = Locale(identifier: "en_GB")

return df
}()

static let monthMedium: DateFormatter = {
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .medium
df.timeZone = .current
df.locale = Locale(identifier: "en_GB")
df.dateFormat = "MMM"

return df
}()

static let dayMedium: DateFormatter = {
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .medium
df.timeZone = .current
df.locale = Locale(identifier: "en_GB")
df.dateFormat = "d"

return df
}()

static let dayWithMonth: DateFormatter = {
let df = DateFormatter()
df.locale = .current
df.dateFormat = "d MMM"

return df
}()

static let time: DateFormatter = {
let df = DateFormatter()
df.locale = .current
df.dateFormat = "HH:mm"

return df
}()

static func getMonth(from date: Date = Date()) -> String {
return DateFormatter.monthMedium.string(from: date)
}

static func getDayWithMonth(from date: Date = Date()) -> String {
return DateFormatter.dayWithMonth.string(from: date)
}

static func getDayWithMonth(from date: String) -> String? {
guard let fullDate = DateFormatter.getFullDate(from: date) else {
return nil
}

let dayWithMonth = DateFormatter.getDayWithMonth(from: fullDate)
return dayWithMonth
}

static func getDay(from date: Date = Date()) -> Int? {
let stringDay = DateFormatter.dayMedium.string(from: date)
guard let intDay = Int(stringDay) else {
return nil
}

return intDay
}

static func getTime(from date: Date = Date()) -> String {
return DateFormatter.time.string(from: date)
}

static func getTime(from date: String) -> String? {
// Getting full date from string
guard let fullDate = DateFormatter.getFullDate(from: date) else {
return nil
}

// Convert it to string time
let time = DateFormatter.getTime(from: fullDate)
return time
}

static func getFullDate(from date: Date = Date()) -> String {
return DateFormatter.fullDateMedium.string(from: date)
}

static func getFullDate(from date: String) -> Date? {
guard let date = DateFormatter.fullDateMedium.date(from: date) else {
return nil
}

return date
}
}
Loading

0 comments on commit 3e7df0a

Please sign in to comment.