Commit 4c9e8560 authored by Soomin Lee's avatar Soomin Lee Committed by Jean-Baptiste Kempf

iOS: Add cancel and confirm button to sleep timer feature

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 25cdd71f
Pipeline #73 failed with stage
in 0 seconds
......@@ -553,6 +553,15 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_sleepTimerContainer.layer.cornerRadius = 5;
_sleepTimerContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
//Layers used to create a separator for the buttons.
CALayer *horizontalSeparator = [CALayer layer];
horizontalSeparator.frame = CGRectMake(0., 162., 300., 1.);
horizontalSeparator.backgroundColor = [UIColor VLCLightTextColor].CGColor;
CALayer *verticalSeparator = [CALayer layer];
verticalSeparator.frame = CGRectMake(150., 162., 1., 48.);
verticalSeparator.backgroundColor = [UIColor VLCLightTextColor].CGColor;
_sleepTimeDatePicker = [[UIDatePicker alloc] init];
if (deviceSpeedCategory >= 3) {
_sleepTimeDatePicker.opaque = NO;
......@@ -564,6 +573,26 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_sleepTimeDatePicker.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
[_sleepTimerContainer addSubview:_sleepTimeDatePicker];
[_sleepTimerContainer.layer addSublayer:horizontalSeparator];
[_sleepTimerContainer.layer addSublayer:verticalSeparator];
UIButton *cancelSleepTimer = [[UIButton alloc] initWithFrame:CGRectMake(0., 162., 150., 48.)];
cancelSleepTimer.backgroundColor = [UIColor clearColor];
[cancelSleepTimer setTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) forState:UIControlStateNormal];
[cancelSleepTimer setTintColor:[UIColor VLCLightTextColor]];
[cancelSleepTimer setTitleColor:[UIColor VLCDarkTextShadowColor] forState:UIControlStateHighlighted];
[cancelSleepTimer addTarget:self action:@selector(sleepTimerCancel:) forControlEvents:UIControlEventTouchDown];
cancelSleepTimer.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 10, 0);
[_sleepTimerContainer addSubview:cancelSleepTimer];
UIButton *confirmSleepTimer = [[UIButton alloc] initWithFrame:CGRectMake(150., 162., 150., 48.)];
confirmSleepTimer.backgroundColor = [UIColor clearColor];
[confirmSleepTimer setTitle:NSLocalizedString(@"BUTTON_DONE", nil) forState:UIControlStateNormal];
[confirmSleepTimer setTintColor:[UIColor VLCLightTextColor]];
[confirmSleepTimer setTitleColor:[UIColor VLCDarkTextShadowColor] forState:UIControlStateHighlighted];
[confirmSleepTimer addTarget:self action:@selector(sleepTimerAction:) forControlEvents:UIControlEventTouchDown];
confirmSleepTimer.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 10, 0);
[_sleepTimerContainer addSubview:confirmSleepTimer];
/* adapt the date picker style to suit our needs */
[_sleepTimeDatePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
......@@ -1093,6 +1122,18 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
_sleepTimerContainer.hidden = NO;
}
- (IBAction)sleepTimerCancel:(id)sender
{
NSTimer *sleepTimer = [_vpc sleepTimer];
if (sleepTimer) {
[sleepTimer invalidate];
sleepTimer = nil;
}
[self.statusLabel showStatusMessage:NSLocalizedString(@"SLEEP_TIMER_UPDATED", nil)];
[self setControlsHidden:YES animated:YES];
}
- (IBAction)sleepTimerAction:(id)sender
{
[_vpc scheduleSleepTimerWithInterval:_sleepTimeDatePicker.countDownDuration];
......@@ -1104,6 +1145,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
userInfo:nil
repeats:YES];
}
[self.statusLabel showStatusMessage:NSLocalizedString(@"SLEEP_TIMER_UPDATED", nil)];
[self setControlsHidden:YES animated:YES];
}
- (void)moreActions:(UIButton *)sender
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment