-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
120 changed files
with
6,051 additions
and
260 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run tests | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: macOS-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Select Xcode 11 | ||
run: sudo xcode-select -switch /Applications/Xcode_11.7.app | ||
|
||
- name: Install bundle | ||
run: bundle install | ||
|
||
- name: Build and Test | ||
run: bundle exec fastlane ios tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata/ | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
Pods/ | ||
|
||
# fastlane | ||
# | ||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the | ||
# screenshots whenever they are needed. | ||
# For more information about the recommended setup visit: | ||
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md | ||
|
||
**/fastlane/report.xml | ||
**/fastlane/Preview.html | ||
**/fastlane/screenshots | ||
**/fastlane/test_output | ||
|
||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
disabled_rules: | ||
- type_name | ||
- identifier_name | ||
|
||
excluded: | ||
- Pods |
Large diffs are not rendered by default.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
Chuck Norris Facts.xcodeproj/xcshareddata/xcschemes/Chuck Norris Facts.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1220" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1EE0713825314AF500F6BF6D" | ||
BuildableName = "Chuck Norris Facts.app" | ||
BlueprintName = "Chuck Norris Facts" | ||
ReferencedContainer = "container:Chuck Norris Facts.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1EE0714E25314AF600F6BF6D" | ||
BuildableName = "Chuck Norris FactsTests.xctest" | ||
BlueprintName = "Chuck Norris FactsTests" | ||
ReferencedContainer = "container:Chuck Norris Facts.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1EE0715925314AF600F6BF6D" | ||
BuildableName = "Chuck Norris FactsUITests.xctest" | ||
BlueprintName = "Chuck Norris FactsUITests" | ||
ReferencedContainer = "container:Chuck Norris Facts.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1EE0713825314AF500F6BF6D" | ||
BuildableName = "Chuck Norris Facts.app" | ||
BlueprintName = "Chuck Norris Facts" | ||
ReferencedContainer = "container:Chuck Norris Facts.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1EE0713825314AF500F6BF6D" | ||
BuildableName = "Chuck Norris Facts.app" | ||
BlueprintName = "Chuck Norris Facts" | ||
ReferencedContainer = "container:Chuck Norris Facts.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// AppCoordinator.swift | ||
// Chuck Norris Facts | ||
// | ||
// Created by Djorkaeff Alexandre Vilela Pereira on 10/10/20. | ||
// Copyright © 2020 Djorkaeff Alexandre Vilela Pereira. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import RxSwift | ||
|
||
class AppCoordinator: BaseCoordinator<Void> { | ||
|
||
private let window: UIWindow | ||
|
||
init(window: UIWindow) { | ||
self.window = window | ||
} | ||
|
||
override func start() -> Observable<Void> { | ||
let factsListCoordinator = FactsListCoordinator(window: window) | ||
return coordinate(to: factsListCoordinator) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// AppDelegate.swift | ||
// Chuck Norris Facts | ||
// | ||
// Created by Djorkaeff Alexandre Vilela Pereira on 10/9/20. | ||
// Copyright © 2020 Djorkaeff Alexandre Vilela Pereira. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import RealmSwift | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
func application( | ||
_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | ||
) -> Bool { | ||
|
||
processArguments() | ||
|
||
return true | ||
} | ||
|
||
private func processArguments() { | ||
if LaunchArgument.check(.uiTest) { | ||
UIView.setAnimationsEnabled(false) | ||
} | ||
|
||
if LaunchArgument.check(.resetData) { | ||
let realm = try? Realm() | ||
try? realm?.write { | ||
realm?.deleteAll() | ||
} | ||
} | ||
|
||
if LaunchArgument.check(.mockStorage) { | ||
let entities = [ | ||
SearchEntity(searchTerm: "games"), | ||
SearchEntity(searchTerm: "fashion"), | ||
FactCategoryEntity(category: FactCategory(text: "games")), | ||
FactCategoryEntity(category: FactCategory(text: "fashion")) | ||
] | ||
|
||
let realm = try? Realm() | ||
try? realm?.write { | ||
realm?.add(entities, update: .modified) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// SceneDelegate.swift | ||
// Chuck Norris Facts | ||
// | ||
// Created by Djorkaeff Alexandre Vilela Pereira on 10/9/20. | ||
// Copyright © 2020 Djorkaeff Alexandre Vilela Pereira. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import RxSwift | ||
|
||
class SceneDelegate: UIResponder, UIWindowSceneDelegate { | ||
|
||
var window: UIWindow? | ||
private var appCoordinator: AppCoordinator? | ||
private let disposeBag = DisposeBag() | ||
|
||
func scene( | ||
_ scene: UIScene, | ||
willConnectTo session: UISceneSession, | ||
options connectionOptions: UIScene.ConnectionOptions | ||
) { | ||
guard let scene = (scene as? UIWindowScene) else { return } | ||
|
||
let window = UIWindow(windowScene: scene) | ||
self.window = window | ||
|
||
appCoordinator = AppCoordinator(window: window) | ||
appCoordinator?.start() | ||
.subscribe() | ||
.disposed(by: disposeBag) | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
Chuck Norris Facts/App/Scenes/Facts/FactsList/Error/FactsListError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// FactsListError.swift | ||
// Chuck Norris Facts | ||
// | ||
// Created by Djorkaeff Alexandre Vilela Pereira on 10/28/20. | ||
// Copyright © 2020 Djorkaeff Alexandre Vilela Pereira. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
enum FactsListError { | ||
// Error related to syncCategories request | ||
case syncCategories(Error) | ||
// Error related to searchFacts request | ||
case searchFacts(Error) | ||
} | ||
|
||
extension FactsListError { | ||
|
||
// APIError related to the error. | ||
var error: APIError { | ||
switch self { | ||
case .syncCategories(let error): | ||
return (error as? APIError) ?? APIError.unknown(error) | ||
case .searchFacts(let error): | ||
return (error as? APIError) ?? APIError.unknown(error) | ||
} | ||
} | ||
|
||
// A code to check where the error come. | ||
var code: Int { | ||
switch self { | ||
case .syncCategories: | ||
return 0 | ||
case .searchFacts: | ||
return 1 | ||
} | ||
} | ||
|
||
// A message that will be shown to user. | ||
var message: String { | ||
switch self { | ||
case .syncCategories: | ||
return L10n.Errors.cantSyncCategories | ||
case .searchFacts: | ||
return L10n.Errors.cantSearchFacts | ||
} | ||
} | ||
} | ||
|
||
extension FactsListError: Equatable { | ||
static func == (lhs: FactsListError, rhs: FactsListError) -> Bool { | ||
lhs.code == rhs.code | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Chuck Norris Facts/App/Scenes/Facts/FactsList/Error/FactsListErrorViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// FactsListErrorViewModel.swift | ||
// Chuck Norris Facts | ||
// | ||
// Created by Djorkaeff Alexandre Vilela Pereira on 11/2/20. | ||
// Copyright © 2020 Djorkaeff Alexandre Vilela Pereira. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct FactsListErrorViewModel { | ||
|
||
let error: APIError | ||
let title: String | ||
let message: String | ||
var shouldRetry: Bool = false | ||
|
||
init(factsListError: FactsListError) { | ||
self.error = factsListError.error | ||
|
||
self.title = factsListError.message | ||
self.message = error.message | ||
|
||
switch factsListError { | ||
case .syncCategories: | ||
self.shouldRetry = error.code != APIError.noConnection.code | ||
default: | ||
break | ||
} | ||
} | ||
} |
Oops, something went wrong.