Skip to content

Commit

Permalink
Allow to specify startingDate and minimumDate
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Müller <[email protected]>
  • Loading branch information
SystemKeeper committed Aug 3, 2023
1 parent 819583e commit 86b3a7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion NextcloudTalk/DatePickerTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
self.tintColor = .clear
}

public func getDate(completion: @escaping (Date) -> Void) {
public func getDate(startingDate: Date?, minimumDate: Date?, completion: @escaping (Date) -> Void) {
guard self.canBecomeFirstResponder else {
return
}
Expand All @@ -48,6 +48,14 @@
datePicker.locale = .current
datePicker.preferredDatePickerStyle = .wheels

if let startingDate {
datePicker.date = startingDate
}

if let minimumDate {
datePicker.minimumDate = minimumDate
}

self.inputView = datePicker

let cancelButton = UIBarButtonItem(systemItem: .cancel, primaryAction: UIAction { [weak self] _ in
Expand Down
4 changes: 3 additions & 1 deletion NextcloudTalk/NCChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4329,7 +4329,9 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuCo
self.interactingMessage = message;
self.lastMessageBeforeInteraction = [[self.tableView indexPathsForVisibleRows] lastObject];

[weakSelf.datePickerTextField getDateWithCompletion:^(NSDate * _Nonnull selectedDate) {
NSDate *startingDate = [[NSDate date] dateByAddingHours:1];
NSDate *minimumDate = [[NSDate date] dateByAddingMinutes:15];
[weakSelf.datePickerTextField getDateWithStartingDate:startingDate minimumDate:minimumDate completion:^(NSDate * _Nonnull selectedDate) {
NSString *timestamp = [NSString stringWithFormat:@"%.0f", [selectedDate timeIntervalSince1970]];

[[NCAPIController sharedInstance] setReminderForMessage:message withTimestamp:timestamp withCompletionBlock:setReminderCompletion];
Expand Down

0 comments on commit 86b3a7c

Please sign in to comment.