Files
transshift/TransmissionRPCClient/WaitViewController.m
Alexey Chechetkin f322eea442 Updated to Xcode 9.0
2017-09-25 11:02:55 +03:00

74 lines
1.5 KiB
Objective-C

//
// WaitViewController.m
// TransmissionRPCClient
//
// Created by Alexey Chechetkin on 21.04.16.
// Copyright © 2016 Alexey Chechetkin. All rights reserved.
//
#import "WaitViewController.h"
@interface WaitViewController ()
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *indicator;
@property (weak, nonatomic) IBOutlet UILabel *labelStatus;
@property (weak, nonatomic) IBOutlet UIImageView *iconStatus;
@property (weak, nonatomic) IBOutlet UILabel *labelTimeout;
@end
@implementation WaitViewController
{
NSTimeInterval _curTick;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear: animated];
if( _statusText )
_labelStatus.text = _statusText;
// start timer if timeout is set
if( _activityTimeout > 0 )
{
_curTick = _activityTimeout;
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerTick:) userInfo:nil repeats:YES];
}
}
- (void)timerTick:(NSTimer *)timer
{
_labelTimeout.text = [NSString stringWithFormat:@"%02ld", (long)_curTick];
_curTick--;
if( _curTick < 0 )
{
[timer invalidate];
}
}
- (void)stopActivity
{
[_indicator stopAnimating];
_labelTimeout.hidden = YES;
_iconStatus.hidden = NO;
}
- (void)setStatusText:(NSString *)statusText
{
_statusText = statusText;
if( _labelStatus )
_labelStatus.text = statusText;
}
@end