Sfoglia il codice sorgente

playback: fix sleep timer layout (closes #14139)

Felix Paul Kühne 10 anni fa
parent
commit
ccbf4da74c
1 ha cambiato i file con 40 aggiunte e 41 eliminazioni
  1. 40 41
      Sources/VLCMovieViewController.m

+ 40 - 41
Sources/VLCMovieViewController.m

@@ -421,6 +421,46 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     _equalizerView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
     _equalizerView.hidden = YES;
     [self.view addSubview:_equalizerView];
+
+    /* add sleep timer UI */
+    _sleepTimerContainer = [[VLCFrostedGlasView alloc] initWithFrame:CGRectMake(0., 0., 300., 162.)];
+    _sleepTimerContainer.center = self.view.center;
+    _sleepTimerContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
+
+    _sleepTimeDatePicker = [[UIDatePicker alloc] init];
+    if ([[UIDevice currentDevice] speedCategory] >= 3) {
+        _sleepTimeDatePicker.opaque = NO;
+        _sleepTimeDatePicker.backgroundColor = [UIColor clearColor];
+    } else
+        _sleepTimeDatePicker.backgroundColor = [UIColor blackColor];
+    _sleepTimeDatePicker.tintColor = [UIColor VLCLightTextColor];
+    _sleepTimeDatePicker.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
+    [_sleepTimerContainer addSubview:_sleepTimeDatePicker];
+
+    /* adapt the date picker style to suit our needs */
+    [_sleepTimeDatePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
+    SEL selector = NSSelectorFromString(@"setHighlightsToday:");
+    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]];
+    BOOL no = NO;
+    [invocation setSelector:selector];
+    [invocation setArgument:&no atIndex:2];
+    [invocation invokeWithTarget:_sleepTimeDatePicker];
+
+    if (_sleepTimerContainer.subviews.count > 0) {
+        NSArray *subviewsOfSubview = [_sleepTimeDatePicker.subviews[0] subviews];
+        NSUInteger subviewCount = subviewsOfSubview.count;
+        for (NSUInteger x = 0; x < subviewCount; x++) {
+            if ([subviewsOfSubview[x] isKindOfClass:[UILabel class]])
+                [subviewsOfSubview[x] setTextColor:[UIColor VLCLightTextColor]];
+        }
+    }
+    _sleepTimeDatePicker.datePickerMode = UIDatePickerModeCountDownTimer;
+    _sleepTimeDatePicker.minuteInterval = 5;
+    _sleepTimeDatePicker.minimumDate = [NSDate date];
+    _sleepTimeDatePicker.countDownDuration = 1200.;
+    [_sleepTimeDatePicker addTarget:self action:@selector(sleepTimerAction:) forControlEvents:UIControlEventValueChanged];
+
+    [self.view addSubview:_sleepTimerContainer];
 }
 
 - (BOOL)_blobCheck
@@ -1273,47 +1313,6 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
 
 - (IBAction)sleepTimer:(id)sender
 {
-    if (!_sleepTimerContainer) {
-        self.playbackSpeedView.hidden = YES;
-        _sleepTimerContainer = [[VLCFrostedGlasView alloc] initWithFrame:CGRectMake(0., 0., 300., 162.)];
-        _sleepTimerContainer.center = self.view.center;
-        _sleepTimerContainer.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
-
-        _sleepTimeDatePicker = [[UIDatePicker alloc] init];
-        if ([[UIDevice currentDevice] speedCategory] >= 3) {
-            _sleepTimeDatePicker.opaque = NO;
-            _sleepTimeDatePicker.backgroundColor = [UIColor clearColor];
-        } else
-            _sleepTimeDatePicker.backgroundColor = [UIColor blackColor];
-        _sleepTimeDatePicker.tintColor = [UIColor VLCLightTextColor];
-        [_sleepTimerContainer addSubview:_sleepTimeDatePicker];
-
-        /* adapt the date picker style to suit our needs */
-        [_sleepTimeDatePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
-        SEL selector = NSSelectorFromString(@"setHighlightsToday:");
-        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]];
-        BOOL no = NO;
-        [invocation setSelector:selector];
-        [invocation setArgument:&no atIndex:2];
-        [invocation invokeWithTarget:_sleepTimeDatePicker];
-
-        if (_sleepTimerContainer.subviews.count > 0) {
-            NSArray *subviewsOfSubview = [_sleepTimeDatePicker.subviews[0] subviews];
-            NSUInteger subviewCount = subviewsOfSubview.count;
-            for (NSUInteger x = 0; x < subviewCount; x++) {
-                if ([subviewsOfSubview[x] isKindOfClass:[UILabel class]])
-                    [subviewsOfSubview[x] setTextColor:[UIColor VLCLightTextColor]];
-            }
-        }
-        _sleepTimeDatePicker.datePickerMode = UIDatePickerModeCountDownTimer;
-        _sleepTimeDatePicker.minuteInterval = 5;
-        _sleepTimeDatePicker.minimumDate = [NSDate date];
-        _sleepTimeDatePicker.countDownDuration = 1200.;
-        [_sleepTimeDatePicker addTarget:self action:@selector(sleepTimerAction:) forControlEvents:UIControlEventValueChanged];
-
-        [self.view addSubview:_sleepTimerContainer];
-    }
-
     if (!_playbackSpeedViewHidden)
         self.playbackSpeedView.hidden = _playbackSpeedViewHidden = YES;