Commit 124ad622 authored by Tobias's avatar Tobias

add delete hint view to remote playback view controller which shows how files...

add delete hint view to remote playback view controller which shows how files can be deleted once they wiggle
parent d57ea10d
{
"images" : [
{
"idiom" : "tv",
"filename" : "PlayPauseButton.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
\ No newline at end of file
/*****************************************************************************
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Tobias Conradi <videolan # tobias-conradi.de>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface VLCDeleteHintTVView : UIView
@property (nonatomic) UIVisualEffectView *effectView;
@property (nonatomic) UILabel *leadingLabel;
@property (nonatomic) UIImageView *glyphImageView;
@property (nonatomic) UILabel *trailingLabel;
@end
/*****************************************************************************
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Tobias Conradi <videolan # tobias-conradi.de>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCDeleteHintTVView.h"
@implementation VLCDeleteHintTVView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self sharedSetup];
}
return self;
}
- (void)awakeFromNib
{
[super awakeFromNib];
[self sharedSetup];
}
- (void)prepareForInterfaceBuilder
{
[super prepareForInterfaceBuilder];
[self sharedSetup];
}
- (void)sharedSetup
{
self.backgroundColor = nil;
/*
* Views
*/
UIVisualEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
effectView.frame = self.bounds;
effectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
effectView.layer.cornerRadius = 5.0;
effectView.clipsToBounds = YES;
[self addSubview:effectView];
self.effectView = effectView;
UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
UIColor *textColor = [UIColor whiteColor];
UILabel *leadingLabel = [[UILabel alloc] initWithFrame:CGRectZero];
leadingLabel.translatesAutoresizingMaskIntoConstraints = NO;
leadingLabel.font = font;
leadingLabel.textColor = textColor;
[self addSubview:leadingLabel];
self.leadingLabel = leadingLabel;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlayPauseRemoteButton"]];
imageView.translatesAutoresizingMaskIntoConstraints = NO;
imageView.tintColor = textColor;
[self addSubview:imageView];
self.glyphImageView = imageView;
UILabel *trailingLabel = [[UILabel alloc] initWithFrame:CGRectZero];
trailingLabel.translatesAutoresizingMaskIntoConstraints = NO;
trailingLabel.font = font;
trailingLabel.textColor = textColor;
[self addSubview:trailingLabel];
self.trailingLabel = trailingLabel;
/*
* Content
*/
NSString *localizedString = NSLocalizedString(@"DELETE_ITEM_HINT", @"Insert %@ where play-pause-glyph should be placed");
NSArray *strings = [localizedString componentsSeparatedByString:@"%@"];
NSCharacterSet *trimmSet = [NSCharacterSet whitespaceCharacterSet];
leadingLabel.text = [strings.firstObject stringByTrimmingCharactersInSet:trimmSet];
if (strings.count > 1) {
trailingLabel.text = [strings.lastObject stringByTrimmingCharactersInSet:trimmSet];
}
/*
* Constraints
*/
NSMutableArray<NSLayoutConstraint*> *constraints = [NSMutableArray array];
// label margins
const CGFloat sideMargin = -60.0;
[constraints addObject:[self.leadingAnchor constraintEqualToAnchor:leadingLabel.leadingAnchor constant:sideMargin]];
[constraints addObject:[trailingLabel.trailingAnchor constraintEqualToAnchor:self.trailingAnchor constant:sideMargin]];
// image margins
const CGFloat imageMargin = -16.0;
[constraints addObject:[leadingLabel.trailingAnchor constraintEqualToAnchor:imageView.leadingAnchor constant:imageMargin]];
[constraints addObject:[imageView.trailingAnchor constraintEqualToAnchor:trailingLabel.leadingAnchor constant:imageMargin]];
[constraints addObject:[self.topAnchor constraintEqualToAnchor:imageView.topAnchor constant:imageMargin]];
[constraints addObject:[self.bottomAnchor constraintEqualToAnchor:imageView.bottomAnchor constant:-imageMargin]];
// vertical alignment
[constraints addObject:[leadingLabel.centerYAnchor constraintEqualToAnchor:imageView.centerYAnchor]];
[constraints addObject:[imageView.centerYAnchor constraintEqualToAnchor:trailingLabel.centerYAnchor]];
[self addConstraints:constraints];
}
@end
......@@ -19,6 +19,7 @@
@property (readwrite, nonatomic, weak) IBOutlet UILabel *cachedMediaLabel;
@property (readwrite, nonatomic, weak) IBOutlet UICollectionView *cachedMediaCollectionView;
@property (nonatomic, weak) IBOutlet UIView *deleteHintView;
- (IBAction)toggleHTTPServer:(id)sender;
......
......@@ -30,6 +30,8 @@ static NSString *const VLCWiggleAnimationKey = @"VLCWiggleAnimation";
@property (nonatomic) UITapGestureRecognizer *playPausePressRecognizer;
@property (nonatomic) UITapGestureRecognizer *cancelRecognizer;
@property (nonatomic) NSIndexPath *currentlyFocusedIndexPath;
@property (nonatomic) NSTimer *hintTimer;
@end
@implementation VLCRemotePlaybackViewController
......@@ -156,6 +158,7 @@ static NSString *const VLCWiggleAnimationKey = @"VLCWiggleAnimation";
[[NSUserDefaults standardUserDefaults] synchronize];
}
#pragma mark - editing
- (void)handlePlayPausePress
{
......@@ -207,6 +210,47 @@ static NSString *const VLCWiggleAnimationKey = @"VLCWiggleAnimation";
}
- (void)animateDeletHintToVisibility:(BOOL)visible
{
const NSTimeInterval duration = 0.5;
UIView *hintView = self.deleteHintView;
if (hintView.hidden) {
hintView.alpha = 0.0;
}
if (hintView.alpha == 0.0) {
hintView.hidden = NO;
}
const CGFloat targetAlpha = visible ? 1.0 : 0.0;
[UIView animateWithDuration:duration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
hintView.alpha = targetAlpha;
}
completion:^(BOOL finished) {
if (hintView.alpha == 0.0) {
hintView.hidden = YES;
}
}];
}
- (void)hintTimerFired:(NSTimer *)timer
{
const NSTimeInterval waitUntilHideInterval = 5.0;
NSNumber *userInfo = [timer userInfo];
BOOL shouldShow = [userInfo isKindOfClass:[NSNumber class]] && [userInfo boolValue];
[self animateDeletHintToVisibility:shouldShow];
if (shouldShow) {
[self.hintTimer invalidate];
self.hintTimer = [NSTimer scheduledTimerWithTimeInterval:waitUntilHideInterval target:self selector:@selector(hintTimerFired:) userInfo:@(NO) repeats:NO];
}
}
- (void)startEditMode
{
self.editing = YES;
......@@ -225,8 +269,13 @@ static NSString *const VLCWiggleAnimationKey = @"VLCWiggleAnimation";
if (editing) {
[focusedCell.layer addAnimation:[CAAnimation vlc_wiggleAnimation]
forKey:VLCWiggleAnimationKey];
[self.hintTimer invalidate];
self.hintTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(hintTimerFired:) userInfo:@(YES) repeats:NO];
} else {
[focusedCell.layer removeAnimationForKey:VLCWiggleAnimationKey];
[self.hintTimer invalidate];
self.hintTimer = nil;
[self animateDeletHintToVisibility:NO];
}
self.cancelRecognizer.enabled = editing;
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCRemotePlaybackViewController">
<connections>
<outlet property="cachedMediaCollectionView" destination="VjG-Gw-i36" id="ATe-7D-fDz"/>
<outlet property="cachedMediaLabel" destination="77q-qM-GSv" id="gs2-sW-Z17"/>
<outlet property="deleteHintView" destination="Hxr-bA-eu2" id="04c-3W-B8K"/>
<outlet property="httpServerLabel" destination="mOM-K1-6hX" id="PvM-0r-xq1"/>
<outlet property="toggleHTTPServerButton" destination="N4Q-4c-bh0" id="5Je-Lj-ba0"/>
<outlet property="view" destination="iN0-l3-epB" id="Eym-vH-oyN"/>
......@@ -58,6 +59,10 @@ http://192.168.1.1</string>
<outlet property="delegate" destination="-1" id="hUM-OV-Y9o"/>
</connections>
</collectionView>
<view hidden="YES" contentMode="scaleToFill" placeholderIntrinsicWidth="550" placeholderIntrinsicHeight="100" translatesAutoresizingMaskIntoConstraints="NO" id="Hxr-bA-eu2" customClass="VLCDeleteHintTVView">
<rect key="frame" x="685" y="930" width="550" height="100"/>
<animations/>
</view>
</subviews>
<animations/>
<constraints>
......@@ -67,7 +72,9 @@ http://192.168.1.1</string>
<constraint firstItem="mOM-K1-6hX" firstAttribute="top" secondItem="N4Q-4c-bh0" secondAttribute="bottom" constant="36" id="Szw-br-TIc"/>
<constraint firstItem="77q-qM-GSv" firstAttribute="centerX" secondItem="VjG-Gw-i36" secondAttribute="centerX" id="Tcb-Jy-an4"/>
<constraint firstItem="N4Q-4c-bh0" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="VFF-HR-rhV"/>
<constraint firstAttribute="bottom" secondItem="Hxr-bA-eu2" secondAttribute="bottom" constant="50" id="XV3-Ye-FV9"/>
<constraint firstItem="VjG-Gw-i36" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="hSa-3P-bGw"/>
<constraint firstItem="Hxr-bA-eu2" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="iND-1n-gnL"/>
<constraint firstItem="VjG-Gw-i36" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="l72-n9-cwb"/>
<constraint firstAttribute="trailing" secondItem="VjG-Gw-i36" secondAttribute="trailing" id="lJF-jb-gaz"/>
<constraint firstItem="VjG-Gw-i36" firstAttribute="top" secondItem="77q-qM-GSv" secondAttribute="bottom" constant="70" id="nNF-vd-238"/>
......
B"CHOOSE_AUDIO_TRACK"="Audiospur wählen";
......
......@@ -306,3 +306,6 @@
"FTP_LONG"="File Transfer Protocol (FTP)";
"FTP_SHORT"="FTP";
// Insert %@ where play-pause-glyph should be placed
"DELETE_ITEM_HINT"="Press %@ to Delete";
......@@ -371,6 +371,7 @@
DD8095F61BE624C00065D8E1 /* VLCPlaybackInfoTVAnimators.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8095F51BE624C00065D8E1 /* VLCPlaybackInfoTVAnimators.m */; };
DD8095F91BE6268A0065D8E1 /* VLCPlaybackInfoPanelTVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8095F81BE6268A0065D8E1 /* VLCPlaybackInfoPanelTVViewController.m */; };
DD8F84311B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8F84301B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m */; };
DD9D8F5F1C00C73F00B4060F /* VLCDeleteHintTVView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD9D8F5E1C00C73F00B4060F /* VLCDeleteHintTVView.m */; };
DDAD5C2B1BB999CA006AFD3B /* VLCMovieViewControlPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDAD5C2A1BB999CA006AFD3B /* VLCMovieViewControlPanel.xib */; };
DDB7C6A41BAEB28200E6570E /* WKInterfaceController+VLCConnectionAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = DD9FBE761BAD6BB600FFE77A /* WKInterfaceController+VLCConnectionAlert.m */; };
DDB959421AFBB30500BB8CFF /* MappingModel_2_5_to_2_6.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = DDB959411AFBB30500BB8CFF /* MappingModel_2_5_to_2_6.xcmappingmodel */; };
......@@ -1121,6 +1122,8 @@
DD8C8FAE1B676D8500B3C4EE /* VLC WatchKit Extension-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "VLC WatchKit Extension-Bridging-Header.h"; sourceTree = "<group>"; };
DD8F842F1B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "VLCPlaybackController+MediaLibrary.h"; path = "Sources/VLCPlaybackController+MediaLibrary.h"; sourceTree = SOURCE_ROOT; };
DD8F84301B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "VLCPlaybackController+MediaLibrary.m"; path = "Sources/VLCPlaybackController+MediaLibrary.m"; sourceTree = SOURCE_ROOT; };
DD9D8F5D1C00C73F00B4060F /* VLCDeleteHintTVView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCDeleteHintTVView.h; sourceTree = "<group>"; };
DD9D8F5E1C00C73F00B4060F /* VLCDeleteHintTVView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCDeleteHintTVView.m; sourceTree = "<group>"; };
DD9FBE751BAD6BB600FFE77A /* WKInterfaceController+VLCConnectionAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WKInterfaceController+VLCConnectionAlert.h"; sourceTree = "<group>"; };
DD9FBE761BAD6BB600FFE77A /* WKInterfaceController+VLCConnectionAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WKInterfaceController+VLCConnectionAlert.m"; sourceTree = "<group>"; };
DD9FBE791BADA8E300FFE77A /* VLC WatchKit Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "VLC WatchKit Extension.entitlements"; path = "../VLC WatchKit Extension.entitlements"; sourceTree = "<group>"; };
......@@ -1997,6 +2000,8 @@
DD3EABE81BE13D5B003668DA /* VLCRemoteBrowsingTVCell.m */,
7D1A2DAF1BF66335002E0962 /* VLCMDFBrowsingArtworkProvider.h */,
7D1A2DB01BF66335002E0962 /* VLCMDFBrowsingArtworkProvider.m */,
DD9D8F5D1C00C73F00B4060F /* VLCDeleteHintTVView.h */,
DD9D8F5E1C00C73F00B4060F /* VLCDeleteHintTVView.m */,
);
name = "Common Code";
sourceTree = "<group>";
......@@ -2894,6 +2899,7 @@
7D0EDE061BE774BF00363AA1 /* WhiteRaccoon.m in Sources */,
DD13A37B1BEE2FAA00A35554 /* VLCMaskView.m in Sources */,
7DF383AC1BF206F100D71A5C /* VLCRemoteBrowsingCollectionViewController.m in Sources */,
DD9D8F5F1C00C73F00B4060F /* VLCDeleteHintTVView.m in Sources */,
7D405ED01BEA11C1006ED886 /* VLCHTTPConnection.m in Sources */,
DD490B1F1BE95B5C0010F335 /* VLCSiriRemoteGestureRecognizer.m in Sources */,
DD3EFF3C1BDEBCE500B68579 /* VLCNetworkServerBrowserVLCMedia.m in Sources */,
......
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