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

Правки по спринту 14 #1

Merged
merged 40 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
47fd398
Верстка LaunchScreen и экранов Трекер и Статистика
freeagles1991 Jul 26, 2024
fe76cfb
Добавил экраны для создания трекера
freeagles1991 Aug 5, 2024
9b8f1fd
Добавил экран с выбором расписания
freeagles1991 Aug 8, 2024
c5d06f4
Сохраняем выбранные дни недели
freeagles1991 Aug 8, 2024
1feecb3
Добавил UIDatePicker и заголовок
freeagles1991 Aug 8, 2024
7a97082
Сверстал ячейку для UICollectionView
freeagles1991 Aug 9, 2024
94c9da5
Настроил отображение UISearchBar
freeagles1991 Aug 9, 2024
d57422c
Добавил категории для ячеек
freeagles1991 Aug 9, 2024
19c9774
Правки по верстке экрана трекеров
freeagles1991 Aug 9, 2024
b1fe019
Добавил экраны для добавления категорий и сервис хранения трекеров
freeagles1991 Aug 10, 2024
075ddc8
Добавил таблицу на экран выбора категории
freeagles1991 Aug 10, 2024
489e063
Добавил сохранение созданных категорий в DataService
freeagles1991 Aug 11, 2024
a148204
Добавил отображение выбранной категории на кнопку
freeagles1991 Aug 11, 2024
ad0ad87
Добавил отображение выбранных дней недели в кнопке
freeagles1991 Aug 13, 2024
4762815
Добавил кнопки Отмена и Создать на экране создания трекера
freeagles1991 Aug 13, 2024
9777283
Правки верстки экрана создания нового трекера
freeagles1991 Aug 13, 2024
fb450eb
Сделал сохранение новых трекеров в сервис
freeagles1991 Aug 13, 2024
2505173
Отображение созданных трекеров из сервиса
freeagles1991 Aug 14, 2024
8155b22
Добавил фильтрацию трекеров по выбранной дате
freeagles1991 Aug 14, 2024
35c2e19
Добавил логику увеличения/уменьшения каунтера для трекера и проверку …
freeagles1991 Aug 14, 2024
47b2c42
Добавил записи в TrackerDataService
freeagles1991 Aug 15, 2024
17e6a35
Настройка отображения данных в ячейке
freeagles1991 Aug 15, 2024
acab97c
Трекер отображается сразу в выбранный день после добавления
freeagles1991 Aug 15, 2024
3a48254
Динамический размер ячеек в коллекции
freeagles1991 Aug 16, 2024
750040c
Добавил изменение состояния кнопки при создании трекера
freeagles1991 Aug 16, 2024
a4d67af
Почистил ненужные комментарии
freeagles1991 Aug 16, 2024
cd52f6c
Перенес хранение в TrackersVC
freeagles1991 Aug 17, 2024
c45b19d
Добавил склонение День для разного кол-ва выполненных дней
freeagles1991 Aug 17, 2024
c608ab7
Добавил бордер к TabBar и увеличил высоту
freeagles1991 Aug 17, 2024
9a68498
Исправил использование шрифтов
freeagles1991 Aug 17, 2024
9bb8c2c
Переименовал цвет и изменил цвет свичей в расписании
freeagles1991 Aug 17, 2024
a402ebf
Изменил цвет кнопок
freeagles1991 Aug 17, 2024
b8b0c48
Изменил логику выполнения трекера по выбранным дням
freeagles1991 Aug 18, 2024
7a59a97
Исправил верстку кнопки ячейки
freeagles1991 Aug 18, 2024
5d42b43
Скрываем клавиатуру при тапе на область экрана
freeagles1991 Aug 18, 2024
e601f9a
Добавил создание нерегулярных событий
freeagles1991 Aug 18, 2024
1b2e985
Переименовал контроллеры
freeagles1991 Aug 18, 2024
5fde007
Добавил подложку для эмоджи, динамическая верстка элементов ячейки
freeagles1991 Aug 18, 2024
b3e28a9
Верстка заголовка секции
freeagles1991 Aug 18, 2024
5932792
Указал final для классов
freeagles1991 Aug 18, 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
Prev Previous commit
Next Next commit
Добавил экран с выбором расписания
  • Loading branch information
freeagles1991 committed Aug 8, 2024
commit 9b8f1fd87d4a303abe1d9a3f564ab18ecbb3b7ce
4 changes: 4 additions & 0 deletions Tracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
32A45BB52C5EACDC002A97F5 /* TrackerRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32A45BB42C5EACDC002A97F5 /* TrackerRecord.swift */; };
32A45BB72C5FE326002A97F5 /* CreateNewTrackerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32A45BB62C5FE326002A97F5 /* CreateNewTrackerViewController.swift */; };
32BABEFC2C60DAAC00E176E2 /* CreateNewHabitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32BABEFB2C60DAAC00E176E2 /* CreateNewHabitViewController.swift */; };
32BABEFE2C61501A00E176E2 /* ScheduleScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32BABEFD2C61501A00E176E2 /* ScheduleScreenViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -67,6 +68,7 @@
32A45BB42C5EACDC002A97F5 /* TrackerRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackerRecord.swift; sourceTree = "<group>"; };
32A45BB62C5FE326002A97F5 /* CreateNewTrackerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateNewTrackerViewController.swift; sourceTree = "<group>"; };
32BABEFB2C60DAAC00E176E2 /* CreateNewHabitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateNewHabitViewController.swift; sourceTree = "<group>"; };
32BABEFD2C61501A00E176E2 /* ScheduleScreenViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleScreenViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -172,6 +174,7 @@
32A45B6A2C53DA2E002A97F5 /* TrackersViewController.swift */,
32A45BB62C5FE326002A97F5 /* CreateNewTrackerViewController.swift */,
32BABEFB2C60DAAC00E176E2 /* CreateNewHabitViewController.swift */,
32BABEFD2C61501A00E176E2 /* ScheduleScreenViewController.swift */,
);
path = TrackersScreen;
sourceTree = "<group>";
Expand Down Expand Up @@ -359,6 +362,7 @@
3238825B2C52AB0B00EE11A3 /* AppDelegate.swift in Sources */,
32A45B652C53D549002A97F5 /* LaunchScreenViewController.swift in Sources */,
32A45B682C53D9A6002A97F5 /* TabBarController.swift in Sources */,
32BABEFE2C61501A00E176E2 /* ScheduleScreenViewController.swift in Sources */,
3238825D2C52AB0B00EE11A3 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
38 changes: 38 additions & 0 deletions Tracker/Assets.xcassets/lightGrey.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xEB",
"green" : "0xE8",
"red" : "0xE6"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFE"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
14 changes: 7 additions & 7 deletions Tracker/Models/Tracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import Foundation

enum Weekday: String, CaseIterable, Codable {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше вынести в отдельный файл

case monday = "Monday"
case tuesday = "Tuesday"
case wednesday = "Wednesday"
case thursday = "Thursday"
case friday = "Friday"
case saturday = "Saturday"
case sunday = "Sunday"
case monday = "Понедельник"
case tuesday = "Вторник"
case wednesday = "Среда"
case thursday = "Четверг"
case friday = "Пятница"
case saturday = "Суббота"
case sunday = "Воскресенье"
}

struct Tracker: Identifiable, Codable {
Expand Down
133 changes: 127 additions & 6 deletions Tracker/TrackersScreen/CreateNewHabitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,143 @@ import Foundation
import UIKit

final class CreateNewHabitViewController: UIViewController {
private var screenTitle: UILabel?
private var screenTitle = UILabel()
private let screenTitleString: String = "Новая привычка"

private var textField: UITextField?
private var textField = UITextField()
private let textFieldString: String = "Введите название трекера"

private var categoryButton: UIButton?
private var categoryButton = UIButton()
private let categoryButtonString: String = "Категория"

private var scheduleButton: UIButton?
private var scheduleButton = UIButton()
private let scheduleButtonString: String = "Расписание"

private var cancelButton: UIButton?
private var cancelButton = UIButton()
private let cancelButtonString: String = "Отменить"

private var createButton: UIButton?
private var createButton = UIButton()
private let createButtonString: String = "Создать"

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
setupScreenTitle()
setupTextField()
setupCategoryButton()
setupScheduleButton()
setupStackView()
}

private func setupScreenTitle() {
let label = UILabel()
let font = UIFont(name: "SF Pro", size: 16)
label.text = screenTitleString
label.textColor = .black
label.font = font
label.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(label)

label.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 22).isActive = true
label.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor).isActive = true

self.screenTitle = label
}

private func setupTextField() {
let textField = UITextField()
textField.placeholder = "Введите название трекера"
textField.borderStyle = .none
textField.layer.cornerRadius = 16
textField.layer.masksToBounds = true
textField.backgroundColor = UIColor(white: 0.95, alpha: 1)
textField.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(textField)

NSLayoutConstraint.activate([
textField.topAnchor.constraint(equalTo: screenTitle.bottomAnchor, constant: 38),
textField.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
textField.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
textField.heightAnchor.constraint(equalToConstant: 75)
])

self.textField = textField
}

private func setupButton(with text: String) -> UIButton {
let button = UIButton(type: .system)
button.setTitle(text, for: .normal)
button.setTitleColor(.black, for: .normal)
button.contentHorizontalAlignment = .left
button.backgroundColor = UIColor(named: "lightGrey")
button.layer.cornerRadius = 16
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0)

let arrowImageView = UIImageView(image: UIImage(systemName: "chevron.right"))
arrowImageView.tintColor = .gray
arrowImageView.translatesAutoresizingMaskIntoConstraints = false
button.addSubview(arrowImageView)

NSLayoutConstraint.activate([
arrowImageView.centerYAnchor.constraint(equalTo: button.centerYAnchor),
arrowImageView.trailingAnchor.constraint(equalTo: button.trailingAnchor, constant: -16)
])

return button
}

private func setupCategoryButton() {
let categoryButton = setupButton(with: categoryButtonString)
categoryButton.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]

self.categoryButton = categoryButton
}

private func setupScheduleButton() {
let scheduleButton = setupButton(with: scheduleButtonString)
scheduleButton.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
scheduleButton.addTarget(self, action: #selector(scheduleButtonTapped(_:)), for: .touchUpInside)

self.scheduleButton = scheduleButton
}

let separator: UIView = {
let view = UIView()
view.backgroundColor = UIColor(white: 0.8, alpha: 1)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

private func setupStackView() {
// Создание StackView для кнопок
let stackView = UIStackView(arrangedSubviews: [categoryButton, separator, scheduleButton])
stackView.axis = .vertical
stackView.spacing = 0
stackView.alignment = .fill
stackView.distribution = .fill

// Добавление StackView на view
stackView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stackView)

// Установка constraints для StackView
NSLayoutConstraint.activate([
// Центрирование StackView по горизонтали
stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
// Центрирование StackView по вертикали
stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
])
// Установка constraints для кнопок
NSLayoutConstraint.activate([
categoryButton.heightAnchor.constraint(equalToConstant: 75),
scheduleButton.heightAnchor.constraint(equalToConstant: 75)
])
}

@objc private func scheduleButtonTapped(_ sender: UIButton) {
let scheduleScreenVC = ScheduleScreenViewController()
present(scheduleScreenVC, animated: true)
}
}
17 changes: 15 additions & 2 deletions Tracker/TrackersScreen/CreateNewTrackerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ final class CreateNewTrackerViewController: UIViewController {
}

private func setupHabitButton() {
self.habitButton = self.setupButton(with: habitButtonText)
let habitButton = self.setupButton(with: habitButtonText)
habitButton.addTarget(self, action: #selector(habitButtonTapped(_:)), for: .touchUpInside)

self.habitButton = habitButton
}

private func setupEventButton() {
let eventButton = self.setupButton(with: eventButtonText)
eventButton.addTarget(self, action: #selector(eventButtonTapped(_:)), for: .touchUpInside)

self.eventButton = self.setupButton(with: eventButtonText)
self.eventButton = eventButton
}

private func setupStackView() {
Expand Down Expand Up @@ -89,4 +94,12 @@ final class CreateNewTrackerViewController: UIViewController {
])
}

@objc private func habitButtonTapped(_ sender: UIButton) {
let createNewHabitVC = CreateNewHabitViewController()
present(createNewHabitVC, animated: true)
}

@objc private func eventButtonTapped(_ sender: UIButton) {

}
}
Loading