diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06a8660 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/Pods/ +/Templates/ +/Weather.xcodeproj/xcuserdata/ +/Weather.xcworkspace/xcuserdata/ +/R.generated.swift diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..520cd11 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,54 @@ +included: + - Weather + +excluded: + - Pods + +disabled_rules: + - force_cast + - object_literal + - syntactic_sugar + +opt_in_rules: + - empty_count + - conditional_returns_on_newline + - explicit_init + - closure_spacing + - overridden_super_call + - redundant_nil_coalescing + - private_outlet + - nimble_operator + - attributes + - joined_default_parameter + - operator_usage_whitespace + - first_where + - sorted_imports + - object_literal + - number_separator + - prohibited_super_call + - fatal_error_message + - vertical_parameter_alignment_on_call + - let_var_whitespace + - unneeded_parentheses_in_closure_argument + - extension_access_modifier + - pattern_matching_keywords + - multiline_parameters + - switch_case_on_newline + +identifier_name: + excluded: + - id + allowed_symbols: + - _ +line_length: 144 +type_name: + max_length: + warning: 50 + error: 60 + +number_separator: + minimum_length: 5 + +nesting: + type_level: + warning: 2 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3ef8a66 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +gem 'cocoapods', '~> 1.5.3' +gem 'generamba', github: 'strongself/Generamba', :branch => 'develop' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..a9ea916 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,94 @@ +GIT + remote: https://github.com/strongself/Generamba + revision: 4c450efc3ea63dd34fa04206194813dbb021441e + branch: develop + specs: + generamba (1.4.1) + cocoapods-core (= 1.5.3) + git (= 1.2.9.1) + liquid (= 4.0.0) + terminal-table (= 1.4.5) + thor (= 0.19.1) + xcodeproj (= 1.6.0) + +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.0) + activesupport (4.2.11) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + atomos (0.1.3) + claide (1.0.2) + cocoapods (1.5.3) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.5.3) + cocoapods-deintegrate (>= 1.0.2, < 2.0) + cocoapods-downloader (>= 1.2.0, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.3.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (~> 2.0.1) + gh_inspector (~> 1.0) + molinillo (~> 0.6.5) + nap (~> 1.0) + ruby-macho (~> 1.1) + xcodeproj (>= 1.5.7, < 2.0) + cocoapods-core (1.5.3) + activesupport (>= 4.0.2, < 6) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + cocoapods-deintegrate (1.0.2) + cocoapods-downloader (1.2.2) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.3.1) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.1.0) + colored2 (3.1.2) + concurrent-ruby (1.1.4) + escape (0.0.4) + fourflusher (2.0.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + git (1.2.9.1) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + liquid (4.0.0) + minitest (5.11.3) + molinillo (0.6.6) + nanaimo (0.2.6) + nap (1.1.0) + netrc (0.11.0) + ruby-macho (1.3.1) + terminal-table (1.4.5) + thor (0.19.1) + thread_safe (0.3.6) + tzinfo (1.2.5) + thread_safe (~> 0.1) + xcodeproj (1.6.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.6) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods (~> 1.5.3) + generamba! + +BUNDLED WITH + 1.17.3 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..69528b9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Sergey Krupov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..c5cd51e --- /dev/null +++ b/Podfile @@ -0,0 +1,22 @@ + +platform :ios, '9.0' + +target 'Weather' do + + use_frameworks! + + pod 'RxSwift', '~> 4.4.0' + pod 'RxCocoa', '~> 4.4.0' + pod 'RxDataSources', '~> 3.1.0' + pod 'R.swift', '~> 5.0.0' + pod 'Swinject', '~> 2.5.0' + pod 'SwinjectStoryboard', '~> 2.1.0' + pod 'Alamofire', '~> 4.8.1' + pod 'SwiftLint' + + target 'WeatherTests' do + inherit! :search_paths + # Pods for testing + end + +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..09aeb01 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,60 @@ +PODS: + - Alamofire (4.8.1) + - Differentiator (3.1.0) + - R.swift (5.0.2): + - R.swift.Library (~> 5.0.0) + - R.swift.Library (5.0.0) + - RxAtomic (4.4.0) + - RxCocoa (4.4.0): + - RxSwift (~> 4.0) + - RxDataSources (3.1.0): + - Differentiator (~> 3.0) + - RxCocoa (~> 4.0) + - RxSwift (~> 4.0) + - RxSwift (4.4.0): + - RxAtomic (~> 4.4) + - SwiftLint (0.30.1) + - Swinject (2.5.0) + - SwinjectStoryboard (2.1.0): + - Swinject (~> 2.5) + +DEPENDENCIES: + - Alamofire (~> 4.8.1) + - R.swift (~> 5.0.0) + - RxCocoa (~> 4.4.0) + - RxDataSources (~> 3.1.0) + - RxSwift (~> 4.4.0) + - SwiftLint + - Swinject (~> 2.5.0) + - SwinjectStoryboard (~> 2.1.0) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - Alamofire + - Differentiator + - R.swift + - R.swift.Library + - RxAtomic + - RxCocoa + - RxDataSources + - RxSwift + - SwiftLint + - Swinject + - SwinjectStoryboard + +SPEC CHECKSUMS: + Alamofire: 16ce2c353fb72865124ddae8a57c5942388f4f11 + Differentiator: be49ca3408f0ecfc761e4c7763d20c62be01b9ad + R.swift: 81455d81467763cbd3f4d79d938d05f4ac4c0228 + R.swift.Library: 0bf390e729bc10bb2c9e4fb78bd043164a7be4ff + RxAtomic: eacf60db868c96bfd63320e28619fe29c179656f + RxCocoa: df63ebf7b9a70d6b4eeea407ed5dd4efc8979749 + RxDataSources: a843bad90c29817f5923ec8163f4af2de084ceb3 + RxSwift: 5976ecd04fc2fefd648827c23de5e11157faa973 + SwiftLint: a54bf1fe12b55c68560eb2a7689dfc81458508f7 + Swinject: 82cdb851f63f91bba974e3eca1d69780f2f7677e + SwinjectStoryboard: 688f096033103e66ffcf6ca678211acd7d7be505 + +PODFILE CHECKSUM: e07856620ae84e1db1a6b49e1cbfbe41a53da4cf + +COCOAPODS: 1.5.3 diff --git a/README.md b/README.md new file mode 100644 index 0000000..16b425d --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Weather +Тестовое приложение, показывающее прогноз погоды diff --git a/Rambafile b/Rambafile new file mode 100644 index 0000000..da8ce4d --- /dev/null +++ b/Rambafile @@ -0,0 +1,25 @@ +### Headers settings +company: Home + +### Xcode project settings +project_name: Weather +xcodeproj_path: Weather.xcodeproj + +### Code generation settings section +# The main project target name +project_target: Weather + +# The file path for new modules +project_file_path: Weather/Modules + +# The Xcode group path to new modules +project_group_path: Weather/Modules + +### Templates +templates: +- {name: rviper_controller} +- {name: mvvm_controller} +- {name: swifty_viper} + +templates: +- {name: viperSwift, local: 'viperSwift'} diff --git a/RxViper/Code/Assembly/assemblycontainer.swift.liquid b/RxViper/Code/Assembly/assemblycontainer.swift.liquid new file mode 100755 index 0000000..a37dbcd --- /dev/null +++ b/RxViper/Code/Assembly/assemblycontainer.swift.liquid @@ -0,0 +1,38 @@ +// +// {{ prefix }}{{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import Swinject +import SwinjectStoryboard + +final class {{ module_info.name }}AssemblyContainer: Assembly { + + func assemble(container: Container) { + container.register({{ module_info.name }}InteractorProtocol.self) { resolver in + let interactor = {{ module_info.name }}Interactor() + return interactor + } + + container.register({{ module_info.name }}RouterProtocol.self) { (resolver, viewController: {{ module_info.name }}ViewController) in + let router = {{ module_info.name }}Router() + return router + } + + container.register({{ module_info.name }}Presenter.self) { (resolver, viewController: {{ module_info.name }}ViewController) in + let presenter = {{ module_info.name }}Presenter() + presenter.view = viewController + presenter.interactor = resolver.resolve({{ module_info.name }}InteractorProtocol.self) + presenter.router = resolver.resolve({{ module_info.name }}RouterProtocol.self, argument: viewController) + return presenter + } + + container.storyboardInitCompleted({{ module_info.name }}ViewController.self) { resolver, viewController in + let presenter = resolver.resolve({{ module_info.name }}Presenter.self, argument: viewController)! + viewController.setPresenter(presenter) + } + } +} \ No newline at end of file diff --git a/RxViper/Code/Interactor/interactor.swift.liquid b/RxViper/Code/Interactor/interactor.swift.liquid new file mode 100755 index 0000000..9f807ff --- /dev/null +++ b/RxViper/Code/Interactor/interactor.swift.liquid @@ -0,0 +1,17 @@ +// +// {{ prefix }}{{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class {{ module_info.name }}Interactor: {{ module_info.name }}InteractorProtocol { + + // MARK: - Dependencies + + // MARK: - {{ module_info.name }}InteractorProtocol +} \ No newline at end of file diff --git a/RxViper/Code/Interactor/interactor_protocol.swift.liquid b/RxViper/Code/Interactor/interactor_protocol.swift.liquid new file mode 100644 index 0000000..c77ce96 --- /dev/null +++ b/RxViper/Code/Interactor/interactor_protocol.swift.liquid @@ -0,0 +1,14 @@ +// +// {{ prefix }}{{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol {{ module_info.name }}InteractorProtocol: class { + +} diff --git a/RxViper/Code/Presenter/module_input.swift.liquid b/RxViper/Code/Presenter/module_input.swift.liquid new file mode 100755 index 0000000..d8275f2 --- /dev/null +++ b/RxViper/Code/Presenter/module_input.swift.liquid @@ -0,0 +1,11 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +protocol {{ module_info.name }}ModuleInput: class { + +} diff --git a/RxViper/Code/Presenter/presenter.swift.liquid b/RxViper/Code/Presenter/presenter.swift.liquid new file mode 100755 index 0000000..204026c --- /dev/null +++ b/RxViper/Code/Presenter/presenter.swift.liquid @@ -0,0 +1,32 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class {{ module_info.name }}Presenter { + + // MARK: - Properties + var interactor: {{ module_info.name }}InteractorProtocol! + var router: {{ module_info.name }}RouterProtocol! + weak var view: {{ module_info.name }}ViewProtocol? + + // MARK: - Private + private let disposeBag = DisposeBag() +} + +// MARK: - {{ module_info.name }}PesenterProtocol +extension {{ module_info.name }}Presenter: {{ module_info.name }}PresenterProtocol { + + func setupBindings(_ view: {{ module_info.name }}ViewProtocol) { + } +} + +// MARK: - {{ module_info.name }}ModuleInput +extension {{ module_info.name }}Presenter: {{ module_info.name }}ModuleInput { +} diff --git a/RxViper/Code/Presenter/presenter_protocol.swift.liquid b/RxViper/Code/Presenter/presenter_protocol.swift.liquid new file mode 100644 index 0000000..490d773 --- /dev/null +++ b/RxViper/Code/Presenter/presenter_protocol.swift.liquid @@ -0,0 +1,12 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +protocol {{ module_info.name }}PresenterProtocol { + + func setupBindings(_ view: {{ module_info.name }}ViewProtocol) +} diff --git a/RxViper/Code/Router/router.swift.liquid b/RxViper/Code/Router/router.swift.liquid new file mode 100755 index 0000000..93eb6fd --- /dev/null +++ b/RxViper/Code/Router/router.swift.liquid @@ -0,0 +1,11 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +final class {{ module_info.name }}Router: {{ module_info.name }}RouterProtocol { + +} diff --git a/RxViper/Code/Router/router_protocol.swift.liquid b/RxViper/Code/Router/router_protocol.swift.liquid new file mode 100755 index 0000000..6d52318 --- /dev/null +++ b/RxViper/Code/Router/router_protocol.swift.liquid @@ -0,0 +1,13 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import Foundation + +protocol {{ module_info.name }}RouterProtocol: class { + +} diff --git a/RxViper/Code/View/view_protocol.swift.liquid b/RxViper/Code/View/view_protocol.swift.liquid new file mode 100644 index 0000000..96ca39b --- /dev/null +++ b/RxViper/Code/View/view_protocol.swift.liquid @@ -0,0 +1,17 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol {{ module_info.name }}ViewProtocol: class { + + // MARK: - Input + + // MARK: - Output +} diff --git a/RxViper/Code/View/viewcontroller.swift.liquid b/RxViper/Code/View/viewcontroller.swift.liquid new file mode 100755 index 0000000..8e2aeda --- /dev/null +++ b/RxViper/Code/View/viewcontroller.swift.liquid @@ -0,0 +1,38 @@ +// +// {{ module_info.name }}{{ module_info.file_name }} +// {{ module_info.project_name }} +// +// Created by {{ developer.name }} on {{ date }}. +// Copyright © {{ year }} {{ developer.company }}. All rights reserved. +// + +import UIKit +import RxCocoa +import RxSwift + +final class {{ module_info.name }}ViewController: UIViewController { + + // MARK: - Outlets + + // MARK: - Public + func setPresenter(_ presenter: {{ module_info.name }}PresenterProtocol) { + self.presenter = presenter + } + + // MARK: - Life cycle + override func viewDidLoad() { + super.viewDidLoad() + presenter?.setupBindings(self) + } + + // MARK: - Private + private var presenter: {{ module_info.name }}PresenterProtocol? +} + +// MARK: - {{ module_info.name }}ViewInput +extension {{ module_info.name }}ViewController: {{ module_info.name }}ViewProtocol { + + func setupInitialState() { + } +} + diff --git a/RxViper/RxViper.rambaspec b/RxViper/RxViper.rambaspec new file mode 100755 index 0000000..aec2f39 --- /dev/null +++ b/RxViper/RxViper.rambaspec @@ -0,0 +1,29 @@ +# Template information section +name: "viperSwiftRx" +summary: "ViperModule with Swinject & RxSwift" +author: "Sergey V. Krupov" +version: "0.1.2" +license: "MIT" + +# The declarations for code files + +code_files: +# Assembly +- {name: Assembly/AssemblyContainer.swift, path: Code/Assembly/assemblycontainer.swift.liquid} + +# View layer +- {name: View/ViewController.swift, path: Code/View/viewcontroller.swift.liquid} +- {name: View/ViewProtocol.swift, path: Code/View/view_protocol.swift.liquid} + +# Presenter layer +- {name: Presenter/ModuleInput.swift, path: Code/Presenter/module_input.swift.liquid} +- {name: Presenter/Presenter.swift, path: Code/Presenter/presenter.swift.liquid} +- {name: Presenter/PresenterProtocol.swift, path: Code/Presenter/presenter_protocol.swift.liquid} + +# Interactor layer +- {name: Interactor/InteractorProtocol.swift, path: Code/Interactor/interactor_protocol.swift.liquid} +- {name: Interactor/Interactor.swift, path: Code/Interactor/interactor.swift.liquid} + +# Router layer +- {name: Router/RouterProtocol.swift, path: Code/Router/router_protocol.swift.liquid} +- {name: Router/Router.swift, path: Code/Router/router.swift.liquid} diff --git a/Weather.xcodeproj/project.pbxproj b/Weather.xcodeproj/project.pbxproj index 1a7b81a..5de3916 100644 --- a/Weather.xcodeproj/project.pbxproj +++ b/Weather.xcodeproj/project.pbxproj @@ -7,12 +7,77 @@ objects = { /* Begin PBXBuildFile section */ + 006DB9A065C1CA46500142A1 /* MainPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1ADE96DCB61DB76CE378D7 /* MainPresenter.swift */; }; + 09AB02CB8B629AA9704EFB7E /* SettingsRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757FFF6FDAF03CEC7C661F9B /* SettingsRouter.swift */; }; + 0C3D1E6453F92226F941ECFA /* RootRouterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA54BBA8ECC99BCB65A3920 /* RootRouterProtocol.swift */; }; + 117ADB173EF54AF05477DAE4 /* ForecastPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D774BE9C0BC9FE431B693B7A /* ForecastPresenter.swift */; }; + 2072A2AD181B207EEEC0FC36 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71725D6D137BDE88FCC05CAE /* MainViewController.swift */; }; + 2A8938784AB747645D1F0D70 /* MainModuleInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC7AD71D6D4B648D380B46C9 /* MainModuleInput.swift */; }; + 2DDCA54FF830B71BEF49D713 /* RootInteractorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B41FBF9DD373DE6180E79571 /* RootInteractorProtocol.swift */; }; + 2E79E308652298F6F8985E29 /* RootRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94BBF25345413B2FC1196E95 /* RootRouter.swift */; }; + 30D85DBBB8550DBA9C5939C5 /* RootModuleInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = C790210476F83745C1EB66DC /* RootModuleInput.swift */; }; + 3A354C154EDC732288CA1AA6 /* MainRouterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8666B7D50994A67CBA328E2 /* MainRouterProtocol.swift */; }; + 3B059344697AA9B9A4B860FA /* SettingsAssemblyContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FFAA6447906EF9D1AA79746 /* SettingsAssemblyContainer.swift */; }; + 44D29A98F0B5DCB1560BF743 /* Pods_WeatherTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03BB9D1BA32CC0D8DEF98EA3 /* Pods_WeatherTests.framework */; }; + 499BE77931D09DA7AEB4A781 /* ForecastAssemblyContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1476AC3400AFFA07ACC2F5F8 /* ForecastAssemblyContainer.swift */; }; + 58815EB0C695A513E9AF40EF /* ForecastInteractorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AF42257167128E914BBB8E /* ForecastInteractorProtocol.swift */; }; + 5AC66E084CFAAC1A1AD32335 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E6EE7AE29CF927798F39CD /* SettingsViewController.swift */; }; + 63E9FC28AF76275F86571E06 /* RootPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 071AD597BA5EEAD6FA3EBBDE /* RootPresenter.swift */; }; + 6467B37621D34B9B7E7B9625 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D423C31853981F02AA0154 /* RootViewController.swift */; }; + 6A0F8A803FD49AF1560D99DF /* ForecastInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736ECFB054B23D8BE23F9DB8 /* ForecastInteractor.swift */; }; + 6E264E7665975DEED2ABC927 /* RootAssemblyContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C61E09AA03BD04C093442DF /* RootAssemblyContainer.swift */; }; + 781645B6B09CA7A4A8D35BC2 /* MainAssemblyContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA97BED45186AD523E7F325 /* MainAssemblyContainer.swift */; }; + 793B2B42A883F924AE7C2FC8 /* SettingsInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4249FEE5F13036A534EF1327 /* SettingsInteractor.swift */; }; + 85DA8E6C3BC1B5EDD428D079 /* MainRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA3FF49282529BAF3C70C576 /* MainRouter.swift */; }; + 88F146F7F1ED02E31C450B57 /* SettingsInteractorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F6182D635523DBC148322CA /* SettingsInteractorProtocol.swift */; }; + 898B3286578E6B18088D3308 /* SettingsViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E685F1B61CCA8AC4D3CB5B86 /* SettingsViewProtocol.swift */; }; + 8AE316B93B8254AD75BEC35C /* RootViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CF8D19C67D3AC92B0F9B4B7 /* RootViewProtocol.swift */; }; + 970195C8D54BD4946B0DF592 /* SettingsModuleInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2915E93CEC5978555412EA9 /* SettingsModuleInput.swift */; }; + 9D31BE73A5EA5A23B7BB3BAF /* SettingsRouterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69EA0CC9873473125A669348 /* SettingsRouterProtocol.swift */; }; + A09304581BE7E8B9D0C6698A /* SettingsPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F96FCC6485C351AC595D49A4 /* SettingsPresenter.swift */; }; + A503394C22034D8200659545 /* Cities.json in Resources */ = {isa = PBXBuildFile; fileRef = A503394B22034D8200659545 /* Cities.json */; }; + A503FF0622007C44003C15CA /* SettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF0522007C44003C15CA /* SettingsService.swift */; }; + A503FF0B22007E14003C15CA /* City.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF0A22007E14003C15CA /* City.swift */; }; + A503FF0D22007FCF003C15CA /* SettingsServiceAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF0C22007FCF003C15CA /* SettingsServiceAssembly.swift */; }; + A503FF0F220166EE003C15CA /* Root.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A503FF0E220166EE003C15CA /* Root.storyboard */; }; + A503FF1122016882003C15CA /* Forecast.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A503FF1022016882003C15CA /* Forecast.storyboard */; }; + A503FF13220168B9003C15CA /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A503FF12220168B9003C15CA /* Settings.storyboard */; }; + A503FF152201A034003C15CA /* Icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A503FF142201A034003C15CA /* Icons.xcassets */; }; + A503FF192202B529003C15CA /* WeatherItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF182202B529003C15CA /* WeatherItem.swift */; }; + A503FF1C2202B68B003C15CA /* ForecastItemCellTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF1A2202B68B003C15CA /* ForecastItemCellTableViewCell.swift */; }; + A503FF1D2202B68B003C15CA /* ForecastItemCellTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A503FF1B2202B68B003C15CA /* ForecastItemCellTableViewCell.xib */; }; + A503FF222202D2D6003C15CA /* SettingsCityCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF202202D2D6003C15CA /* SettingsCityCell.swift */; }; + A503FF232202D2D6003C15CA /* SettingsCityCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A503FF212202D2D6003C15CA /* SettingsCityCell.xib */; }; + A503FF262202D32D003C15CA /* CityItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF252202D32D003C15CA /* CityItem.swift */; }; + A503FF282202D47C003C15CA /* CitiesSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF272202D47C003C15CA /* CitiesSection.swift */; }; + A503FF2B2202FB72003C15CA /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = A503FF2A2202FB72003C15CA /* Utils.swift */; }; + A5A5E1FF21FF033500A2059E /* SwinjectStoryboard+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E1FE21FF033500A2059E /* SwinjectStoryboard+Setup.swift */; }; + A5A5E20221FF19B300A2059E /* R.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E20121FF19B300A2059E /* R.generated.swift */; }; + A5A5E20721FF1AF300A2059E /* WeatherService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E20621FF1AF300A2059E /* WeatherService.swift */; }; + A5A5E20921FF1C2800A2059E /* NetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E20821FF1C2800A2059E /* NetworkService.swift */; }; + A5A5E20C21FF241400A2059E /* Weather.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E20B21FF241400A2059E /* Weather.swift */; }; + A5A5E20E21FF2A2200A2059E /* ApiResponses.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E20D21FF2A2200A2059E /* ApiResponses.swift */; }; + A5A5E21021FF2F0000A2059E /* NetworkServiceAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E20F21FF2F0000A2059E /* NetworkServiceAssembly.swift */; }; + A5A5E21221FF302B00A2059E /* WeatherServiceAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A5E21121FF302B00A2059E /* WeatherServiceAssembly.swift */; }; + A5BA73CD220022E00099641D /* MainPresenterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5BA73CC220022E00099641D /* MainPresenterProtocol.swift */; }; A5EE267921FED57C00618447 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EE267821FED57C00618447 /* AppDelegate.swift */; }; - A5EE267B21FED57C00618447 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EE267A21FED57C00618447 /* ViewController.swift */; }; A5EE267E21FED57C00618447 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A5EE267C21FED57C00618447 /* Main.storyboard */; }; A5EE268021FED57E00618447 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A5EE267F21FED57E00618447 /* Assets.xcassets */; }; A5EE268321FED57E00618447 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A5EE268121FED57E00618447 /* LaunchScreen.storyboard */; }; A5EE268E21FED57E00618447 /* WeatherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EE268D21FED57E00618447 /* WeatherTests.swift */; }; + A9093C67C67A19ABDB8A8470 /* ForecastViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 155293F6A8DE6CA58CB9A477 /* ForecastViewController.swift */; }; + B11069CE8301CF288FC9C33A /* ForecastRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E998DC5ED738939E69DF61AA /* ForecastRouter.swift */; }; + B2F8B20DEB11FF97C120826B /* ForecastPresenterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FDF753ED86E521A10443113 /* ForecastPresenterProtocol.swift */; }; + BCCB02966EAA32758D46515F /* MainViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 578F3D3E332A7D7B35D4434B /* MainViewProtocol.swift */; }; + C3A36ED60E4FB24BAD6E08EB /* ForecastModuleInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E8C2051080907DE3DA8E131 /* ForecastModuleInput.swift */; }; + C4D0A5E098AF865E28D0EB6F /* SettingsPresenterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC6A4FA75B92A88DA32D618C /* SettingsPresenterProtocol.swift */; }; + C9234DF481BE3E0C46964F46 /* Pods_Weather.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C36A94B916E852EBB4E6636 /* Pods_Weather.framework */; }; + CA4755BDA0CB30CA0B1FE240 /* MainInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D69010E35AA4E1D3BC7B56BF /* MainInteractor.swift */; }; + CF7E8E383F79CDA642CE74C4 /* RootPresenterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29173DE0924DBD205F0E6033 /* RootPresenterProtocol.swift */; }; + D472251FE5427B2E7189F74C /* ForecastRouterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF86011D35240501ADD7CF54 /* ForecastRouterProtocol.swift */; }; + DC8C1911CB3C8F8C000AEA76 /* MainInteractorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EF9A17CFF0162313238A56D /* MainInteractorProtocol.swift */; }; + E933B27929CECFC35EC20CD8 /* RootInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B384465FCA28308B340E85C /* RootInteractor.swift */; }; + FC39B811B4AD39407D1CEC4E /* ForecastViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5AF56FA7E16FA3001F8838D /* ForecastViewProtocol.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -26,9 +91,60 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 03BB9D1BA32CC0D8DEF98EA3 /* Pods_WeatherTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WeatherTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 071AD597BA5EEAD6FA3EBBDE /* RootPresenter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootPresenter.swift; sourceTree = ""; }; + 0C36A94B916E852EBB4E6636 /* Pods_Weather.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Weather.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 1476AC3400AFFA07ACC2F5F8 /* ForecastAssemblyContainer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastAssemblyContainer.swift; sourceTree = ""; }; + 155293F6A8DE6CA58CB9A477 /* ForecastViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastViewController.swift; sourceTree = ""; }; + 1EA54BBA8ECC99BCB65A3920 /* RootRouterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootRouterProtocol.swift; sourceTree = ""; }; + 1F6182D635523DBC148322CA /* SettingsInteractorProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsInteractorProtocol.swift; sourceTree = ""; }; + 29173DE0924DBD205F0E6033 /* RootPresenterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootPresenterProtocol.swift; sourceTree = ""; }; + 2DA97BED45186AD523E7F325 /* MainAssemblyContainer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainAssemblyContainer.swift; sourceTree = ""; }; + 4249FEE5F13036A534EF1327 /* SettingsInteractor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsInteractor.swift; sourceTree = ""; }; + 4B384465FCA28308B340E85C /* RootInteractor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootInteractor.swift; sourceTree = ""; }; + 4FFAA6447906EF9D1AA79746 /* SettingsAssemblyContainer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsAssemblyContainer.swift; sourceTree = ""; }; + 578F3D3E332A7D7B35D4434B /* MainViewProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainViewProtocol.swift; sourceTree = ""; }; + 5CF8D19C67D3AC92B0F9B4B7 /* RootViewProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootViewProtocol.swift; sourceTree = ""; }; + 5E8C2051080907DE3DA8E131 /* ForecastModuleInput.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastModuleInput.swift; sourceTree = ""; }; + 6738335F37486B828CF3305E /* Pods-Weather.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Weather.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Weather/Pods-Weather.debug.xcconfig"; sourceTree = ""; }; + 69E55FA44A8347B7197A8DAC /* Pods-Weather.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Weather.release.xcconfig"; path = "Pods/Target Support Files/Pods-Weather/Pods-Weather.release.xcconfig"; sourceTree = ""; }; + 69EA0CC9873473125A669348 /* SettingsRouterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsRouterProtocol.swift; sourceTree = ""; }; + 71725D6D137BDE88FCC05CAE /* MainViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; + 736ECFB054B23D8BE23F9DB8 /* ForecastInteractor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastInteractor.swift; sourceTree = ""; }; + 757FFF6FDAF03CEC7C661F9B /* SettingsRouter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsRouter.swift; sourceTree = ""; }; + 7C61E09AA03BD04C093442DF /* RootAssemblyContainer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootAssemblyContainer.swift; sourceTree = ""; }; + 7FDF753ED86E521A10443113 /* ForecastPresenterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastPresenterProtocol.swift; sourceTree = ""; }; + 94BBF25345413B2FC1196E95 /* RootRouter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootRouter.swift; sourceTree = ""; }; + 95AF42257167128E914BBB8E /* ForecastInteractorProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastInteractorProtocol.swift; sourceTree = ""; }; + 96D423C31853981F02AA0154 /* RootViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = ""; }; + 9EF9A17CFF0162313238A56D /* MainInteractorProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainInteractorProtocol.swift; sourceTree = ""; }; + A503394B22034D8200659545 /* Cities.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Cities.json; sourceTree = ""; }; + A503FF0522007C44003C15CA /* SettingsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsService.swift; sourceTree = ""; }; + A503FF0A22007E14003C15CA /* City.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = City.swift; sourceTree = ""; }; + A503FF0C22007FCF003C15CA /* SettingsServiceAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsServiceAssembly.swift; sourceTree = ""; }; + A503FF0E220166EE003C15CA /* Root.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Root.storyboard; sourceTree = ""; }; + A503FF1022016882003C15CA /* Forecast.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Forecast.storyboard; sourceTree = ""; }; + A503FF12220168B9003C15CA /* Settings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = ""; }; + A503FF142201A034003C15CA /* Icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icons.xcassets; sourceTree = ""; }; + A503FF182202B529003C15CA /* WeatherItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherItem.swift; sourceTree = ""; }; + A503FF1A2202B68B003C15CA /* ForecastItemCellTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastItemCellTableViewCell.swift; sourceTree = ""; }; + A503FF1B2202B68B003C15CA /* ForecastItemCellTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ForecastItemCellTableViewCell.xib; sourceTree = ""; }; + A503FF202202D2D6003C15CA /* SettingsCityCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsCityCell.swift; sourceTree = ""; }; + A503FF212202D2D6003C15CA /* SettingsCityCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingsCityCell.xib; sourceTree = ""; }; + A503FF252202D32D003C15CA /* CityItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityItem.swift; sourceTree = ""; }; + A503FF272202D47C003C15CA /* CitiesSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CitiesSection.swift; sourceTree = ""; }; + A503FF2A2202FB72003C15CA /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; + A5A5E1FE21FF033500A2059E /* SwinjectStoryboard+Setup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SwinjectStoryboard+Setup.swift"; sourceTree = ""; }; + A5A5E20121FF19B300A2059E /* R.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = R.generated.swift; sourceTree = ""; }; + A5A5E20621FF1AF300A2059E /* WeatherService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherService.swift; sourceTree = ""; }; + A5A5E20821FF1C2800A2059E /* NetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkService.swift; sourceTree = ""; }; + A5A5E20B21FF241400A2059E /* Weather.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weather.swift; sourceTree = ""; }; + A5A5E20D21FF2A2200A2059E /* ApiResponses.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiResponses.swift; sourceTree = ""; }; + A5A5E20F21FF2F0000A2059E /* NetworkServiceAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkServiceAssembly.swift; sourceTree = ""; }; + A5A5E21121FF302B00A2059E /* WeatherServiceAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherServiceAssembly.swift; sourceTree = ""; }; + A5BA73CC220022E00099641D /* MainPresenterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainPresenterProtocol.swift; sourceTree = ""; }; A5EE267521FED57C00618447 /* Weather.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Weather.app; sourceTree = BUILT_PRODUCTS_DIR; }; A5EE267821FED57C00618447 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - A5EE267A21FED57C00618447 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; A5EE267D21FED57C00618447 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; A5EE267F21FED57E00618447 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; A5EE268221FED57E00618447 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -36,6 +152,24 @@ A5EE268921FED57E00618447 /* WeatherTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WeatherTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A5EE268D21FED57E00618447 /* WeatherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherTests.swift; sourceTree = ""; }; A5EE268F21FED57E00618447 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AD1ADE96DCB61DB76CE378D7 /* MainPresenter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainPresenter.swift; sourceTree = ""; }; + B41FBF9DD373DE6180E79571 /* RootInteractorProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootInteractorProtocol.swift; sourceTree = ""; }; + B6395620A61D55DD7CFA9BA3 /* Pods-WeatherTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WeatherTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WeatherTests/Pods-WeatherTests.release.xcconfig"; sourceTree = ""; }; + C0E6EE7AE29CF927798F39CD /* SettingsViewController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = ""; }; + C5B0A54CAA8FAA068B0525A1 /* Pods-WeatherTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WeatherTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WeatherTests/Pods-WeatherTests.debug.xcconfig"; sourceTree = ""; }; + C790210476F83745C1EB66DC /* RootModuleInput.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = RootModuleInput.swift; sourceTree = ""; }; + C8666B7D50994A67CBA328E2 /* MainRouterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainRouterProtocol.swift; sourceTree = ""; }; + CA3FF49282529BAF3C70C576 /* MainRouter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainRouter.swift; sourceTree = ""; }; + D2915E93CEC5978555412EA9 /* SettingsModuleInput.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsModuleInput.swift; sourceTree = ""; }; + D69010E35AA4E1D3BC7B56BF /* MainInteractor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainInteractor.swift; sourceTree = ""; }; + D774BE9C0BC9FE431B693B7A /* ForecastPresenter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastPresenter.swift; sourceTree = ""; }; + DC6A4FA75B92A88DA32D618C /* SettingsPresenterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsPresenterProtocol.swift; sourceTree = ""; }; + DC7AD71D6D4B648D380B46C9 /* MainModuleInput.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MainModuleInput.swift; sourceTree = ""; }; + E685F1B61CCA8AC4D3CB5B86 /* SettingsViewProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsViewProtocol.swift; sourceTree = ""; }; + E998DC5ED738939E69DF61AA /* ForecastRouter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastRouter.swift; sourceTree = ""; }; + EF86011D35240501ADD7CF54 /* ForecastRouterProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastRouterProtocol.swift; sourceTree = ""; }; + F5AF56FA7E16FA3001F8838D /* ForecastViewProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ForecastViewProtocol.swift; sourceTree = ""; }; + F96FCC6485C351AC595D49A4 /* SettingsPresenter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SettingsPresenter.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -43,6 +177,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C9234DF481BE3E0C46964F46 /* Pods_Weather.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -50,18 +185,285 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 44D29A98F0B5DCB1560BF743 /* Pods_WeatherTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0ED154AF9A3E25CE41613337 /* View */ = { + isa = PBXGroup; + children = ( + A503FF0E220166EE003C15CA /* Root.storyboard */, + 96D423C31853981F02AA0154 /* RootViewController.swift */, + 5CF8D19C67D3AC92B0F9B4B7 /* RootViewProtocol.swift */, + ); + path = View; + sourceTree = ""; + }; + 1399F4B486CEF7B22A86F0F9 /* Pods */ = { + isa = PBXGroup; + children = ( + 6738335F37486B828CF3305E /* Pods-Weather.debug.xcconfig */, + 69E55FA44A8347B7197A8DAC /* Pods-Weather.release.xcconfig */, + C5B0A54CAA8FAA068B0525A1 /* Pods-WeatherTests.debug.xcconfig */, + B6395620A61D55DD7CFA9BA3 /* Pods-WeatherTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 1735C5817D169BB415B4912F /* Assembly */ = { + isa = PBXGroup; + children = ( + 4FFAA6447906EF9D1AA79746 /* SettingsAssemblyContainer.swift */, + ); + path = Assembly; + sourceTree = ""; + }; + 20FAC95DD92F177657CB26AF /* Presenter */ = { + isa = PBXGroup; + children = ( + C790210476F83745C1EB66DC /* RootModuleInput.swift */, + 071AD597BA5EEAD6FA3EBBDE /* RootPresenter.swift */, + 29173DE0924DBD205F0E6033 /* RootPresenterProtocol.swift */, + ); + path = Presenter; + sourceTree = ""; + }; + 221E45F93BEFC4F7B2FEB1FF /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0C36A94B916E852EBB4E6636 /* Pods_Weather.framework */, + 03BB9D1BA32CC0D8DEF98EA3 /* Pods_WeatherTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 239F6A31881E0D237558D41E /* Assembly */ = { + isa = PBXGroup; + children = ( + 1476AC3400AFFA07ACC2F5F8 /* ForecastAssemblyContainer.swift */, + ); + path = Assembly; + sourceTree = ""; + }; + 437FF6E8C1CA79E355696A06 /* Assembly */ = { + isa = PBXGroup; + children = ( + 7C61E09AA03BD04C093442DF /* RootAssemblyContainer.swift */, + ); + path = Assembly; + sourceTree = ""; + }; + 46073904D49EA4889EF6FF16 /* Router */ = { + isa = PBXGroup; + children = ( + 1EA54BBA8ECC99BCB65A3920 /* RootRouterProtocol.swift */, + 94BBF25345413B2FC1196E95 /* RootRouter.swift */, + ); + path = Router; + sourceTree = ""; + }; + 54DD7061E508D533BA3ADD6D /* Settings */ = { + isa = PBXGroup; + children = ( + 1735C5817D169BB415B4912F /* Assembly */, + BD3F92DF0959FE0E340E2D68 /* View */, + 834842758FA59B37566C8E96 /* Presenter */, + F489FA8EBE5D017921C10AC7 /* Interactor */, + 879ADF32BFA29CFB0BEF3B49 /* Router */, + ); + path = Settings; + sourceTree = ""; + }; + 685A3CB8C4C26E5187AE988D /* View */ = { + isa = PBXGroup; + children = ( + A503FF1E2202B68F003C15CA /* Cells */, + A503FF1022016882003C15CA /* Forecast.storyboard */, + 155293F6A8DE6CA58CB9A477 /* ForecastViewController.swift */, + F5AF56FA7E16FA3001F8838D /* ForecastViewProtocol.swift */, + ); + path = View; + sourceTree = ""; + }; + 6935CE3134022C3A82DC52CF /* Interactor */ = { + isa = PBXGroup; + children = ( + B41FBF9DD373DE6180E79571 /* RootInteractorProtocol.swift */, + 4B384465FCA28308B340E85C /* RootInteractor.swift */, + ); + path = Interactor; + sourceTree = ""; + }; + 6EF8EFA4C52A33AECE748448 /* Interactor */ = { + isa = PBXGroup; + children = ( + D69010E35AA4E1D3BC7B56BF /* MainInteractor.swift */, + 9EF9A17CFF0162313238A56D /* MainInteractorProtocol.swift */, + ); + path = Interactor; + sourceTree = ""; + }; + 834842758FA59B37566C8E96 /* Presenter */ = { + isa = PBXGroup; + children = ( + A503FF242202D320003C15CA /* Models */, + D2915E93CEC5978555412EA9 /* SettingsModuleInput.swift */, + F96FCC6485C351AC595D49A4 /* SettingsPresenter.swift */, + DC6A4FA75B92A88DA32D618C /* SettingsPresenterProtocol.swift */, + ); + path = Presenter; + sourceTree = ""; + }; + 879ADF32BFA29CFB0BEF3B49 /* Router */ = { + isa = PBXGroup; + children = ( + 69EA0CC9873473125A669348 /* SettingsRouterProtocol.swift */, + 757FFF6FDAF03CEC7C661F9B /* SettingsRouter.swift */, + ); + path = Router; + sourceTree = ""; + }; + 8FB8BA8098907C6F02D70F64 /* Router */ = { + isa = PBXGroup; + children = ( + EF86011D35240501ADD7CF54 /* ForecastRouterProtocol.swift */, + E998DC5ED738939E69DF61AA /* ForecastRouter.swift */, + ); + path = Router; + sourceTree = ""; + }; + 91572A217143C18930A81BA4 /* Router */ = { + isa = PBXGroup; + children = ( + CA3FF49282529BAF3C70C576 /* MainRouter.swift */, + C8666B7D50994A67CBA328E2 /* MainRouterProtocol.swift */, + ); + path = Router; + sourceTree = ""; + }; + 91E95AC7D2146C6AA3B15393 /* Root */ = { + isa = PBXGroup; + children = ( + 437FF6E8C1CA79E355696A06 /* Assembly */, + 0ED154AF9A3E25CE41613337 /* View */, + 20FAC95DD92F177657CB26AF /* Presenter */, + 6935CE3134022C3A82DC52CF /* Interactor */, + 46073904D49EA4889EF6FF16 /* Router */, + ); + path = Root; + sourceTree = ""; + }; + A503FF0422007C1E003C15CA /* Settings */ = { + isa = PBXGroup; + children = ( + A503FF0522007C44003C15CA /* SettingsService.swift */, + A503FF0C22007FCF003C15CA /* SettingsServiceAssembly.swift */, + ); + path = Settings; + sourceTree = ""; + }; + A503FF0722007DB8003C15CA /* Resources */ = { + isa = PBXGroup; + children = ( + A503394B22034D8200659545 /* Cities.json */, + A503FF142201A034003C15CA /* Icons.xcassets */, + ); + path = Resources; + sourceTree = ""; + }; + A503FF172202B512003C15CA /* Models */ = { + isa = PBXGroup; + children = ( + A503FF182202B529003C15CA /* WeatherItem.swift */, + ); + path = Models; + sourceTree = ""; + }; + A503FF1E2202B68F003C15CA /* Cells */ = { + isa = PBXGroup; + children = ( + A503FF1A2202B68B003C15CA /* ForecastItemCellTableViewCell.swift */, + A503FF1B2202B68B003C15CA /* ForecastItemCellTableViewCell.xib */, + ); + path = Cells; + sourceTree = ""; + }; + A503FF1F2202D2BC003C15CA /* Cells */ = { + isa = PBXGroup; + children = ( + A503FF202202D2D6003C15CA /* SettingsCityCell.swift */, + A503FF212202D2D6003C15CA /* SettingsCityCell.xib */, + ); + path = Cells; + sourceTree = ""; + }; + A503FF242202D320003C15CA /* Models */ = { + isa = PBXGroup; + children = ( + A503FF252202D32D003C15CA /* CityItem.swift */, + A503FF272202D47C003C15CA /* CitiesSection.swift */, + ); + path = Models; + sourceTree = ""; + }; + A503FF292202FAD9003C15CA /* Utils */ = { + isa = PBXGroup; + children = ( + A503FF2A2202FB72003C15CA /* Utils.swift */, + ); + path = Utils; + sourceTree = ""; + }; + A5A5E20321FF1A5F00A2059E /* Services */ = { + isa = PBXGroup; + children = ( + A503FF0422007C1E003C15CA /* Settings */, + A5A5E20521FF1AC000A2059E /* Weather */, + A5A5E20421FF1A8400A2059E /* Network */, + ); + path = Services; + sourceTree = ""; + }; + A5A5E20421FF1A8400A2059E /* Network */ = { + isa = PBXGroup; + children = ( + A5A5E20821FF1C2800A2059E /* NetworkService.swift */, + A5A5E20F21FF2F0000A2059E /* NetworkServiceAssembly.swift */, + ); + path = Network; + sourceTree = ""; + }; + A5A5E20521FF1AC000A2059E /* Weather */ = { + isa = PBXGroup; + children = ( + A5A5E20D21FF2A2200A2059E /* ApiResponses.swift */, + A5A5E20621FF1AF300A2059E /* WeatherService.swift */, + A5A5E21121FF302B00A2059E /* WeatherServiceAssembly.swift */, + ); + path = Weather; + sourceTree = ""; + }; + A5A5E20A21FF1E2500A2059E /* Models */ = { + isa = PBXGroup; + children = ( + A5A5E20B21FF241400A2059E /* Weather.swift */, + A503FF0A22007E14003C15CA /* City.swift */, + ); + path = Models; + sourceTree = ""; + }; A5EE266C21FED57C00618447 = { isa = PBXGroup; children = ( + A5A5E20121FF19B300A2059E /* R.generated.swift */, A5EE267721FED57C00618447 /* Weather */, A5EE268C21FED57E00618447 /* WeatherTests */, A5EE267621FED57C00618447 /* Products */, + 1399F4B486CEF7B22A86F0F9 /* Pods */, + 221E45F93BEFC4F7B2FEB1FF /* Frameworks */, ); sourceTree = ""; }; @@ -77,12 +479,16 @@ A5EE267721FED57C00618447 /* Weather */ = { isa = PBXGroup; children = ( + A5EE268421FED57E00618447 /* Info.plist */, A5EE267821FED57C00618447 /* AppDelegate.swift */, - A5EE267A21FED57C00618447 /* ViewController.swift */, - A5EE267C21FED57C00618447 /* Main.storyboard */, + A5A5E1FE21FF033500A2059E /* SwinjectStoryboard+Setup.swift */, A5EE267F21FED57E00618447 /* Assets.xcassets */, A5EE268121FED57E00618447 /* LaunchScreen.storyboard */, - A5EE268421FED57E00618447 /* Info.plist */, + A5A5E20A21FF1E2500A2059E /* Models */, + A757766E748B4349679D37A0 /* Modules */, + A503FF0722007DB8003C15CA /* Resources */, + A5A5E20321FF1A5F00A2059E /* Services */, + A503FF292202FAD9003C15CA /* Utils */, ); path = Weather; sourceTree = ""; @@ -96,6 +502,109 @@ path = WeatherTests; sourceTree = ""; }; + A757766E748B4349679D37A0 /* Modules */ = { + isa = PBXGroup; + children = ( + DB4DEA5EAC60D4F14F8ABAE4 /* Main */, + 91E95AC7D2146C6AA3B15393 /* Root */, + C3A1C21B576621BC97FADA16 /* Forecast */, + 54DD7061E508D533BA3ADD6D /* Settings */, + ); + path = Modules; + sourceTree = ""; + }; + AD5158206C6A9B9401F12022 /* Interactor */ = { + isa = PBXGroup; + children = ( + 95AF42257167128E914BBB8E /* ForecastInteractorProtocol.swift */, + 736ECFB054B23D8BE23F9DB8 /* ForecastInteractor.swift */, + ); + path = Interactor; + sourceTree = ""; + }; + ADC5CF62F49F3488E4220AD3 /* Assembly */ = { + isa = PBXGroup; + children = ( + 2DA97BED45186AD523E7F325 /* MainAssemblyContainer.swift */, + ); + path = Assembly; + sourceTree = ""; + }; + BD3F92DF0959FE0E340E2D68 /* View */ = { + isa = PBXGroup; + children = ( + A503FF1F2202D2BC003C15CA /* Cells */, + A503FF12220168B9003C15CA /* Settings.storyboard */, + C0E6EE7AE29CF927798F39CD /* SettingsViewController.swift */, + E685F1B61CCA8AC4D3CB5B86 /* SettingsViewProtocol.swift */, + ); + path = View; + sourceTree = ""; + }; + C3A1C21B576621BC97FADA16 /* Forecast */ = { + isa = PBXGroup; + children = ( + 239F6A31881E0D237558D41E /* Assembly */, + 685A3CB8C4C26E5187AE988D /* View */, + E7084254A89819003E5EAAE1 /* Presenter */, + AD5158206C6A9B9401F12022 /* Interactor */, + 8FB8BA8098907C6F02D70F64 /* Router */, + ); + path = Forecast; + sourceTree = ""; + }; + CC74F3EA32A265625AE5DCD3 /* Presenter */ = { + isa = PBXGroup; + children = ( + DC7AD71D6D4B648D380B46C9 /* MainModuleInput.swift */, + AD1ADE96DCB61DB76CE378D7 /* MainPresenter.swift */, + A5BA73CC220022E00099641D /* MainPresenterProtocol.swift */, + ); + path = Presenter; + sourceTree = ""; + }; + DB4DEA5EAC60D4F14F8ABAE4 /* Main */ = { + isa = PBXGroup; + children = ( + ADC5CF62F49F3488E4220AD3 /* Assembly */, + EA851B66B24AF8B13EB4B122 /* View */, + CC74F3EA32A265625AE5DCD3 /* Presenter */, + 6EF8EFA4C52A33AECE748448 /* Interactor */, + 91572A217143C18930A81BA4 /* Router */, + ); + path = Main; + sourceTree = ""; + }; + E7084254A89819003E5EAAE1 /* Presenter */ = { + isa = PBXGroup; + children = ( + A503FF172202B512003C15CA /* Models */, + 5E8C2051080907DE3DA8E131 /* ForecastModuleInput.swift */, + D774BE9C0BC9FE431B693B7A /* ForecastPresenter.swift */, + 7FDF753ED86E521A10443113 /* ForecastPresenterProtocol.swift */, + ); + path = Presenter; + sourceTree = ""; + }; + EA851B66B24AF8B13EB4B122 /* View */ = { + isa = PBXGroup; + children = ( + A5EE267C21FED57C00618447 /* Main.storyboard */, + 71725D6D137BDE88FCC05CAE /* MainViewController.swift */, + 578F3D3E332A7D7B35D4434B /* MainViewProtocol.swift */, + ); + path = View; + sourceTree = ""; + }; + F489FA8EBE5D017921C10AC7 /* Interactor */ = { + isa = PBXGroup; + children = ( + 1F6182D635523DBC148322CA /* SettingsInteractorProtocol.swift */, + 4249FEE5F13036A534EF1327 /* SettingsInteractor.swift */, + ); + path = Interactor; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -103,9 +612,13 @@ isa = PBXNativeTarget; buildConfigurationList = A5EE269221FED57E00618447 /* Build configuration list for PBXNativeTarget "Weather" */; buildPhases = ( + 635337CBA82DE715A2D8D618 /* [CP] Check Pods Manifest.lock */, + A5A5E20021FF194000A2059E /* ShellScript */, A5EE267121FED57C00618447 /* Sources */, A5EE267221FED57C00618447 /* Frameworks */, A5EE267321FED57C00618447 /* Resources */, + 8A802A784D011EDFAB8D46EE /* [CP] Embed Pods Frameworks */, + A534B16E22032C5E00077EC5 /* ShellScript */, ); buildRules = ( ); @@ -120,6 +633,7 @@ isa = PBXNativeTarget; buildConfigurationList = A5EE269521FED57E00618447 /* Build configuration list for PBXNativeTarget "WeatherTests" */; buildPhases = ( + C4028A9031F281B2698C463F /* [CP] Check Pods Manifest.lock */, A5EE268521FED57E00618447 /* Sources */, A5EE268621FED57E00618447 /* Frameworks */, A5EE268721FED57E00618447 /* Resources */, @@ -177,9 +691,16 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + A503FF0F220166EE003C15CA /* Root.storyboard in Resources */, + A503FF1122016882003C15CA /* Forecast.storyboard in Resources */, + A503394C22034D8200659545 /* Cities.json in Resources */, + A503FF232202D2D6003C15CA /* SettingsCityCell.xib in Resources */, A5EE268321FED57E00618447 /* LaunchScreen.storyboard in Resources */, A5EE268021FED57E00618447 /* Assets.xcassets in Resources */, + A503FF1D2202B68B003C15CA /* ForecastItemCellTableViewCell.xib in Resources */, A5EE267E21FED57C00618447 /* Main.storyboard in Resources */, + A503FF152201A034003C15CA /* Icons.xcassets in Resources */, + A503FF13220168B9003C15CA /* Settings.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -192,13 +713,190 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 635337CBA82DE715A2D8D618 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Weather-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 8A802A784D011EDFAB8D46EE /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-Weather/Pods-Weather-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", + "${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework", + "${BUILT_PRODUCTS_DIR}/R.swift.Library/Rswift.framework", + "${BUILT_PRODUCTS_DIR}/RxAtomic/RxAtomic.framework", + "${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework", + "${BUILT_PRODUCTS_DIR}/RxDataSources/RxDataSources.framework", + "${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework", + "${BUILT_PRODUCTS_DIR}/Swinject/Swinject.framework", + "${BUILT_PRODUCTS_DIR}/SwinjectStoryboard/SwinjectStoryboard.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Rswift.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxAtomic.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxDataSources.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Swinject.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectStoryboard.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Weather/Pods-Weather-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + A534B16E22032C5E00077EC5 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n"; + }; + A5A5E20021FF194000A2059E /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "$TEMP_DIR/rswift-lastrun", + ); + outputFileListPaths = ( + ); + outputPaths = ( + $SRCROOT/R.generated.swift, + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$PODS_ROOT/R.swift/rswift\" generate \"$SRCROOT/R.generated.swift\"\n"; + }; + C4028A9031F281B2698C463F /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-WeatherTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ A5EE267121FED57C00618447 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - A5EE267B21FED57C00618447 /* ViewController.swift in Sources */, + A503FF0D22007FCF003C15CA /* SettingsServiceAssembly.swift in Sources */, A5EE267921FED57C00618447 /* AppDelegate.swift in Sources */, + A5A5E20C21FF241400A2059E /* Weather.swift in Sources */, + A5A5E20221FF19B300A2059E /* R.generated.swift in Sources */, + 781645B6B09CA7A4A8D35BC2 /* MainAssemblyContainer.swift in Sources */, + A5A5E21221FF302B00A2059E /* WeatherServiceAssembly.swift in Sources */, + BCCB02966EAA32758D46515F /* MainViewProtocol.swift in Sources */, + 2072A2AD181B207EEEC0FC36 /* MainViewController.swift in Sources */, + 2A8938784AB747645D1F0D70 /* MainModuleInput.swift in Sources */, + 006DB9A065C1CA46500142A1 /* MainPresenter.swift in Sources */, + DC8C1911CB3C8F8C000AEA76 /* MainInteractorProtocol.swift in Sources */, + A503FF0622007C44003C15CA /* SettingsService.swift in Sources */, + A5BA73CD220022E00099641D /* MainPresenterProtocol.swift in Sources */, + A5A5E20921FF1C2800A2059E /* NetworkService.swift in Sources */, + A5A5E20721FF1AF300A2059E /* WeatherService.swift in Sources */, + CA4755BDA0CB30CA0B1FE240 /* MainInteractor.swift in Sources */, + A5A5E1FF21FF033500A2059E /* SwinjectStoryboard+Setup.swift in Sources */, + A503FF262202D32D003C15CA /* CityItem.swift in Sources */, + A5A5E21021FF2F0000A2059E /* NetworkServiceAssembly.swift in Sources */, + A5A5E20E21FF2A2200A2059E /* ApiResponses.swift in Sources */, + 3A354C154EDC732288CA1AA6 /* MainRouterProtocol.swift in Sources */, + 85DA8E6C3BC1B5EDD428D079 /* MainRouter.swift in Sources */, + A503FF282202D47C003C15CA /* CitiesSection.swift in Sources */, + A503FF0B22007E14003C15CA /* City.swift in Sources */, + 6E264E7665975DEED2ABC927 /* RootAssemblyContainer.swift in Sources */, + 6467B37621D34B9B7E7B9625 /* RootViewController.swift in Sources */, + 8AE316B93B8254AD75BEC35C /* RootViewProtocol.swift in Sources */, + 30D85DBBB8550DBA9C5939C5 /* RootModuleInput.swift in Sources */, + 63E9FC28AF76275F86571E06 /* RootPresenter.swift in Sources */, + A503FF192202B529003C15CA /* WeatherItem.swift in Sources */, + CF7E8E383F79CDA642CE74C4 /* RootPresenterProtocol.swift in Sources */, + 2DDCA54FF830B71BEF49D713 /* RootInteractorProtocol.swift in Sources */, + E933B27929CECFC35EC20CD8 /* RootInteractor.swift in Sources */, + 0C3D1E6453F92226F941ECFA /* RootRouterProtocol.swift in Sources */, + 2E79E308652298F6F8985E29 /* RootRouter.swift in Sources */, + 499BE77931D09DA7AEB4A781 /* ForecastAssemblyContainer.swift in Sources */, + A9093C67C67A19ABDB8A8470 /* ForecastViewController.swift in Sources */, + A503FF2B2202FB72003C15CA /* Utils.swift in Sources */, + FC39B811B4AD39407D1CEC4E /* ForecastViewProtocol.swift in Sources */, + C3A36ED60E4FB24BAD6E08EB /* ForecastModuleInput.swift in Sources */, + 117ADB173EF54AF05477DAE4 /* ForecastPresenter.swift in Sources */, + B2F8B20DEB11FF97C120826B /* ForecastPresenterProtocol.swift in Sources */, + 58815EB0C695A513E9AF40EF /* ForecastInteractorProtocol.swift in Sources */, + 6A0F8A803FD49AF1560D99DF /* ForecastInteractor.swift in Sources */, + D472251FE5427B2E7189F74C /* ForecastRouterProtocol.swift in Sources */, + B11069CE8301CF288FC9C33A /* ForecastRouter.swift in Sources */, + A503FF222202D2D6003C15CA /* SettingsCityCell.swift in Sources */, + 3B059344697AA9B9A4B860FA /* SettingsAssemblyContainer.swift in Sources */, + 5AC66E084CFAAC1A1AD32335 /* SettingsViewController.swift in Sources */, + 898B3286578E6B18088D3308 /* SettingsViewProtocol.swift in Sources */, + 970195C8D54BD4946B0DF592 /* SettingsModuleInput.swift in Sources */, + A09304581BE7E8B9D0C6698A /* SettingsPresenter.swift in Sources */, + C4D0A5E098AF865E28D0EB6F /* SettingsPresenterProtocol.swift in Sources */, + 88F146F7F1ED02E31C450B57 /* SettingsInteractorProtocol.swift in Sources */, + 793B2B42A883F924AE7C2FC8 /* SettingsInteractor.swift in Sources */, + 9D31BE73A5EA5A23B7BB3BAF /* SettingsRouterProtocol.swift in Sources */, + 09AB02CB8B629AA9704EFB7E /* SettingsRouter.swift in Sources */, + A503FF1C2202B68B003C15CA /* ForecastItemCellTableViewCell.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -358,6 +1056,7 @@ }; A5EE269321FED57E00618447 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 6738335F37486B828CF3305E /* Pods-Weather.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -375,6 +1074,7 @@ }; A5EE269421FED57E00618447 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 69E55FA44A8347B7197A8DAC /* Pods-Weather.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -392,6 +1092,7 @@ }; A5EE269621FED57E00618447 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = C5B0A54CAA8FAA068B0525A1 /* Pods-WeatherTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -412,6 +1113,7 @@ }; A5EE269721FED57E00618447 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = B6395620A61D55DD7CFA9BA3 /* Pods-WeatherTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; diff --git a/Weather.xcworkspace/contents.xcworkspacedata b/Weather.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..71d6a2f --- /dev/null +++ b/Weather.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Weather.xcodeproj/xcuserdata/sergey.xcuserdatad/xcschemes/xcschememanagement.plist b/Weather.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 54% rename from Weather.xcodeproj/xcuserdata/sergey.xcuserdatad/xcschemes/xcschememanagement.plist rename to Weather.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist index d1731a2..18d9810 100644 --- a/Weather.xcodeproj/xcuserdata/sergey.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Weather.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -2,13 +2,7 @@ - SchemeUserState - - Weather.xcscheme_^#shared#^_ - - orderHint - 0 - - + IDEDidComputeMac32BitWarning + diff --git a/Weather/AppDelegate.swift b/Weather/AppDelegate.swift index 9b6aa36..43af9c0 100644 --- a/Weather/AppDelegate.swift +++ b/Weather/AppDelegate.swift @@ -13,34 +13,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - + // swiftlint:disable:next line_length func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. return true } func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - - } - diff --git a/Weather/Base.lproj/Main.storyboard b/Weather/Base.lproj/Main.storyboard deleted file mode 100644 index f1bcf38..0000000 --- a/Weather/Base.lproj/Main.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Weather/Info.plist b/Weather/Info.plist index 16be3b6..06c8dae 100644 --- a/Weather/Info.plist +++ b/Weather/Info.plist @@ -23,7 +23,7 @@ UILaunchStoryboardName LaunchScreen UIMainStoryboardFile - Main + Root UIRequiredDeviceCapabilities armv7 diff --git a/Weather/Models/City.swift b/Weather/Models/City.swift new file mode 100644 index 0000000..2e7f7ea --- /dev/null +++ b/Weather/Models/City.swift @@ -0,0 +1,13 @@ +// +// City.swift +// Weather +// +// Created by Sergey V. Krupov on 29.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +struct City: Decodable { + let id: Int + let name: String + let country: String +} diff --git a/Weather/Models/Weather.swift b/Weather/Models/Weather.swift new file mode 100644 index 0000000..f991867 --- /dev/null +++ b/Weather/Models/Weather.swift @@ -0,0 +1,20 @@ +// +// Weather.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Foundation + +struct Weather { + let temperature: Double + let minTemperature: Double + let maxTemperature: Double + let pressure: Double + let humidity: Double + let date: Date + let icon: String + let description: String +} diff --git a/Weather/Modules/Forecast/Assembly/ForecastAssemblyContainer.swift b/Weather/Modules/Forecast/Assembly/ForecastAssemblyContainer.swift new file mode 100644 index 0000000..13544a0 --- /dev/null +++ b/Weather/Modules/Forecast/Assembly/ForecastAssemblyContainer.swift @@ -0,0 +1,40 @@ +// +// ForecastForecastAssemblyContainer.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Swinject +import SwinjectStoryboard + +final class ForecastAssemblyContainer: Assembly { + + func assemble(container: Container) { + container.register(ForecastInteractorProtocol.self) { resolver in + let interactor = ForecastInteractor() + interactor.weatherService = resolver.resolve(WeatherService.self)! + interactor.settingsService = resolver.resolve(SettingsService.self)! + return interactor + } + + container.register(ForecastRouterProtocol.self) { (_, _: ForecastViewController) in + let router = ForecastRouter() + return router + } + + container.register(ForecastPresenter.self) { (resolver, viewController: ForecastViewController) in + let presenter = ForecastPresenter() + presenter.view = viewController + presenter.interactor = resolver.resolve(ForecastInteractorProtocol.self) + presenter.router = resolver.resolve(ForecastRouterProtocol.self, argument: viewController) + return presenter + } + + container.storyboardInitCompleted(ForecastViewController.self) { resolver, viewController in + let presenter = resolver.resolve(ForecastPresenter.self, argument: viewController)! + viewController.setPresenter(presenter) + } + } +} diff --git a/Weather/Modules/Forecast/Interactor/ForecastInteractor.swift b/Weather/Modules/Forecast/Interactor/ForecastInteractor.swift new file mode 100644 index 0000000..85fd56b --- /dev/null +++ b/Weather/Modules/Forecast/Interactor/ForecastInteractor.swift @@ -0,0 +1,33 @@ +// +// ForecastForecastInteractor.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class ForecastInteractor: ForecastInteractorProtocol { + + // MARK: - Dependencies + var weatherService: WeatherService! + var settingsService: SettingsService! + + // MARK: - ForecastInteractorProtocol + lazy var forecast: Driver<[Weather]> = { + let refreshObservable = refreshSubject.startWith(()) + return Observable.combineLatest(refreshObservable, settingsService.currentCity) { $1 } + .flatMapLatest { [service = self.weatherService!] city in service.obtainForecast(for: city) } + .catchError { _ in .empty() } + .asDriver(onErrorDriveWith: .empty()) + } () + + func refresh() { + refreshSubject.onNext(()) + } + + // MARK: - Private + private let refreshSubject = PublishSubject() +} diff --git a/Weather/Modules/Forecast/Interactor/ForecastInteractorProtocol.swift b/Weather/Modules/Forecast/Interactor/ForecastInteractorProtocol.swift new file mode 100644 index 0000000..a3ef609 --- /dev/null +++ b/Weather/Modules/Forecast/Interactor/ForecastInteractorProtocol.swift @@ -0,0 +1,17 @@ +// +// ForecastForecastInteractorProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol ForecastInteractorProtocol: class { + + var forecast: Driver<[Weather]> { get } + + func refresh() +} diff --git a/Weather/Modules/Forecast/Presenter/ForecastModuleInput.swift b/Weather/Modules/Forecast/Presenter/ForecastModuleInput.swift new file mode 100644 index 0000000..8bb390a --- /dev/null +++ b/Weather/Modules/Forecast/Presenter/ForecastModuleInput.swift @@ -0,0 +1,11 @@ +// +// ForecastForecastModuleInput.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol ForecastModuleInput: class { + +} diff --git a/Weather/Modules/Forecast/Presenter/ForecastPresenter.swift b/Weather/Modules/Forecast/Presenter/ForecastPresenter.swift new file mode 100644 index 0000000..18ccc2e --- /dev/null +++ b/Weather/Modules/Forecast/Presenter/ForecastPresenter.swift @@ -0,0 +1,59 @@ +// +// ForecastForecastPresenter.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class ForecastPresenter { + + // MARK: - Properties + var interactor: ForecastInteractorProtocol! + var router: ForecastRouterProtocol! + weak var view: ForecastViewProtocol? + + // MARK: - Public + + // MARK: - Private + private let disposeBag = DisposeBag() +} + +// MARK: - ForecastPesenterProtocol +extension ForecastPresenter: ForecastPresenterProtocol { + + func setupBindings(_ view: ForecastViewProtocol) { + interactor.forecast + .map { weathers -> [WeatherItem] in + weathers.map { + WeatherItem( + image: UIImage(named: $0.icon) ?? R.image.undefined(), + description: $0.description, + temperature: Utils.temperatureFormatter.string(from: $0.temperature as NSNumber), + date: Utils.dateFormatter.string(from: $0.date) + ) + } + } + .drive(view.items) + .disposed(by: disposeBag) + + view.refresh + .bind(to: Binder(self) { this, _ in + this.interactor.refresh() + }) + .disposed(by: disposeBag) + + interactor.forecast + .drive(Binder(self) { this, _ in + this.view?.endRefreshing() + }) + .disposed(by: disposeBag) + } +} + +// MARK: - ForecastModuleInput +extension ForecastPresenter: ForecastModuleInput { +} diff --git a/Weather/Modules/Forecast/Presenter/ForecastPresenterProtocol.swift b/Weather/Modules/Forecast/Presenter/ForecastPresenterProtocol.swift new file mode 100644 index 0000000..2d793ef --- /dev/null +++ b/Weather/Modules/Forecast/Presenter/ForecastPresenterProtocol.swift @@ -0,0 +1,12 @@ +// +// ForecastForecastPresenterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol ForecastPresenterProtocol { + + func setupBindings(_ view: ForecastViewProtocol) +} diff --git a/Weather/Modules/Forecast/Presenter/Models/WeatherItem.swift b/Weather/Modules/Forecast/Presenter/Models/WeatherItem.swift new file mode 100644 index 0000000..6b90a17 --- /dev/null +++ b/Weather/Modules/Forecast/Presenter/Models/WeatherItem.swift @@ -0,0 +1,16 @@ +// +// WeatherItem.swift +// Weather +// +// Created by Sergey V. Krupov on 31.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import UIKit + +struct WeatherItem { + let image: UIImage? + let description: String? + let temperature: String? + let date: String? +} diff --git a/Weather/Modules/Forecast/Router/ForecastRouter.swift b/Weather/Modules/Forecast/Router/ForecastRouter.swift new file mode 100644 index 0000000..f2898c4 --- /dev/null +++ b/Weather/Modules/Forecast/Router/ForecastRouter.swift @@ -0,0 +1,11 @@ +// +// ForecastForecastRouter.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +final class ForecastRouter: ForecastRouterProtocol { + +} diff --git a/Weather/Modules/Forecast/Router/ForecastRouterProtocol.swift b/Weather/Modules/Forecast/Router/ForecastRouterProtocol.swift new file mode 100644 index 0000000..13b91c9 --- /dev/null +++ b/Weather/Modules/Forecast/Router/ForecastRouterProtocol.swift @@ -0,0 +1,13 @@ +// +// ForecastForecastRouterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Foundation + +protocol ForecastRouterProtocol: class { + +} diff --git a/Weather/Modules/Forecast/View/Cells/ForecastItemCellTableViewCell.swift b/Weather/Modules/Forecast/View/Cells/ForecastItemCellTableViewCell.swift new file mode 100644 index 0000000..665221a --- /dev/null +++ b/Weather/Modules/Forecast/View/Cells/ForecastItemCellTableViewCell.swift @@ -0,0 +1,23 @@ +// +// ForecastItemCellTableViewCell.swift +// Weather +// +// Created by Sergey V. Krupov on 31.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import UIKit + +final class ForecastItemCellTableViewCell: UITableViewCell { + + @IBOutlet private weak var dateLabel: UILabel! + @IBOutlet private weak var temperatureLabel: UILabel! + @IBOutlet private weak var weatherImageView: UIImageView! + + // MARK: - Public + func setup(_ item: WeatherItem) { + dateLabel.text = item.date + temperatureLabel.text = item.temperature + weatherImageView.image = item.image + } +} diff --git a/Weather/Modules/Forecast/View/Cells/ForecastItemCellTableViewCell.xib b/Weather/Modules/Forecast/View/Cells/ForecastItemCellTableViewCell.xib new file mode 100644 index 0000000..4e6932d --- /dev/null +++ b/Weather/Modules/Forecast/View/Cells/ForecastItemCellTableViewCell.xib @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Modules/Forecast/View/Forecast.storyboard b/Weather/Modules/Forecast/View/Forecast.storyboard new file mode 100644 index 0000000..a632a2c --- /dev/null +++ b/Weather/Modules/Forecast/View/Forecast.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Modules/Forecast/View/ForecastViewController.swift b/Weather/Modules/Forecast/View/ForecastViewController.swift new file mode 100644 index 0000000..0abf771 --- /dev/null +++ b/Weather/Modules/Forecast/View/ForecastViewController.swift @@ -0,0 +1,64 @@ +// +// ForecastForecastViewController.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxDataSources +import RxSwift +import UIKit + +final class ForecastViewController: UIViewController { + + // MARK: - Outlets + @IBOutlet private weak var tableView: UITableView! + + // MARK: - Public + func setPresenter(_ presenter: ForecastPresenterProtocol) { + self.presenter = presenter + } + + // MARK: - Life cycle + override func viewDidLoad() { + super.viewDidLoad() + + tableView.rowHeight = 45 + tableView.refreshControl = refreshControl + tableView.register(R.nib.forecastItemCellTableViewCell) + itemsRelay.asObservable() + .bind(to: tableView.rx.items(cellIdentifier: R.reuseIdentifier.forecastItemCellTableViewCell.identifier)) { _, model, cell in + let weatherCell = cell as! ForecastItemCellTableViewCell + weatherCell.setup(model) + } + .disposed(by: disposeBag) + + presenter?.setupBindings(self) + } + + // MARK: - Private + private var presenter: ForecastPresenterProtocol? + private let itemsRelay = PublishRelay<[WeatherItem]>() + private let disposeBag = DisposeBag() + private let refreshControl = UIRefreshControl(frame: .zero) +} + +// MARK: - ForecastViewInput +extension ForecastViewController: ForecastViewProtocol { + + var items: Binder<[WeatherItem]> { + return Binder(self) { this, items in + this.itemsRelay.accept(items) + } + } + + var refresh: ControlEvent { + return refreshControl.rx.controlEvent(.valueChanged) + } + + func endRefreshing() { + refreshControl.endRefreshing() + } +} diff --git a/Weather/Modules/Forecast/View/ForecastViewProtocol.swift b/Weather/Modules/Forecast/View/ForecastViewProtocol.swift new file mode 100644 index 0000000..9ee1581 --- /dev/null +++ b/Weather/Modules/Forecast/View/ForecastViewProtocol.swift @@ -0,0 +1,21 @@ +// +// ForecastForecastViewProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol ForecastViewProtocol: class { + + // MARK: - Input + var items: Binder<[WeatherItem]> { get } + + // MARK: - Output + var refresh: ControlEvent { get } + + func endRefreshing() +} diff --git a/Weather/Modules/Main/Assembly/MainAssemblyContainer.swift b/Weather/Modules/Main/Assembly/MainAssemblyContainer.swift new file mode 100644 index 0000000..ba5d72f --- /dev/null +++ b/Weather/Modules/Main/Assembly/MainAssemblyContainer.swift @@ -0,0 +1,40 @@ +// +// MainMainAssemblyContainer.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Swinject +import SwinjectStoryboard + +final class MainAssemblyContainer: Assembly { + + func assemble(container: Container) { + container.register(MainInteractorProtocol.self) { resolver in + let interactor = MainInteractor() + interactor.weatherService = resolver.resolve(WeatherService.self)! + interactor.settingsService = resolver.resolve(SettingsService.self)! + return interactor + } + + container.register(MainRouterProtocol.self) { (_, _: MainViewController) in + let router = MainRouter() + return router + } + + container.register(MainPresenter.self) { (resolver, viewController: MainViewController) in + let presenter = MainPresenter() + presenter.view = viewController + presenter.interactor = resolver.resolve(MainInteractorProtocol.self) + presenter.router = resolver.resolve(MainRouterProtocol.self, argument: viewController) + return presenter + } + + container.storyboardInitCompleted(MainViewController.self) { resolver, viewController in + let presenter = resolver.resolve(MainPresenter.self, argument: viewController)! + viewController.setPresenter(presenter) + } + } +} diff --git a/Weather/Modules/Main/Interactor/MainInteractor.swift b/Weather/Modules/Main/Interactor/MainInteractor.swift new file mode 100644 index 0000000..4fce68d --- /dev/null +++ b/Weather/Modules/Main/Interactor/MainInteractor.swift @@ -0,0 +1,40 @@ +// +// MainMainInteractor.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class MainInteractor: MainInteractorProtocol { + + // MARK: - Dependencies + var weatherService: WeatherService! + var settingsService: SettingsService! + + // MARK: - MainInteractorProtocol + lazy var weather: Driver = { + let refreshObservable = refreshSubject.startWith(()) + return Observable.combineLatest(refreshObservable, settingsService.currentCity) { $1 } + .flatMapLatest { [service = self.weatherService!] city in service.obtainWeather(for: city) } + .catchError { _ in .empty() } + .asDriver(onErrorDriveWith: .empty()) + } () + + lazy var city: Driver = { + return settingsService.currentCity + .catchError { _ in .empty() } + .asDriver(onErrorDriveWith: .empty()) + .map { $0.name } + } () + + func refresh() { + refreshSubject.onNext(()) + } + + // MARK: - Private + private let refreshSubject = PublishSubject() +} diff --git a/Weather/Modules/Main/Interactor/MainInteractorProtocol.swift b/Weather/Modules/Main/Interactor/MainInteractorProtocol.swift new file mode 100644 index 0000000..b896227 --- /dev/null +++ b/Weather/Modules/Main/Interactor/MainInteractorProtocol.swift @@ -0,0 +1,18 @@ +// +// MainMainInteractorProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol MainInteractorProtocol: class { + + var weather: Driver { get } + var city: Driver { get } + + func refresh() +} diff --git a/Weather/Modules/Main/Presenter/MainModuleInput.swift b/Weather/Modules/Main/Presenter/MainModuleInput.swift new file mode 100644 index 0000000..43715c1 --- /dev/null +++ b/Weather/Modules/Main/Presenter/MainModuleInput.swift @@ -0,0 +1,11 @@ +// +// MainMainModuleInput.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol MainModuleInput: class { + +} diff --git a/Weather/Modules/Main/Presenter/MainPresenter.swift b/Weather/Modules/Main/Presenter/MainPresenter.swift new file mode 100644 index 0000000..3026667 --- /dev/null +++ b/Weather/Modules/Main/Presenter/MainPresenter.swift @@ -0,0 +1,68 @@ +// +// MainMainPresenter.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift +import UIKit + +final class MainPresenter { + + // MARK: - Properties + var interactor: MainInteractorProtocol! + var router: MainRouterProtocol! + weak var view: MainViewProtocol? + + // MARK: - Private + let disposeBag = DisposeBag() +} + +// MARK: - MainPesenterProtocol +extension MainPresenter: MainPresenterProtocol { + + func setupBindings(_ view: MainViewProtocol) { + + interactor.city + .startWith(nil) + .drive(view.city) + .disposed(by: disposeBag) + + interactor.weather + .map { Utils.temperatureFormatter.string(from: $0.temperature as NSNumber) } + .startWith("--") + .drive(view.temperature) + .disposed(by: disposeBag) + + interactor.weather + .map { UIImage(named: $0.icon) ?? R.image.undefined() } + .startWith(R.image.undefined()) + .drive(view.weatherImage) + .disposed(by: disposeBag) + + interactor.weather + .map { $0.description as String? } + .startWith(nil) + .drive(view.weatherDescription) + .disposed(by: disposeBag) + + view.refresh + .bind(to: Binder(self) { this, _ in + this.interactor.refresh() + }) + .disposed(by: disposeBag) + + interactor.weather + .drive(Binder(self) { this, _ in + this.view?.endRefreshing() + }) + .disposed(by: disposeBag) + } +} + +// MARK: - MainModuleInput +extension MainPresenter: MainModuleInput { +} diff --git a/Weather/Modules/Main/Presenter/MainPresenterProtocol.swift b/Weather/Modules/Main/Presenter/MainPresenterProtocol.swift new file mode 100644 index 0000000..8eb18fe --- /dev/null +++ b/Weather/Modules/Main/Presenter/MainPresenterProtocol.swift @@ -0,0 +1,12 @@ +// +// MainPresenterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 29.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +protocol MainPresenterProtocol { + + func setupBindings(_ view: MainViewProtocol) +} diff --git a/Weather/Modules/Main/Router/MainRouter.swift b/Weather/Modules/Main/Router/MainRouter.swift new file mode 100644 index 0000000..bb34cb7 --- /dev/null +++ b/Weather/Modules/Main/Router/MainRouter.swift @@ -0,0 +1,11 @@ +// +// MainMainRouter.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +final class MainRouter: MainRouterProtocol { + +} diff --git a/Weather/Modules/Main/Router/MainRouterProtocol.swift b/Weather/Modules/Main/Router/MainRouterProtocol.swift new file mode 100644 index 0000000..7008b9f --- /dev/null +++ b/Weather/Modules/Main/Router/MainRouterProtocol.swift @@ -0,0 +1,13 @@ +// +// MainMainRouterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Foundation + +protocol MainRouterProtocol: class { + +} diff --git a/Weather/Modules/Main/View/Base.lproj/Main.storyboard b/Weather/Modules/Main/View/Base.lproj/Main.storyboard new file mode 100644 index 0000000..17e8561 --- /dev/null +++ b/Weather/Modules/Main/View/Base.lproj/Main.storyboard @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Modules/Main/View/MainViewController.swift b/Weather/Modules/Main/View/MainViewController.swift new file mode 100644 index 0000000..9ec12dd --- /dev/null +++ b/Weather/Modules/Main/View/MainViewController.swift @@ -0,0 +1,65 @@ +// +// MainMainViewController.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import UIKit + +final class MainViewController: UIViewController { + + // MARK: - Outlets + @IBOutlet private weak var currentTemperatureLabel: UILabel! + @IBOutlet private weak var weatherConditionImageView: UIImageView! + @IBOutlet private weak var weatherConditionLabel: UILabel! + @IBOutlet private weak var cityLabel: UILabel! + @IBOutlet private weak var scrollView: UIScrollView! + + // MARK: - Public + func setPresenter(_ presenter: MainPresenterProtocol) { + self.presenter = presenter + } + + // MARK: - Life cycle + override func viewDidLoad() { + super.viewDidLoad() + scrollView.addSubview(refreshControl) + + presenter?.setupBindings(self) + } + + // MARK: - Private + private var presenter: MainPresenterProtocol? + private let refreshControl = UIRefreshControl(frame: .zero) +} + +// MARK: - MainViewInput +extension MainViewController: MainViewProtocol { + + var city: Binder { + return cityLabel.rx.text + } + + var temperature: Binder { + return currentTemperatureLabel.rx.text + } + + var weatherImage: Binder { + return weatherConditionImageView.rx.image + } + + var weatherDescription: Binder { + return weatherConditionLabel.rx.text + } + + var refresh: ControlEvent { + return refreshControl.rx.controlEvent(.valueChanged) + } + + func endRefreshing() { + refreshControl.endRefreshing() + } +} diff --git a/Weather/Modules/Main/View/MainViewProtocol.swift b/Weather/Modules/Main/View/MainViewProtocol.swift new file mode 100644 index 0000000..769e159 --- /dev/null +++ b/Weather/Modules/Main/View/MainViewProtocol.swift @@ -0,0 +1,23 @@ +// +// MainMainViewProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 28/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa + +protocol MainViewProtocol: class { + + // MARK: - Input + var city: Binder { get } + var temperature: Binder { get } + var weatherImage: Binder { get } + var weatherDescription: Binder { get } + + func endRefreshing() + + // MARK: - Output + var refresh: ControlEvent { get } +} diff --git a/Weather/Modules/Root/Assembly/RootAssemblyContainer.swift b/Weather/Modules/Root/Assembly/RootAssemblyContainer.swift new file mode 100644 index 0000000..3a15cb3 --- /dev/null +++ b/Weather/Modules/Root/Assembly/RootAssemblyContainer.swift @@ -0,0 +1,42 @@ +// +// RootRootAssemblyContainer.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Swinject +import SwinjectStoryboard + +final class RootAssemblyContainer: Assembly { + + func assemble(container: Container) { + container.register(RootInteractorProtocol.self) { _ in + let interactor = RootInteractor() + return interactor + } + + container.register(RootRouterProtocol.self) { (_, _: RootViewController) in + let router = RootRouter() + return router + } + + container.register(RootPresenter.self) { (resolver, viewController: RootViewController) in + let presenter = RootPresenter() + presenter.view = viewController + presenter.interactor = resolver.resolve(RootInteractorProtocol.self) + presenter.router = resolver.resolve(RootRouterProtocol.self, argument: viewController) + return presenter + } + + container.storyboardInitCompleted(RootViewController.self) { resolver, viewController in + let presenter = resolver.resolve(RootPresenter.self, argument: viewController)! + let main = R.storyboard.main.mainViewController()! + let forecast = R.storyboard.forecast.forecastViewController()! + let settings = R.storyboard.settings.settingsViewController()! + viewController.pages = [main, forecast, settings] + viewController.setPresenter(presenter) + } + } +} diff --git a/Weather/Modules/Root/Interactor/RootInteractor.swift b/Weather/Modules/Root/Interactor/RootInteractor.swift new file mode 100644 index 0000000..4c8dac6 --- /dev/null +++ b/Weather/Modules/Root/Interactor/RootInteractor.swift @@ -0,0 +1,17 @@ +// +// RootRootInteractor.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class RootInteractor: RootInteractorProtocol { + + // MARK: - Dependencies + + // MARK: - RootInteractorProtocol +} diff --git a/Weather/Modules/Root/Interactor/RootInteractorProtocol.swift b/Weather/Modules/Root/Interactor/RootInteractorProtocol.swift new file mode 100644 index 0000000..2222ad0 --- /dev/null +++ b/Weather/Modules/Root/Interactor/RootInteractorProtocol.swift @@ -0,0 +1,14 @@ +// +// RootRootInteractorProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol RootInteractorProtocol: class { + +} diff --git a/Weather/Modules/Root/Presenter/RootModuleInput.swift b/Weather/Modules/Root/Presenter/RootModuleInput.swift new file mode 100644 index 0000000..f8f7712 --- /dev/null +++ b/Weather/Modules/Root/Presenter/RootModuleInput.swift @@ -0,0 +1,11 @@ +// +// RootRootModuleInput.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol RootModuleInput: class { + +} diff --git a/Weather/Modules/Root/Presenter/RootPresenter.swift b/Weather/Modules/Root/Presenter/RootPresenter.swift new file mode 100644 index 0000000..89f3f7c --- /dev/null +++ b/Weather/Modules/Root/Presenter/RootPresenter.swift @@ -0,0 +1,32 @@ +// +// RootRootPresenter.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class RootPresenter { + + // MARK: - Properties + var interactor: RootInteractorProtocol! + var router: RootRouterProtocol! + weak var view: RootViewProtocol? + + // MARK: - Private + let disposeBag = DisposeBag() +} + +// MARK: - RootPesenterProtocol +extension RootPresenter: RootPresenterProtocol { + + func setupBindings(_ view: RootViewProtocol) { + } +} + +// MARK: - RootModuleInput +extension RootPresenter: RootModuleInput { +} diff --git a/Weather/Modules/Root/Presenter/RootPresenterProtocol.swift b/Weather/Modules/Root/Presenter/RootPresenterProtocol.swift new file mode 100644 index 0000000..46dd341 --- /dev/null +++ b/Weather/Modules/Root/Presenter/RootPresenterProtocol.swift @@ -0,0 +1,12 @@ +// +// RootRootPresenterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol RootPresenterProtocol { + + func setupBindings(_ view: RootViewProtocol) +} diff --git a/Weather/Modules/Root/Router/RootRouter.swift b/Weather/Modules/Root/Router/RootRouter.swift new file mode 100644 index 0000000..03584e0 --- /dev/null +++ b/Weather/Modules/Root/Router/RootRouter.swift @@ -0,0 +1,11 @@ +// +// RootRootRouter.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +final class RootRouter: RootRouterProtocol { + +} diff --git a/Weather/Modules/Root/Router/RootRouterProtocol.swift b/Weather/Modules/Root/Router/RootRouterProtocol.swift new file mode 100644 index 0000000..8be45b3 --- /dev/null +++ b/Weather/Modules/Root/Router/RootRouterProtocol.swift @@ -0,0 +1,13 @@ +// +// RootRootRouterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Foundation + +protocol RootRouterProtocol: class { + +} diff --git a/Weather/Modules/Root/View/Root.storyboard b/Weather/Modules/Root/View/Root.storyboard new file mode 100644 index 0000000..e780c92 --- /dev/null +++ b/Weather/Modules/Root/View/Root.storyboard @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Modules/Root/View/RootViewController.swift b/Weather/Modules/Root/View/RootViewController.swift new file mode 100644 index 0000000..63111e9 --- /dev/null +++ b/Weather/Modules/Root/View/RootViewController.swift @@ -0,0 +1,78 @@ +// +// RootRootViewController.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift +import UIKit + +final class RootViewController: UIPageViewController { + + // MARK: - Dependencies + var pages: [UIViewController]! + + // MARK: - Outlets + + // MARK: - Public + func setPresenter(_ presenter: RootPresenterProtocol) { + self.presenter = presenter + } + + // MARK: - Life cycle + override func viewDidLoad() { + super.viewDidLoad() + if let firstPage = pages.first { + setViewControllers([firstPage], direction: .forward, animated: false) + } + dataSource = self + presenter?.setupBindings(self) + } + + // MARK: - Private + var presenter: RootPresenterProtocol? +} + +// MARK: - RootViewInput +extension RootViewController: RootViewProtocol { + + func setupInitialState() { + } +} + +extension RootViewController: UIPageViewControllerDataSource { + + func pageViewController(_ pageViewController: UIPageViewController, + viewControllerBefore viewController: UIViewController) -> UIViewController? { + + guard let index = pages.firstIndex(of: viewController) else { + return nil + } + let indexBefore = (index + pages.count - 1) % pages.count + return pages[indexBefore] + } + + func pageViewController(_ pageViewController: UIPageViewController, + viewControllerAfter viewController: UIViewController) -> UIViewController? { + + guard let index = pages.firstIndex(of: viewController) else { + return nil + } + let indexAfter = (index + 1) % pages.count + return pages[indexAfter] + } + + func presentationCount(for pageViewController: UIPageViewController) -> Int { + return pages.count + } + + func presentationIndex(for pageViewController: UIPageViewController) -> Int { + guard let viewController = pageViewController.viewControllers?.first else { + return 0 + } + return pages.firstIndex(of: viewController) ?? 0 + } +} diff --git a/Weather/Modules/Root/View/RootViewProtocol.swift b/Weather/Modules/Root/View/RootViewProtocol.swift new file mode 100644 index 0000000..6c2020b --- /dev/null +++ b/Weather/Modules/Root/View/RootViewProtocol.swift @@ -0,0 +1,18 @@ +// +// RootRootViewProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol RootViewProtocol: class { + + // MARK: - Input + func setupInitialState() + + // MARK: - Output +} diff --git a/Weather/Modules/Settings/Assembly/SettingsAssemblyContainer.swift b/Weather/Modules/Settings/Assembly/SettingsAssemblyContainer.swift new file mode 100644 index 0000000..40904ec --- /dev/null +++ b/Weather/Modules/Settings/Assembly/SettingsAssemblyContainer.swift @@ -0,0 +1,39 @@ +// +// SettingsSettingsAssemblyContainer.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Swinject +import SwinjectStoryboard + +final class SettingsAssemblyContainer: Assembly { + + func assemble(container: Container) { + container.register(SettingsInteractorProtocol.self) { resolver in + let interactor = SettingsInteractor() + interactor.settingsService = resolver.resolve(SettingsService.self)! + return interactor + } + + container.register(SettingsRouterProtocol.self) { (_, _: SettingsViewController) in + let router = SettingsRouter() + return router + } + + container.register(SettingsPresenter.self) { (resolver, viewController: SettingsViewController) in + let presenter = SettingsPresenter() + presenter.view = viewController + presenter.interactor = resolver.resolve(SettingsInteractorProtocol.self) + presenter.router = resolver.resolve(SettingsRouterProtocol.self, argument: viewController) + return presenter + } + + container.storyboardInitCompleted(SettingsViewController.self) { resolver, viewController in + let presenter = resolver.resolve(SettingsPresenter.self, argument: viewController)! + viewController.setPresenter(presenter) + } + } +} diff --git a/Weather/Modules/Settings/Interactor/SettingsInteractor.swift b/Weather/Modules/Settings/Interactor/SettingsInteractor.swift new file mode 100644 index 0000000..e9f9f83 --- /dev/null +++ b/Weather/Modules/Settings/Interactor/SettingsInteractor.swift @@ -0,0 +1,33 @@ +// +// SettingsSettingsInteractor.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class SettingsInteractor: SettingsInteractorProtocol { + + // MARK: - Dependencies + var settingsService: SettingsService! + + // MARK: - SettingsInteractorProtocol + lazy var cities: Driver<[City]> = { + settingsService.allCities + .asDriver(onErrorDriveWith: .empty()) + } () + + lazy var selectedCity: Driver = { + settingsService.currentCity + .asDriver(onErrorDriveWith: .empty()) + } () + + var selectedCityIDSink: Binder { + return Binder(self) { this, identifier in + this.settingsService.setCurrentCityID(identifier) + } + } +} diff --git a/Weather/Modules/Settings/Interactor/SettingsInteractorProtocol.swift b/Weather/Modules/Settings/Interactor/SettingsInteractorProtocol.swift new file mode 100644 index 0000000..9f9386d --- /dev/null +++ b/Weather/Modules/Settings/Interactor/SettingsInteractorProtocol.swift @@ -0,0 +1,20 @@ +// +// SettingsSettingsInteractorProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol SettingsInteractorProtocol: class { + + // MARK: - Output + var cities: Driver<[City]> { get } + var selectedCity: Driver { get } + + // MARK: - Input + var selectedCityIDSink: Binder { get } +} diff --git a/Weather/Modules/Settings/Presenter/Models/CitiesSection.swift b/Weather/Modules/Settings/Presenter/Models/CitiesSection.swift new file mode 100644 index 0000000..9d709b5 --- /dev/null +++ b/Weather/Modules/Settings/Presenter/Models/CitiesSection.swift @@ -0,0 +1,22 @@ +// +// CitiesSection.swift +// Weather +// +// Created by Sergey V. Krupov on 31.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import RxDataSources + +struct CitiesSection { + let header: String + let items: [CityItem] +} + +extension CitiesSection: SectionModelType { + + init(original: CitiesSection, items: [CityItem]) { + self.header = original.header + self.items = items + } +} diff --git a/Weather/Modules/Settings/Presenter/Models/CityItem.swift b/Weather/Modules/Settings/Presenter/Models/CityItem.swift new file mode 100644 index 0000000..5e559de --- /dev/null +++ b/Weather/Modules/Settings/Presenter/Models/CityItem.swift @@ -0,0 +1,13 @@ +// +// CityItem.swift +// Weather +// +// Created by Sergey V. Krupov on 31.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +struct CityItem { + let name: String + let isCurrent: Bool + let id: Int +} diff --git a/Weather/Modules/Settings/Presenter/SettingsModuleInput.swift b/Weather/Modules/Settings/Presenter/SettingsModuleInput.swift new file mode 100644 index 0000000..0aee125 --- /dev/null +++ b/Weather/Modules/Settings/Presenter/SettingsModuleInput.swift @@ -0,0 +1,11 @@ +// +// SettingsSettingsModuleInput.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol SettingsModuleInput: class { + +} diff --git a/Weather/Modules/Settings/Presenter/SettingsPresenter.swift b/Weather/Modules/Settings/Presenter/SettingsPresenter.swift new file mode 100644 index 0000000..35f026c --- /dev/null +++ b/Weather/Modules/Settings/Presenter/SettingsPresenter.swift @@ -0,0 +1,49 @@ +// +// SettingsSettingsPresenter.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +final class SettingsPresenter { + + // MARK: - Properties + var interactor: SettingsInteractorProtocol! + var router: SettingsRouterProtocol! + weak var view: SettingsViewProtocol? + + // MARK: - Private + private let disposeBag = DisposeBag() +} + +// MARK: - SettingsPesenterProtocol +extension SettingsPresenter: SettingsPresenterProtocol { + + func setupBindings(_ view: SettingsViewProtocol) { + Driver.combineLatest(interactor.cities, interactor.selectedCity) { cities, currentCity -> [CitiesSection] in + let items = cities.map { + CityItem( + name: $0.name, + isCurrent: $0.id == currentCity.id, + id: $0.id + ) + } + return [CitiesSection(header: "Город", items: items)] + } + .drive(view.sections) + .disposed(by: disposeBag) + + view.citySelected + .map { $0.id } + .bind(to: interactor.selectedCityIDSink) + .disposed(by: disposeBag) + } +} + +// MARK: - SettingsModuleInput +extension SettingsPresenter: SettingsModuleInput { +} diff --git a/Weather/Modules/Settings/Presenter/SettingsPresenterProtocol.swift b/Weather/Modules/Settings/Presenter/SettingsPresenterProtocol.swift new file mode 100644 index 0000000..9305d60 --- /dev/null +++ b/Weather/Modules/Settings/Presenter/SettingsPresenterProtocol.swift @@ -0,0 +1,12 @@ +// +// SettingsSettingsPresenterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +protocol SettingsPresenterProtocol { + + func setupBindings(_ view: SettingsViewProtocol) +} diff --git a/Weather/Modules/Settings/Router/SettingsRouter.swift b/Weather/Modules/Settings/Router/SettingsRouter.swift new file mode 100644 index 0000000..f25a5e1 --- /dev/null +++ b/Weather/Modules/Settings/Router/SettingsRouter.swift @@ -0,0 +1,11 @@ +// +// SettingsSettingsRouter.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +final class SettingsRouter: SettingsRouterProtocol { + +} diff --git a/Weather/Modules/Settings/Router/SettingsRouterProtocol.swift b/Weather/Modules/Settings/Router/SettingsRouterProtocol.swift new file mode 100644 index 0000000..2112f9c --- /dev/null +++ b/Weather/Modules/Settings/Router/SettingsRouterProtocol.swift @@ -0,0 +1,13 @@ +// +// SettingsSettingsRouterProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import Foundation + +protocol SettingsRouterProtocol: class { + +} diff --git a/Weather/Modules/Settings/View/Cells/SettingsCityCell.swift b/Weather/Modules/Settings/View/Cells/SettingsCityCell.swift new file mode 100644 index 0000000..e47e635 --- /dev/null +++ b/Weather/Modules/Settings/View/Cells/SettingsCityCell.swift @@ -0,0 +1,17 @@ +// +// SettingsCityCell.swift +// Weather +// +// Created by Sergey V. Krupov on 31.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import UIKit + +final class SettingsCityCell: UITableViewCell { + + func setup(_ item: CityItem) { + textLabel?.text = item.name + accessoryType = item.isCurrent ? .checkmark : .none + } +} diff --git a/Weather/Modules/Settings/View/Cells/SettingsCityCell.xib b/Weather/Modules/Settings/View/Cells/SettingsCityCell.xib new file mode 100644 index 0000000..2c6d66f --- /dev/null +++ b/Weather/Modules/Settings/View/Cells/SettingsCityCell.xib @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Modules/Settings/View/Settings.storyboard b/Weather/Modules/Settings/View/Settings.storyboard new file mode 100644 index 0000000..4c81005 --- /dev/null +++ b/Weather/Modules/Settings/View/Settings.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Weather/Modules/Settings/View/SettingsViewController.swift b/Weather/Modules/Settings/View/SettingsViewController.swift new file mode 100644 index 0000000..d0cf6f1 --- /dev/null +++ b/Weather/Modules/Settings/View/SettingsViewController.swift @@ -0,0 +1,64 @@ +// +// SettingsSettingsViewController.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxDataSources +import RxSwift +import UIKit + +final class SettingsViewController: UIViewController { + + // MARK: - Outlets + @IBOutlet private weak var tableView: UITableView! + + // MARK: - Public + func setPresenter(_ presenter: SettingsPresenterProtocol) { + self.presenter = presenter + } + + // MARK: - Life cycle + override func viewDidLoad() { + super.viewDidLoad() + + tableView.rowHeight = 45 + tableView.register(R.nib.settingsCityCell) + + let dataSource = RxTableViewSectionedReloadDataSource(configureCell: { dataSource, tableView, indexPath, item in + let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.settingsCityCell, for: indexPath)! + cell.setup(item) + return cell + }, titleForHeaderInSection: { dataSource, section in + return dataSource.sectionModels[section].header + }) + + sectionsRelay.asObservable() + .bind(to: tableView.rx.items(dataSource: dataSource)) + .disposed(by: disposeBag) + + presenter?.setupBindings(self) + } + + // MARK: - Private + private var presenter: SettingsPresenterProtocol? + private let sectionsRelay = PublishRelay<[CitiesSection]>() + private let disposeBag = DisposeBag() +} + +// MARK: - SettingsViewInput +extension SettingsViewController: SettingsViewProtocol { + + var sections: Binder<[CitiesSection]> { + return Binder(self) { this, sections in + this.sectionsRelay.accept(sections) + } + } + + var citySelected: ControlEvent { + return tableView.rx.modelSelected(CityItem.self) + } +} diff --git a/Weather/Modules/Settings/View/SettingsViewProtocol.swift b/Weather/Modules/Settings/View/SettingsViewProtocol.swift new file mode 100644 index 0000000..619a503 --- /dev/null +++ b/Weather/Modules/Settings/View/SettingsViewProtocol.swift @@ -0,0 +1,19 @@ +// +// SettingsSettingsViewProtocol.swift +// Weather +// +// Created by Sergey V. Krupov on 30/01/2019. +// Copyright © 2019 Home. All rights reserved. +// + +import RxCocoa +import RxSwift + +protocol SettingsViewProtocol: class { + + // MARK: - Input + var sections: Binder<[CitiesSection]> { get } + + // MARK: - Output + var citySelected: ControlEvent { get } +} diff --git a/Weather/Resources/Cities.json b/Weather/Resources/Cities.json new file mode 100644 index 0000000..8bcd935 --- /dev/null +++ b/Weather/Resources/Cities.json @@ -0,0 +1,38 @@ +[ + { + "id": 511196, + "name": "Perm", + "country": "RU", + "coord": { + "lon": 56.285519, + "lat": 58.01741 + } + }, + { + "id": 536203, + "name": "Sankt-Peterburg", + "country": "RU", + "coord": { + "lon": 30.25, + "lat": 59.916668 + } + }, + { + "id": 524901, + "name": "Moscow", + "country": "RU", + "coord": { + "lon": 37.615555, + "lat": 55.75222 + } + }, + { + "id": 491422, + "name": "Sochi", + "country": "RU", + "coord": { + "lon": 39.730278, + "lat": 43.599998 + } + } +] \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/01d.imageset/01d.png b/Weather/Resources/Icons.xcassets/01d.imageset/01d.png new file mode 100644 index 0000000..4dddcca Binary files /dev/null and b/Weather/Resources/Icons.xcassets/01d.imageset/01d.png differ diff --git a/Weather/Resources/Icons.xcassets/01d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/01d.imageset/Contents.json new file mode 100644 index 0000000..e74fc60 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/01d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "01d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/01n.imageset/01n.png b/Weather/Resources/Icons.xcassets/01n.imageset/01n.png new file mode 100644 index 0000000..b73dbfb Binary files /dev/null and b/Weather/Resources/Icons.xcassets/01n.imageset/01n.png differ diff --git a/Weather/Resources/Icons.xcassets/01n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/01n.imageset/Contents.json new file mode 100644 index 0000000..b2d72cd --- /dev/null +++ b/Weather/Resources/Icons.xcassets/01n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "01n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/02d.imageset/02d.png b/Weather/Resources/Icons.xcassets/02d.imageset/02d.png new file mode 100644 index 0000000..fb041e0 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/02d.imageset/02d.png differ diff --git a/Weather/Resources/Icons.xcassets/02d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/02d.imageset/Contents.json new file mode 100644 index 0000000..5ef9aa5 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/02d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "02d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/02n.imageset/02n.png b/Weather/Resources/Icons.xcassets/02n.imageset/02n.png new file mode 100644 index 0000000..c6de81f Binary files /dev/null and b/Weather/Resources/Icons.xcassets/02n.imageset/02n.png differ diff --git a/Weather/Resources/Icons.xcassets/02n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/02n.imageset/Contents.json new file mode 100644 index 0000000..d81686c --- /dev/null +++ b/Weather/Resources/Icons.xcassets/02n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "02n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/03d.imageset/03d.png b/Weather/Resources/Icons.xcassets/03d.imageset/03d.png new file mode 100644 index 0000000..b47ceff Binary files /dev/null and b/Weather/Resources/Icons.xcassets/03d.imageset/03d.png differ diff --git a/Weather/Resources/Icons.xcassets/03d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/03d.imageset/Contents.json new file mode 100644 index 0000000..5c3f292 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/03d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "03d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/03n.imageset/03n.png b/Weather/Resources/Icons.xcassets/03n.imageset/03n.png new file mode 100644 index 0000000..d775df3 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/03n.imageset/03n.png differ diff --git a/Weather/Resources/Icons.xcassets/03n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/03n.imageset/Contents.json new file mode 100644 index 0000000..0d57b1b --- /dev/null +++ b/Weather/Resources/Icons.xcassets/03n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "03n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/04d.imageset/04d.png b/Weather/Resources/Icons.xcassets/04d.imageset/04d.png new file mode 100644 index 0000000..9fcb8d1 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/04d.imageset/04d.png differ diff --git a/Weather/Resources/Icons.xcassets/04d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/04d.imageset/Contents.json new file mode 100644 index 0000000..7aa495b --- /dev/null +++ b/Weather/Resources/Icons.xcassets/04d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "04d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/04n.imageset/04n.png b/Weather/Resources/Icons.xcassets/04n.imageset/04n.png new file mode 100644 index 0000000..9fcb8d1 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/04n.imageset/04n.png differ diff --git a/Weather/Resources/Icons.xcassets/04n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/04n.imageset/Contents.json new file mode 100644 index 0000000..aa785f1 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/04n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "04n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/09d.imageset/09d.png b/Weather/Resources/Icons.xcassets/09d.imageset/09d.png new file mode 100644 index 0000000..6e506e9 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/09d.imageset/09d.png differ diff --git a/Weather/Resources/Icons.xcassets/09d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/09d.imageset/Contents.json new file mode 100644 index 0000000..c570396 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/09d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "09d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/09n.imageset/09n.png b/Weather/Resources/Icons.xcassets/09n.imageset/09n.png new file mode 100644 index 0000000..6e506e9 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/09n.imageset/09n.png differ diff --git a/Weather/Resources/Icons.xcassets/09n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/09n.imageset/Contents.json new file mode 100644 index 0000000..83247b9 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/09n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "09n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/10d.imageset/10d.png b/Weather/Resources/Icons.xcassets/10d.imageset/10d.png new file mode 100644 index 0000000..8ed2809 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/10d.imageset/10d.png differ diff --git a/Weather/Resources/Icons.xcassets/10d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/10d.imageset/Contents.json new file mode 100644 index 0000000..b77eb00 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/10d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "10d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/10n.imageset/10n.png b/Weather/Resources/Icons.xcassets/10n.imageset/10n.png new file mode 100644 index 0000000..8bc4ae2 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/10n.imageset/10n.png differ diff --git a/Weather/Resources/Icons.xcassets/10n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/10n.imageset/Contents.json new file mode 100644 index 0000000..41522e6 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/10n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "10n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/11d.imageset/11d.png b/Weather/Resources/Icons.xcassets/11d.imageset/11d.png new file mode 100644 index 0000000..87d12a7 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/11d.imageset/11d.png differ diff --git a/Weather/Resources/Icons.xcassets/11d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/11d.imageset/Contents.json new file mode 100644 index 0000000..1d885dc --- /dev/null +++ b/Weather/Resources/Icons.xcassets/11d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "11d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/11n.imageset/11n.png b/Weather/Resources/Icons.xcassets/11n.imageset/11n.png new file mode 100644 index 0000000..87d12a7 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/11n.imageset/11n.png differ diff --git a/Weather/Resources/Icons.xcassets/11n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/11n.imageset/Contents.json new file mode 100644 index 0000000..44b0589 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/11n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "11n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/13d.imageset/13d.png b/Weather/Resources/Icons.xcassets/13d.imageset/13d.png new file mode 100644 index 0000000..a5ef4b0 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/13d.imageset/13d.png differ diff --git a/Weather/Resources/Icons.xcassets/13d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/13d.imageset/Contents.json new file mode 100644 index 0000000..ed23bd6 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/13d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "13d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/13n.imageset/13n.png b/Weather/Resources/Icons.xcassets/13n.imageset/13n.png new file mode 100644 index 0000000..a5ef4b0 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/13n.imageset/13n.png differ diff --git a/Weather/Resources/Icons.xcassets/13n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/13n.imageset/Contents.json new file mode 100644 index 0000000..b8a862f --- /dev/null +++ b/Weather/Resources/Icons.xcassets/13n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "13n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/50d.imageset/50d.png b/Weather/Resources/Icons.xcassets/50d.imageset/50d.png new file mode 100644 index 0000000..f5cfebb Binary files /dev/null and b/Weather/Resources/Icons.xcassets/50d.imageset/50d.png differ diff --git a/Weather/Resources/Icons.xcassets/50d.imageset/Contents.json b/Weather/Resources/Icons.xcassets/50d.imageset/Contents.json new file mode 100644 index 0000000..7fca196 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/50d.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "50d.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/50n.imageset/50n.png b/Weather/Resources/Icons.xcassets/50n.imageset/50n.png new file mode 100644 index 0000000..a487066 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/50n.imageset/50n.png differ diff --git a/Weather/Resources/Icons.xcassets/50n.imageset/Contents.json b/Weather/Resources/Icons.xcassets/50n.imageset/Contents.json new file mode 100644 index 0000000..e8aff70 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/50n.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "50n.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/Contents.json b/Weather/Resources/Icons.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/undefined.imageset/Contents.json b/Weather/Resources/Icons.xcassets/undefined.imageset/Contents.json new file mode 100644 index 0000000..7739846 --- /dev/null +++ b/Weather/Resources/Icons.xcassets/undefined.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "undefined.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Weather/Resources/Icons.xcassets/undefined.imageset/undefined.png b/Weather/Resources/Icons.xcassets/undefined.imageset/undefined.png new file mode 100644 index 0000000..434ca10 Binary files /dev/null and b/Weather/Resources/Icons.xcassets/undefined.imageset/undefined.png differ diff --git a/Weather/Services/Network/NetworkService.swift b/Weather/Services/Network/NetworkService.swift new file mode 100644 index 0000000..6da62c0 --- /dev/null +++ b/Weather/Services/Network/NetworkService.swift @@ -0,0 +1,56 @@ +// +// NetworkService.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Alamofire +import RxCocoa +import RxSwift + +protocol NetworkService { + + func request(_ url: URL) -> Single + + func jsonRequest(url: URL, parameters: [String: Any]) -> Single +} + +final class NetworkComponent: NetworkService { + + enum Error: Swift.Error { + case undefinedNetworkError + } + + func request(_ url: URL) -> Single { + let request = URLRequest(url: url) + return URLSession.shared.rx.data(request: request).asSingle() + } + + func jsonRequest(url: URL, parameters: [String: Any]) -> Single { + return Single.create { singleAction -> Disposable in + let request = Alamofire.request(url, method: .get, parameters: parameters) + + request.responseData { response in + guard let data = response.data else { + let error: Swift.Error = response.error ?? Error.undefinedNetworkError + singleAction(.error(error)) + return + } + + do { + let payload = try JSONDecoder().decode(T.self, from: data) + singleAction(.success(payload)) + } catch { + assertionFailure() + singleAction(.error(error)) + } + } + + return Disposables.create { + request.cancel() + } + } + } +} diff --git a/Weather/Services/Network/NetworkServiceAssembly.swift b/Weather/Services/Network/NetworkServiceAssembly.swift new file mode 100644 index 0000000..2df9ddf --- /dev/null +++ b/Weather/Services/Network/NetworkServiceAssembly.swift @@ -0,0 +1,19 @@ +// +// NetworkServiceAssembly.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Swinject + +final class NetworkServiceAssembly: Assembly { + + func assemble(container: Container) { + container.register(NetworkService.self) { _ in + return NetworkComponent() + } + .inObjectScope(.container) + } +} diff --git a/Weather/Services/Settings/SettingsService.swift b/Weather/Services/Settings/SettingsService.swift new file mode 100644 index 0000000..062a607 --- /dev/null +++ b/Weather/Services/Settings/SettingsService.swift @@ -0,0 +1,72 @@ +// +// SettingsService.swift +// Weather +// +// Created by Sergey V. Krupov on 29.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Foundation +import RxSwift + +protocol SettingsService { + + var baseURL: URL { get } + + var secret: String { get } + + var allCities: Observable<[City]> { get } + + var currentCity: Observable { get } + + func setCurrentCityID(_ id: Int) +} + +final class SettingsComponent: SettingsService { + + let baseURL: URL = URL(string: "https://api.openweathermap.org")! + + let secret = "77abbce3f579492502ecb93387c50f1b" + + let selectedСityID = ReplaySubject.create(bufferSize: 1) + + init() { + let identifier = UserDefaults.standard.object(forKey: currentCityIDKey) as? Int + selectedСityID.onNext(identifier) + } + + var allCities: Observable<[City]> = { + return Observable.deferred { () -> Observable<[City]> in + do { + let data = try Data(contentsOf: R.file.citiesJson()!) + let cities = try JSONDecoder().decode(Array.self, from: data) + return .just(cities) + } catch { + return .error(error) + } + } + .share(replay: 1, scope: .forever) + } () + + var currentCity: Observable { + return Observable.combineLatest(allCities.asObservable(), selectedСityID.asObserver()) + .flatMap { tuple -> Maybe in + let (cities, identifier) = tuple + + guard let city = cities.first(where: { $0.id == identifier }) else { + return .just(cities.first!) + } + + return .just(city) + } + } + + func setCurrentCityID(_ id: Int) { + UserDefaults.standard.set(id, forKey: currentCityIDKey) + selectedСityID.onNext(id) + } + + // MARK: - Private + private let disposeBag = DisposeBag() + private let currentCityIDKey = "current.city.identifier" +} diff --git a/Weather/Services/Settings/SettingsServiceAssembly.swift b/Weather/Services/Settings/SettingsServiceAssembly.swift new file mode 100644 index 0000000..125d7e4 --- /dev/null +++ b/Weather/Services/Settings/SettingsServiceAssembly.swift @@ -0,0 +1,19 @@ +// +// SettingsServiceAssembly.swift +// Weather +// +// Created by Sergey V. Krupov on 29.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Swinject + +final class SettingsServiceAssembly: Assembly { + + func assemble(container: Container) { + container.register(SettingsService.self) { _ in + return SettingsComponent() + } + .inObjectScope(.container) + } +} diff --git a/Weather/Services/Weather/ApiResponses.swift b/Weather/Services/Weather/ApiResponses.swift new file mode 100644 index 0000000..7d6caef --- /dev/null +++ b/Weather/Services/Weather/ApiResponses.swift @@ -0,0 +1,82 @@ +// +// ApiResponse.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Foundation + +enum API { + + struct Weather: Decodable { + + enum RootSectionKeys: String, CodingKey { + case main + case weather + case date = "dt" + } + + enum MainSectionKeys: String, CodingKey { + case temperature = "temp" + case minTemperature = "temp_min" + case maxTemperature = "temp_max" + case pressure + case humidity + } + + enum WeatherSectionKeys: String, CodingKey { + case description + case icon + } + + init(from decoder: Decoder) throws { + let rootContainer = try decoder.container(keyedBy: RootSectionKeys.self) + date = Date(timeIntervalSince1970: try rootContainer.decode(TimeInterval.self, forKey: .date)) + + let mainContiner = try rootContainer.nestedContainer(keyedBy: MainSectionKeys.self, forKey: .main) + temperature = try mainContiner.decode(Double.self, forKey: .temperature) + minTemperature = try mainContiner.decode(Double.self, forKey: .minTemperature) + maxTemperature = try mainContiner.decode(Double.self, forKey: .maxTemperature) + pressure = try mainContiner.decode(Double.self, forKey: .pressure) + humidity = try mainContiner.decode(Double.self, forKey: .humidity) + + var list = try rootContainer.nestedUnkeyedContainer(forKey: .weather) + assert(!list.isAtEnd) + let weatherContainer = try list.nestedContainer(keyedBy: WeatherSectionKeys.self) + description = try weatherContainer.decode(String.self, forKey: .description) + icon = try weatherContainer.decode(String.self, forKey: .icon) + } + + let temperature: Double + let minTemperature: Double + let maxTemperature: Double + let pressure: Double + let humidity: Double + let date: Date + let description: String + let icon: String + } + + struct Forecast: Decodable { + + enum RootSectionKeys: String, CodingKey { + case list + } + + init(from decoder: Decoder) throws { + let rootContainer = try decoder.container(keyedBy: RootSectionKeys.self) + var list = try rootContainer.nestedUnkeyedContainer(forKey: .list) + + var items = Array() + while !list.isAtEnd { + let item = try list.decode(Weather.self) + items.append(item) + } + self.items = items + } + + let items: [Weather] + } +} diff --git a/Weather/Services/Weather/WeatherService.swift b/Weather/Services/Weather/WeatherService.swift new file mode 100644 index 0000000..fae8219 --- /dev/null +++ b/Weather/Services/Weather/WeatherService.swift @@ -0,0 +1,67 @@ +// +// WeatherService.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import RxSwift + +protocol WeatherService { + + func obtainWeather(for city: City) -> Single + + func obtainForecast(for city: City) -> Single<[Weather]> +} + +final class WeatherComponent: WeatherService { + + // MARK: - Dependencies + var networkService: NetworkService! + var settingsService: SettingsService! + + // Текущая погода + func obtainWeather(for city: City) -> Single { + let url = settingsService.baseURL.appendingPathComponent("data/2.5/weather") + let parameters: [String: Any] = [ + "id": city.id, + "appid": settingsService.secret, + "units": "metric" + ] + + return networkService.jsonRequest(url: url, parameters: parameters) + .map { (response: API.Weather) -> Weather in + return self.mapResponse(response) + } + } + + // Прогноз на несколько дней + func obtainForecast(for city: City) -> Single<[Weather]> { + let url = settingsService.baseURL.appendingPathComponent("data/2.5/forecast") + let parameters: [String: Any] = [ + "id": city.id, + "appid": settingsService.secret, + "units": "metric" + ] + + return networkService.jsonRequest(url: url, parameters: parameters) + .map { (response: API.Forecast) -> [Weather] in + return response.items.map(self.mapResponse) + } + } + + // MARK: - Private + private func mapResponse(_ weather: API.Weather) -> Weather { + return Weather( + temperature: weather.temperature, + minTemperature: weather.minTemperature, + maxTemperature: weather.maxTemperature, + pressure: weather.pressure, + humidity: weather.humidity, + date: weather.date, + icon: weather.icon, + description: weather.description + ) + } +} diff --git a/Weather/Services/Weather/WeatherServiceAssembly.swift b/Weather/Services/Weather/WeatherServiceAssembly.swift new file mode 100644 index 0000000..802ba49 --- /dev/null +++ b/Weather/Services/Weather/WeatherServiceAssembly.swift @@ -0,0 +1,21 @@ +// +// WeatherServiceAssembly.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Swinject + +final class WeatherServiceAssembly: Assembly { + + func assemble(container: Container) { + container.register(WeatherService.self) { resolver in + let component = WeatherComponent() + component.networkService = resolver.resolve(NetworkService.self)! + component.settingsService = resolver.resolve(SettingsService.self)! + return component + } + } +} diff --git a/Weather/SwinjectStoryboard+Setup.swift b/Weather/SwinjectStoryboard+Setup.swift new file mode 100644 index 0000000..9ba8c7f --- /dev/null +++ b/Weather/SwinjectStoryboard+Setup.swift @@ -0,0 +1,24 @@ +// +// SwinjectStoryboard+Setup.swift +// Weather +// +// Created by Sergey V. Krupov on 28.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Swinject +import SwinjectStoryboard + +extension SwinjectStoryboard { + + @objc + class func setup() { + RootAssemblyContainer().assemble(container: defaultContainer) + MainAssemblyContainer().assemble(container: defaultContainer) + ForecastAssemblyContainer().assemble(container: defaultContainer) + SettingsAssemblyContainer().assemble(container: defaultContainer) + WeatherServiceAssembly().assemble(container: defaultContainer) + NetworkServiceAssembly().assemble(container: defaultContainer) + SettingsServiceAssembly().assemble(container: defaultContainer) + } +} diff --git a/Weather/Utils/Utils.swift b/Weather/Utils/Utils.swift new file mode 100644 index 0000000..a5e5089 --- /dev/null +++ b/Weather/Utils/Utils.swift @@ -0,0 +1,27 @@ +// +// Utils.swift +// Weather +// +// Created by Sergey V. Krupov on 31.01.2019. +// Copyright © 2019 Sergey V. Krupov. All rights reserved. +// + +import Foundation + +enum Utils { + + static let temperatureFormatter: NumberFormatter = { + let formatter = NumberFormatter() + formatter.maximumFractionDigits = 1 + formatter.minimumFractionDigits = 1 + formatter.minimumIntegerDigits = 1 + return formatter + } () + + static let dateFormatter: DateFormatter = { + let dateFormatter = DateFormatter() + dateFormatter.locale = Locale(identifier: "ru_RU") + dateFormatter.dateFormat = "HH:mm, dd MMMM" + return dateFormatter + } () +} diff --git a/Weather/ViewController.swift b/Weather/ViewController.swift deleted file mode 100644 index ebc0c38..0000000 --- a/Weather/ViewController.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// ViewController.swift -// Weather -// -// Created by Sergey V. Krupov on 28.01.2019. -// Copyright © 2019 Sergey V. Krupov. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - -} - diff --git a/viperSwift/viperSwift.rambaspec b/viperSwift/viperSwift.rambaspec new file mode 100644 index 0000000..812a482 --- /dev/null +++ b/viperSwift/viperSwift.rambaspec @@ -0,0 +1,29 @@ +# Template information section +name: "RxSwift" +summary: "ViperModule with Swinject & RxSwift" +author: "Sergey V. Krupov" +version: "0.1.2" +license: "MIT" + +# The declarations for code files + +code_files: +# Assembly +- {name: Assembly/AssemblyContainer.swift, path: Code/Assembly/assemblycontainer.swift.liquid} + +# View layer +- {name: View/ViewController.swift, path: Code/View/viewcontroller.swift.liquid} +- {name: View/ViewProtocol.swift, path: Code/View/view_protocol.swift.liquid} + +# Presenter layer +- {name: Presenter/ModuleInput.swift, path: Code/Presenter/module_input.swift.liquid} +- {name: Presenter/Presenter.swift, path: Code/Presenter/presenter.swift.liquid} +- {name: Presenter/PresenterProtocol.swift, path: Code/Presenter/presenter_protocol.swift.liquid} + +# Interactor layer +- {name: Interactor/InteractorProtocol.swift, path: Code/Interactor/interactor_protocol.swift.liquid} +- {name: Interactor/Interactor.swift, path: Code/Interactor/interactor.swift.liquid} + +# Router layer +- {name: Router/RouterProtocol.swift, path: Code/Router/router_protocol.swift.liquid} +- {name: Router/Router.swift, path: Code/Router/router.swift.liquid}