Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint_07 #720

Open
wants to merge 21 commits into
base: project_sprint_3_start
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e234c9e
В AppDelegate добавлен вывод на консоль для тестирования коммита чере…
ilmachin3 Oct 24, 2023
f88dc8d
Изменения принта в делегате
ilmachin3 Oct 24, 2023
c6c5ccb
Merge pull request #1 from ilmachin3/testBranch
ilmachin3 Oct 24, 2023
01fe7fa
Готовое приложение
ilmachin3 Nov 11, 2023
f004185
Готовое приложение
ilmachin3 Nov 11, 2023
dad7a07
Исправление закругления постера
ilmachin3 Nov 13, 2023
dc60e16
5 sprint test
ilmachin3 Dec 4, 2023
4b16e0a
проверка ошибок
ilmachin3 Dec 7, 2023
e519433
Приложение работает!
ilmachin3 Dec 8, 2023
4ce247d
Добавление алерта
ilmachin3 Dec 10, 2023
bab7c15
решение 5 спринта
ilmachin3 Dec 18, 2023
8796cfa
Не работает АЛЕРТ
ilmachin3 Jan 10, 2024
bf8e10f
Не рабочий алерт
ilmachin3 Jan 10, 2024
3feedea
Инициализация алерта
ilmachin3 Jan 11, 2024
1eafead
добавил weak в alertPresenter
ilmachin3 Jan 15, 2024
ee97c2d
convert -> presenter
ilmachin3 Feb 13, 2024
88b7f83
nobut & yesbut
ilmachin3 Feb 15, 2024
8d72b17
showNextQuestionOrResults -> presenter
ilmachin3 Feb 15, 2024
0b3fda1
Перенесли  questionFactory
ilmachin3 Feb 17, 2024
e4f08f7
Готовый проект, с успешными Unit & Ui тестами
ilmachin3 Feb 19, 2024
175853f
Готовый 7 спринт
ilmachin3 Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
742 changes: 737 additions & 5 deletions MovieQuiz.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion MovieQuiz/Helpers/UIColor+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import UIKit

extension UIColor { }

extension UIColor {
static var ypBlack: UIColor { UIColor(named: "YP Black") ?? UIColor.black }
static var ypGreen: UIColor { UIColor(named: "YP Green") ?? UIColor.green }
static var ypRed: UIColor { UIColor(named: "YP Red") ?? UIColor.red }
static var ypBackground: UIColor { UIColor(named: "YP Background") ?? UIColor.darkGray }
static var ypGray: UIColor { UIColor(named: "YP Gray") ?? UIColor.gray }
static var ypWhite: UIColor { UIColor(named: "YP White") ?? UIColor.white}
}
15 changes: 15 additions & 0 deletions MovieQuiz/Models/AlertModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AlertModel.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 09.12.2023.
//

import UIKit

struct AlertModel{
var title: String
var message: String
var buttontext: String
var buttonAction: (() -> Void)
}
21 changes: 21 additions & 0 deletions MovieQuiz/Models/GameRecord.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// GameRecord.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 18.12.2023.
//

import Foundation

struct GameRecord: Codable {
let correct: Int
let total: Int
let date: Date

func isBetterThan(_ another: GameRecord) -> Bool {
correct > another.correct
}
func toString() -> String {
return "\(correct)/\(total) (\(date.dateTimeString)"
}
}
35 changes: 35 additions & 0 deletions MovieQuiz/Models/MostPopularMovies.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// MostPopularMovies.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 27.12.2023.
//

import Foundation

struct MostPopularMovies: Codable {
let errorMessage: String
let items: [MostPopularMovie]
}

struct MostPopularMovie : Codable {
let title: String
let rating: String
let imageURL: URL

var resizedImageURL: URL {
let urlString = imageURL.absoluteString
let imageUrlString = urlString.components(separatedBy: "._")[0] + "._V0_UX600_.jpg"

guard let newURL = URL(string: imageUrlString) else {
return imageURL
}
return newURL
}

private enum CodingKeys: String, CodingKey {
case title = "fullTitle"
case rating = "imDbRating"
case imageURL = "image"
}
}
14 changes: 14 additions & 0 deletions MovieQuiz/Models/QuizQuestion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// QuizQuestion.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 26.11.2023.
//

import UIKit

struct QuizQuestion {
let image: Data
let text: String
let correctAnswer: Bool
}
14 changes: 14 additions & 0 deletions MovieQuiz/Models/QuizResultsViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// QuizResultsViewModel.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 26.11.2023.
//

import UIKit

struct QuizResultsViewModel {
let title: String
let text: String
let buttonText: String
}
14 changes: 14 additions & 0 deletions MovieQuiz/Models/QuizStepViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// QuizStepViewModel.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 26.11.2023.
//

import UIKit

struct QuizStepViewModel {
let image: UIImage
let question: String
let questionNumber: String
}
33 changes: 33 additions & 0 deletions MovieQuiz/Presentation/AlertPresenter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// AlertPresenter.swift
// MovieQuiz
//
// Created by Илья Дышлюк on 09.12.2023.
//


import UIKit

final class AlertPresenter {

weak var view: UIViewController?

init(view: UIViewController) {
self.view = view
}

func show(data: AlertModel) {
let alert = UIAlertController(
title: data.title,
message: data.message,
preferredStyle: .alert)

let action = UIAlertAction(title: data.buttontext, style: .default) { _ in
data.buttonAction()
}

alert.addAction(action)

view!.present(alert, animated: true, completion: nil)
}
}
124 changes: 121 additions & 3 deletions MovieQuiz/Presentation/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="YS Display-Bold.ttf">
<string>YSDisplay-Bold</string>
</array>
<array key="YS Display-Medium.ttf">
<string>YSDisplay-Medium</string>
</array>
</customFonts>
<scenes>
<!--Movie Quiz View Controller-->
<scene sceneID="tne-QT-ifu">
Expand All @@ -15,13 +24,122 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="3c8-aF-6D3">
<rect key="frame" x="20" y="58" width="374" height="804"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tX1-qc-aZm">
<rect key="frame" x="0.0" y="0.0" width="374" height="23.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Вопрос:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dhw-ni-PBa" userLabel="Question Title Label">
<rect key="frame" x="0.0" y="0.0" width="338" height="23.5"/>
<fontDescription key="fontDescription" name="YSDisplay-Medium" family="YS Display" pointSize="20"/>
<color key="textColor" name="YP White"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="1/10" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fX2-Fj-PVH" userLabel="Index Label">
<rect key="frame" x="338" y="0.0" width="36" height="23.5"/>
<accessibility key="accessibilityConfiguration" identifier="Index"/>
<fontDescription key="fontDescription" name="YSDisplay-Medium" family="YS Display" pointSize="20"/>
<color key="textColor" name="YP White"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ma7-IY-YVF" userLabel="Preview Image">
<rect key="frame" x="0.0" y="43.5" width="374" height="561"/>
<color key="backgroundColor" name="YP White"/>
<accessibility key="accessibilityConfiguration" identifier="Poster">
<bool key="isElement" value="YES"/>
</accessibility>
<constraints>
<constraint firstAttribute="width" secondItem="Ma7-IY-YVF" secondAttribute="height" multiplier="2:3" id="ouI-Uf-avV"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Рейтинг этого фильма меньше, чем 5?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="irt-bx-c3D" userLabel="Question Label">
<rect key="frame" x="0.0" y="624.5" width="374" height="99.5"/>
<fontDescription key="fontDescription" name="YSDisplay-Bold" family="YS Display" pointSize="23"/>
<color key="textColor" name="YP White"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="ebJ-ti-wFW">
<rect key="frame" x="0.0" y="744" width="374" height="60"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hee-5s-H0s" userLabel="No button">
<rect key="frame" x="0.0" y="0.0" width="177" height="60"/>
<color key="backgroundColor" name="YP White"/>
<accessibility key="accessibilityConfiguration" identifier="No"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="SAl-4b-2bC"/>
</constraints>
<fontDescription key="fontDescription" name="YSDisplay-Medium" family="YS Display" pointSize="20"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Нет">
<color key="titleColor" name="YP Black"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="layer.cornerRadius" value="15"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="noButtonClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="8xZ-tp-RkC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OFI-qh-hD9" userLabel="Yes button">
<rect key="frame" x="197" y="0.0" width="177" height="60"/>
<color key="backgroundColor" name="YP White"/>
<accessibility key="accessibilityConfiguration" identifier="Yes"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="3Uk-fm-VGc"/>
</constraints>
<fontDescription key="fontDescription" name="YSDisplay-Medium" family="YS Display" pointSize="20"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Да">
<color key="titleColor" name="YP Black"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="layer.cornerRadius" value="15"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="yesButtonClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Pp2-KW-0ru"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
</stackView>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="S4P-Tf-4JN">
<rect key="frame" x="197" y="438" width="20" height="20"/>
</activityIndicatorView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" name="YP Black"/>
<constraints>
<constraint firstItem="3c8-aF-6D3" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="10" id="DS2-IW-5cG"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="3c8-aF-6D3" secondAttribute="trailing" constant="20" id="Gd4-bi-ygD"/>
<constraint firstItem="S4P-Tf-4JN" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="LlW-ln-fCf"/>
<constraint firstItem="3c8-aF-6D3" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="b8p-8f-xEG"/>
<constraint firstItem="3c8-aF-6D3" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="20" id="ogm-u4-VSd"/>
<constraint firstItem="S4P-Tf-4JN" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="xiD-rN-eeW"/>
</constraints>
</view>
<connections>
<outlet property="activityIndicator" destination="S4P-Tf-4JN" id="sLP-c6-W4r"/>
<outlet property="counterLabel" destination="fX2-Fj-PVH" id="2yz-df-3CE"/>
<outlet property="imageView" destination="Ma7-IY-YVF" id="QKU-Ix-kuT"/>
<outlet property="textLabel" destination="irt-bx-c3D" id="wER-c9-4DL"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-55.072463768115945" y="55.580357142857139"/>
</scene>
</scenes>
<resources>
<namedColor name="YP Black">
<color red="0.10199999809265137" green="0.10599999874830246" blue="0.13300000131130219" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="YP White">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
Loading