Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
swli-nltd committed Mar 21, 2022
0 parents commit ce4f7ee
Show file tree
Hide file tree
Showing 99 changed files with 22,885 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

### Projects ###
*.xcodeproj
*.xcworkspace

### Tuist derived files ###
graph.dot
Derived/

### Tuist managed dependencies ###
Tuist/Dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "pokemonBackground.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 App/CatchUI/Resources/Assets.xcassets/Ball.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Ball.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions App/CatchUI/Resources/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "PokemonPlaceholder.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions App/CatchUI/Sources/Scenes/Catch Scene/CatchActions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CatchActions.swift
// CatchUI
//
// Created by Ronan on 01/07/21.
// Copyright © 2021 Sonomos. All rights reserved.
//

import Common

public protocol CatchActions {
func catchPokemon()
}

extension Actions: CatchActions {
public func catchPokemon() {
dataProvider?.catchPokemon()
}
}
25 changes: 25 additions & 0 deletions App/CatchUI/Sources/Scenes/Catch Scene/CatchDataProvider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// CatchDataProvider.swift
// CatchUI
//
// Created by Ronan on 01/07/21.
// Copyright © 2021 Sonomos. All rights reserved.
//

import Foundation
import Common

public protocol CatchDataProvider {
func pokemon() -> ScreenPokemon?
func newSpecies() -> Bool
}

extension DataProvider: CatchDataProvider {
public func pokemon() -> ScreenPokemon? {
guard let foundPokemon = appData.pokemon else { return nil }
return ScreenPokemon(name: foundPokemon.name,
weight: foundPokemon.weight,
height: foundPokemon.height,
iconPath: foundPokemon.sprites.frontDefault)
}
}
67 changes: 67 additions & 0 deletions App/CatchUI/Sources/Scenes/Catch Scene/CatchPresenter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// CatchPresenter.swift
// CatchUI
//
// Created by Ronan on 01/07/21.
// Copyright © 2021 Sonomos. All rights reserved.
//

import Common

protocol CatchView: AnyObject {
func update()
func showLeaveOrCatchAlert()
func showLeaveItAlert()
func showNotFoundAlert()
func showError(message: String)
}

public protocol CatchPresenting: AnyObject {
func pokemon() -> ScreenPokemon?
func catchPokemonAction()
}

public class CatchPresenter: CatchPresenting, Updatable {

// MARK: Properties

private weak var view: CatchView?
private var actions: CatchActions
private var dataProvider: CatchDataProvider

// MARK: Typealias

typealias Actions = CatchActions
typealias DataProvider = CatchDataProvider
typealias View = CatchView

required init(view: CatchView, actions: CatchActions, dataProvider: CatchDataProvider) {
self.view = view
self.actions = actions
self.dataProvider = dataProvider
}

public func update() {
guard let view = view else { return }
view.update()

if pokemon() == nil {
view.showNotFoundAlert()
return
}

dataProvider.newSpecies() ? view.showLeaveOrCatchAlert() : view.showLeaveItAlert()
}

public func showError(message: String) {
view?.showError(message: message)
}

public func pokemon() -> ScreenPokemon? {
return dataProvider.pokemon()
}

public func catchPokemonAction() {
actions.catchPokemon()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Catch View Controller-->
<scene sceneID="Sf8-0k-iHG">
<objects>
<viewController storyboardIdentifier="CatchViewController" id="6JY-wC-gpp" customClass="CatchViewController" customModule="CatchUI" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ywu-gT-m6t">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Background" translatesAutoresizingMaskIntoConstraints="NO" id="sf1-cg-uKF">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YzX-Yf-1Ql">
<rect key="frame" x="127.5" y="501" width="120" height="120"/>
<accessibility key="accessibilityConfiguration" identifier="Catch"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="OAM-Xw-BXP"/>
<constraint firstAttribute="height" constant="120" id="mYr-ZQ-7iZ"/>
</constraints>
<state key="normal" image="Ball"/>
<connections>
<action selector="ballAction" destination="6JY-wC-gpp" eventType="touchUpInside" id="rKr-SQ-uLW"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="ODG-Sk-nvn"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="sf1-cg-uKF" firstAttribute="trailing" secondItem="ODG-Sk-nvn" secondAttribute="trailing" id="1dX-3i-wrw"/>
<constraint firstItem="YzX-Yf-1Ql" firstAttribute="centerX" secondItem="Ywu-gT-m6t" secondAttribute="centerX" id="9Cl-ly-hds"/>
<constraint firstItem="ODG-Sk-nvn" firstAttribute="bottom" secondItem="YzX-Yf-1Ql" secondAttribute="bottom" constant="46" id="Lmf-vs-wPf"/>
<constraint firstItem="sf1-cg-uKF" firstAttribute="top" secondItem="Ywu-gT-m6t" secondAttribute="top" id="UFT-Ev-VST"/>
<constraint firstItem="sf1-cg-uKF" firstAttribute="leading" secondItem="ODG-Sk-nvn" secondAttribute="leading" id="XEf-aR-tOk"/>
<constraint firstItem="sf1-cg-uKF" firstAttribute="bottom" secondItem="Ywu-gT-m6t" secondAttribute="bottom" id="orC-nU-Ixw"/>
</constraints>
</view>
<connections>
<outlet property="backgroundImageView" destination="sf1-cg-uKF" id="O1H-ss-w2w"/>
<outlet property="button" destination="YzX-Yf-1Ql" id="Hw5-Yq-pvw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="y3d-JN-ISV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="293.60000000000002" y="-4.0479760119940034"/>
</scene>
</scenes>
<resources>
<image name="Background" width="800" height="480"/>
<image name="Ball" width="600" height="600"/>
</resources>
</document>
Loading

0 comments on commit ce4f7ee

Please sign in to comment.