-
Notifications
You must be signed in to change notification settings - Fork 35
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
Personal deadlines #300
Personal deadlines #300
Conversation
@@ -41,6 +41,13 @@ class Parser: NSObject { | |||
} | |||
} | |||
|
|||
func timedateStringFromDate(date: Date) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Где-то я это уже видел 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Где? Оо
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну, у нас есть ещё несколько мест, где мы Date форматируем как-то.
Stepic/PersonalDeadlineCounter.swift
Outdated
} | ||
fulfill((section.id, sectionTimeToComplete)) | ||
}, error: { | ||
//TODO: Add error handling here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нужно добавить хотя бы логирование, я считаю.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, упустил эту тудушку вообще
Stepic/PersonalDeadlineCounter.swift
Outdated
private func countTimeToComplete(section: Section) -> Promise<(Int, TimeInterval)> { | ||
return Promise { | ||
fulfill, _ in | ||
section.loadUnits(success: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если это возможно, стоит избавляться от коллбеков сразу.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Там легаси, которое надо рефакторить, когда будет переделывать старые классы модели типа Course, Section, Lesson
import UIKit | ||
import ActionSheetPicker_3_0 | ||
|
||
class PersonalDeadlineEditScheduleViewController: UIViewController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это не MVP модуль? Кажется, что здесь совсем легко можно разделить логику.
extension PersonalDeadlineEditScheduleViewController: UITableViewDelegate { | ||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
AnalyticsReporter.reportEvent(AnalyticsEvents.PersonalDeadlines.EditSchedule.Time.opened) | ||
ActionSheetDatePicker.show(withTitle: NSLocalizedString("SelectTimeTitle", comment: ""), datePickerMode: UIDatePickerMode.dateAndTime, selectedDate: sectionDeadlinesData[indexPath.row].deadline, minimumDate: Date(), maximumDate: Date().addingTimeInterval(60 * 60 * 24 * 30 * 365), doneBlock: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно, произведения единиц времени стоит выносить в константы, чтобы было понятно, что это за интервал.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ок
collectionView.constrainHeight("\(modeButtonSize.height)") | ||
collectionView.invalidateIntrinsicContentSize() | ||
collectionView.layoutIfNeeded() | ||
(collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.itemSize = modeButtonSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ниже дублирование кода. Возможно стоит сделать свой лэйаут или хотя бы в отдельный метод.
import FLKAutoLayout | ||
import SVProgressHUD | ||
|
||
class PersonalDeadlinesModeSelectionViewController: UIViewController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут тоже про MVP вопрос. Правда, здесь ещё меньше логики, которую можно извлечь.
override func setupSubviews() { | ||
self.view.setRoundedCorners(cornerRadius: 8) | ||
yesButton.setRoundedCorners(cornerRadius: 8, borderWidth: 1, borderColor: UIColor(hex: 0x45B0FF)) | ||
//TODO: Do not forget to localize text and buttons here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Уже локализовали.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Потру
Stepic/StepikLabel.swift
Outdated
@@ -34,6 +34,8 @@ enum StepikLabelColorMode { | |||
return UIColor.white | |||
case .gray: | |||
return UIColor.lightGray | |||
case .blue: | |||
return UIColor(hex: 0x45B0FF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В трёх местах уже используется. Вынесем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что вынесем? Цвет? Давай.
Stepic/StorageData.swift
Outdated
|
||
protocol StorageData { | ||
init(json: JSON) | ||
var dictValue: [String : Any] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Всегда ж было { get set }
в одну строку :)
Задача: #APPS-1880
Коротко для Release Notes, в формате «Сделали/Добавили/Исправили N»:
Добавили пользовательские дедлайны
Описание:
Основные классы:
PersonalDeadlineCounter
- класс, ответственный за рассчет времениPersonalDeadlineLocalStorageManager
- класс, ответственный за хранениеStorageRecord
объектовPersonalDeadlineNotificationsManager
- класс, ответственный за установку нотификаций по дедлайнамStorageRecordsAPI
- АПИ класс работы со эндпоинтомapi/storage-records
PersonalDeadlineManager
- класс, ответственный за реализацию всех кейсов использования персональных дедлайновPersonalDeadlineEditScheduleViewController
- контроллер изменения расписанияPersonalDeadlineModesSelectionViewController
- контроллер выбора режимов изученияСуществует несколько кейсов для использования пользовательских дедлайнов, каждый из которых разрешается методом в
PersonalDeadlineManager
:func countDeadlines(for course: Course, mode: DeadlineMode)
PersonalDeadlineCounter
StorageRecordsAPI
PersonalDeadlineLocalStorageManager
PersonalDeadlineNotificationsManager
syncDeadline(for course: Course, userID: Int)
StorageRecordsAPI
по kind с ID нужного нам курсаPersonalDeadlineLocalStorageManager
локальную запись для курсаPersonalDeadlineNotificationsManager
func deleteDeadline(for course: Course)
PersonalDeadlineLocalStorageManager
StorageRecordsAPI
с полученным ID записиPersonalDeadlineLocalStorageManager
локальную запись для курсаPersonalDeadlineNotificationsManager
changeDeadline(for course: Course, newDeadlines: [SectionDeadline])
PersonalDeadlineLocalStorageManager
StorageRecordsAPI
с подмененными дедлайнами в полученном объектеPersonalDeadlineLocalStorageManager
локальную запись для курсаPersonalDeadlineNotificationsManager
Для установки дедлайнов в
PersonalDeadlineNotificationsManager
используется фреймворкUserNotifications
. Подсчет времени вPersonalDeadlineCounter
происходит по полюtime_to_complete
для каждого урока. Core Data была смигрирована на новую версию для храненияtime_to_complete
. StorageRecord объекты хранятся в UserDefaults.