Skip to content

Commit

Permalink
Release 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djorkaeffalexandre authored Nov 3, 2020
2 parents eceabca + b8b2abb commit 3d18a98
Show file tree
Hide file tree
Showing 120 changed files with 6,051 additions and 260 deletions.
Binary file added .github/images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
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
38 changes: 38 additions & 0 deletions .gitignore
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
6 changes: 6 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disabled_rules:
- type_name
- identifier_name

excluded:
- Pods
910 changes: 873 additions & 37 deletions Chuck Norris Facts.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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>
10 changes: 10 additions & 0 deletions Chuck Norris Facts.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Chuck Norris Facts.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
24 changes: 24 additions & 0 deletions Chuck Norris Facts/App/AppCoordinator.swift
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)
}
}
51 changes: 51 additions & 0 deletions Chuck Norris Facts/App/AppDelegate.swift
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)
}
}
}
}
34 changes: 34 additions & 0 deletions Chuck Norris Facts/App/SceneDelegate.swift
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)
}

}
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
}
}
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
}
}
}
Loading

0 comments on commit 3d18a98

Please sign in to comment.