This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
441 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// HVStatusLabel.h | ||
// SDKFeatures | ||
// | ||
// Copyright (c) 2013 Microsoft Corporation. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface HVStatusLabel : UILabel | ||
{ | ||
@private | ||
UIActivityIndicatorView* m_activity; | ||
} | ||
|
||
-(void) showStatus:(NSString *) format, ...; | ||
-(void) clearStatus; | ||
-(void) showActivity; | ||
-(void) hideActivity; | ||
|
||
-(void) showBusy; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// | ||
// HVStatusLabel.m | ||
// SDKFeatures | ||
// | ||
// Copyright (c) 2013 Microsoft Corporation. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "HVStatusLabel.h" | ||
|
||
@interface HVStatusLabel (HVPrivate) | ||
|
||
-(void) ensureSpinner; | ||
|
||
@end | ||
|
||
@implementation HVStatusLabel | ||
|
||
-(void)dealloc | ||
{ | ||
[m_activity release]; | ||
[super dealloc]; | ||
} | ||
|
||
-(void)showStatus:(NSString *)format, ... | ||
{ | ||
va_list args; | ||
va_start(args, format); | ||
|
||
NSLogv(format, args); | ||
NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; | ||
|
||
va_end(args); | ||
|
||
self.text = message; | ||
[message release]; | ||
|
||
[self hideActivity]; | ||
} | ||
|
||
-(void)clearStatus | ||
{ | ||
self.text = nil; | ||
[self hideActivity]; | ||
} | ||
|
||
-(void)showActivity | ||
{ | ||
[self ensureSpinner]; | ||
[m_activity setHidden:FALSE]; | ||
[m_activity startAnimating]; | ||
} | ||
|
||
-(void)hideActivity | ||
{ | ||
if (m_activity) | ||
{ | ||
[m_activity stopAnimating]; | ||
[m_activity setHidden:TRUE]; | ||
} | ||
} | ||
|
||
-(void)showBusy | ||
{ | ||
[self showStatus:@"Working. Please wait..."]; | ||
[self showActivity]; | ||
} | ||
|
||
@end | ||
|
||
@implementation HVStatusLabel (HVPrivate) | ||
|
||
-(void)ensureSpinner | ||
{ | ||
if (m_activity) | ||
{ | ||
return; | ||
} | ||
|
||
m_activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; | ||
|
||
CGRect frame = self.frame; | ||
float side = frame.size.height; // We'll size the spinner so it is a square as tall as this label | ||
|
||
if (self.textAlignment == NSTextAlignmentRight) | ||
{ | ||
frame.origin.x = 0; | ||
} | ||
else | ||
{ | ||
frame.origin.x = frame.size.width - side; | ||
} | ||
frame.origin.y = 0; | ||
frame.size.width = side; | ||
frame.size.height = side; | ||
|
||
[self addSubview:m_activity]; | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.