Skip to content

Homework5.5 #2

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 26 additions & 6 deletions AppTasks.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
81125F5D29E2CA7000F83D0E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 81125F5C29E2CA7000F83D0E /* Assets.xcassets */; };
81125F6029E2CA7000F83D0E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81125F5E29E2CA7000F83D0E /* LaunchScreen.storyboard */; };
81125F6A29E2CE6200F83D0E /* TasksTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81125F6929E2CE6200F83D0E /* TasksTableViewController.swift */; };
81125F7329E2E8D000F83D0E /* TaskTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81125F7129E2E8D000F83D0E /* TaskTableViewCell.swift */; };
81125F7429E2E8D000F83D0E /* TaskTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 81125F7229E2E8D000F83D0E /* TaskTableViewCell.xib */; };
81125F7729E2EC3600F83D0E /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81125F7629E2EC3600F83D0E /* Task.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -24,6 +27,9 @@
81125F5F29E2CA7000F83D0E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
81125F6129E2CA7000F83D0E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
81125F6929E2CE6200F83D0E /* TasksTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TasksTableViewController.swift; sourceTree = "<group>"; };
81125F7129E2E8D000F83D0E /* TaskTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskTableViewCell.swift; sourceTree = "<group>"; };
81125F7229E2E8D000F83D0E /* TaskTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TaskTableViewCell.xib; sourceTree = "<group>"; };
81125F7629E2EC3600F83D0E /* Task.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -58,8 +64,9 @@
children = (
81125F5329E2CA6F00F83D0E /* AppDelegate.swift */,
81125F5529E2CA6F00F83D0E /* SceneDelegate.swift */,
81125F7029E2D29C00F83D0E /* TaskContoller */,
81125F6F29E2D28F00F83D0E /* TaskCell */,
81125F7029E2D29C00F83D0E /* Controller */,
81125F7529E2EC0300F83D0E /* Model */,
81125F6F29E2D28F00F83D0E /* Cell */,
81125F5929E2CA6F00F83D0E /* Main.storyboard */,
81125F5C29E2CA7000F83D0E /* Assets.xcassets */,
81125F5E29E2CA7000F83D0E /* LaunchScreen.storyboard */,
Expand All @@ -68,19 +75,29 @@
path = AppTasks;
sourceTree = "<group>";
};
81125F6F29E2D28F00F83D0E /* TaskCell */ = {
81125F6F29E2D28F00F83D0E /* Cell */ = {
isa = PBXGroup;
children = (
81125F7129E2E8D000F83D0E /* TaskTableViewCell.swift */,
81125F7229E2E8D000F83D0E /* TaskTableViewCell.xib */,
);
name = TaskCell;
name = Cell;
sourceTree = "<group>";
};
81125F7029E2D29C00F83D0E /* TaskContoller */ = {
81125F7029E2D29C00F83D0E /* Controller */ = {
isa = PBXGroup;
children = (
81125F6929E2CE6200F83D0E /* TasksTableViewController.swift */,
);
name = TaskContoller;
name = Controller;
sourceTree = "<group>";
};
81125F7529E2EC0300F83D0E /* Model */ = {
isa = PBXGroup;
children = (
81125F7629E2EC3600F83D0E /* Task.swift */,
);
name = Model;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -141,6 +158,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
81125F7429E2E8D000F83D0E /* TaskTableViewCell.xib in Resources */,
81125F6029E2CA7000F83D0E /* LaunchScreen.storyboard in Resources */,
81125F5D29E2CA7000F83D0E /* Assets.xcassets in Resources */,
81125F5B29E2CA6F00F83D0E /* Main.storyboard in Resources */,
Expand All @@ -154,7 +172,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
81125F7329E2E8D000F83D0E /* TaskTableViewCell.swift in Sources */,
81125F6A29E2CE6200F83D0E /* TasksTableViewController.swift in Sources */,
81125F7729E2EC3600F83D0E /* Task.swift in Sources */,
81125F5429E2CA6F00F83D0E /* AppDelegate.swift in Sources */,
81125F5629E2CA6F00F83D0E /* SceneDelegate.swift in Sources */,
);
Expand Down
6 changes: 3 additions & 3 deletions AppTasks/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Задачи-->
<!--Tasks Table View Controller-->
<scene sceneID="JWe-i3-9Oz">
<objects>
<tableViewController id="Ldy-LZ-dLs" customClass="TasksTableViewController" customModule="AppTasks" customModuleProvider="target" sceneMemberID="viewController">
<tableViewController storyboardIdentifier="TasksTableViewController" id="Ldy-LZ-dLs" customClass="TasksTableViewController" customModule="AppTasks" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="gma-l4-LT0">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand All @@ -30,7 +30,7 @@
<outlet property="delegate" destination="Ldy-LZ-dLs" id="3YG-7o-Od2"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Задачи" id="GiA-1b-6bH">
<navigationItem key="navigationItem" id="GiA-1b-6bH">
<barButtonItem key="rightBarButtonItem" title="Добавить задачу" image="text.badge.plus" catalog="system" id="tyZ-QI-WUZ">
<connections>
<action selector="addNewTask:" destination="Ldy-LZ-dLs" id="66d-ds-0zm"/>
Expand Down
39 changes: 39 additions & 0 deletions AppTasks/Task.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Task.swift
// AppTasks
//
// Created by Александр Кукоба on 09.04.2023.
//

import Foundation

class Task {

//MARK: Properies
var text: String = ""
var taskEditable: Bool = false
private var tasks: [Task] = []

//MARK: Init
init(_ text: String, _ taskEditable: Bool) {
self.text = text
self.taskEditable = taskEditable
}

//MARK: Methods
func taskCount() -> Int {
return tasks.count
}

func addTask(_ task: Task) {
tasks.append(task)
}
func deleteTask(_ index: Int) {
self.tasks.remove(at: index)
}
func getTasks() -> [Task] {
return tasks
}


}
72 changes: 72 additions & 0 deletions AppTasks/TaskTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// TaskTableViewCell.swift
// AppTasks
//
// Created by Александр Кукоба on 09.04.2023.
//

import UIKit


class TaskTableViewCell: UITableViewCell {

//MARK: Properies
var taskEditable: Bool = false
var task: Task!
var index: Int!

//MARK: IBOutlets
@IBOutlet weak var taskLabel: UILabel!

@IBOutlet weak var taskCount: UILabel!

@IBOutlet weak var taskEdit: UITextField!

@IBOutlet weak var taskBtnSave: UIButton!

var closure: ((Task, Int) -> ())?

//MARK: Button action
@IBAction func taskSave(_ sender: UIButton) {
task.text = taskEdit.text ?? ""
closure?(task, index)
}

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}

func configure(_ task: Task, _ index: Int) {
self.task = task
self.index = index

self.taskEditable = task.taskEditable
self.taskLabel.text = task.text
self.taskCount.text = String(task.taskCount())

self.display(task)
}

func display(_ task: Task){
if (task.taskEditable) {
self.taskLabel.isHidden = true
self.taskCount.isHidden = true
self.taskEdit.isHidden = false
self.taskBtnSave.isHidden = false
}
else
{
self.taskLabel.isHidden = false
self.taskCount.isHidden = false
self.taskEdit.isHidden = true
self.taskBtnSave.isHidden = true
}
}


}
91 changes: 91 additions & 0 deletions AppTasks/TaskTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="TaskCell" rowHeight="49" id="KGk-i7-Jjw" customClass="TaskTableViewCell" customModule="AppTasks" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="417" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="417" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="btg-r3-dZT">
<rect key="frame" x="5" y="5" width="350" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="B1y-tM-zBH"/>
<constraint firstAttribute="width" constant="350" id="Lye-VC-t8b"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TDG-1p-dlB">
<rect key="frame" x="370" y="5" width="42" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="2Gs-qg-GqB"/>
<constraint firstAttribute="width" constant="42" id="WQk-wy-I55"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Введите текст" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eJu-qZ-ezO">
<rect key="frame" x="5" y="5" width="350" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="4GC-LX-ysp"/>
<constraint firstAttribute="width" constant="350" id="9M4-nz-W5Y"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9YM-QD-S8B">
<rect key="frame" x="372" y="5" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="MJ6-BH-qqe"/>
<constraint firstAttribute="width" constant="40" id="zhP-II-OBU"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" image="save"/>
<connections>
<action selector="taskSave:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="itv-AE-qUB"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="eJu-qZ-ezO" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="1fU-n2-r7D"/>
<constraint firstItem="eJu-qZ-ezO" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="5" id="ALz-Kq-QvL"/>
<constraint firstItem="9YM-QD-S8B" firstAttribute="leading" secondItem="eJu-qZ-ezO" secondAttribute="trailing" constant="17" id="H1N-vF-UED"/>
<constraint firstAttribute="bottom" secondItem="btg-r3-dZT" secondAttribute="bottom" constant="5" id="IFI-UO-L70"/>
<constraint firstAttribute="bottom" secondItem="9YM-QD-S8B" secondAttribute="bottom" constant="5" id="W6k-9Z-QXF"/>
<constraint firstAttribute="bottom" secondItem="TDG-1p-dlB" secondAttribute="bottom" constant="5" id="Wzg-lg-IfE"/>
<constraint firstAttribute="trailing" secondItem="9YM-QD-S8B" secondAttribute="trailing" constant="5" id="ZMc-sP-TKB"/>
<constraint firstItem="TDG-1p-dlB" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="bcy-Gk-cYS"/>
<constraint firstItem="9YM-QD-S8B" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="eyN-3D-OSo"/>
<constraint firstItem="btg-r3-dZT" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="5" id="iLD-1h-HiQ"/>
<constraint firstAttribute="bottom" secondItem="eJu-qZ-ezO" secondAttribute="bottom" constant="5" id="nGQ-bW-KUO"/>
<constraint firstAttribute="trailing" secondItem="TDG-1p-dlB" secondAttribute="trailing" constant="5" id="nJ1-lo-HJb"/>
<constraint firstItem="btg-r3-dZT" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="otd-1f-l1R"/>
<constraint firstItem="TDG-1p-dlB" firstAttribute="leading" secondItem="btg-r3-dZT" secondAttribute="trailing" constant="15" id="sYL-qZ-gJV"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="taskBtnSave" destination="9YM-QD-S8B" id="NQp-wY-jFf"/>
<outlet property="taskCount" destination="TDG-1p-dlB" id="2O5-LN-vZi"/>
<outlet property="taskEdit" destination="eJu-qZ-ezO" id="B7Q-mZ-SG1"/>
<outlet property="taskLabel" destination="btg-r3-dZT" id="Rfy-W1-lqH"/>
</connections>
<point key="canvasLocation" x="203.81679389312976" y="-10.91549295774648"/>
</tableViewCell>
</objects>
<resources>
<image name="save" width="33.333332061767578" height="33.333332061767578"/>
</resources>
</document>
Loading