Initial commit

This commit is contained in:
NightBits
2018-12-19 20:42:46 +01:00
parent 55baa9dae1
commit 0891cd8242
48 changed files with 3236 additions and 2 deletions

BIN
EonaCatTools/Tools/Popup/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,25 @@
//
// Popup.h
// Created by EonaCat
// Copyright 2013 EonaCat. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Popup : NSObject
{
NSTimer *_notificationTimer;
UILabel *_target;
UIColor *_targetOldBackgroundColor;
UIColor *_targetOldTextColor;
NSString *_targetText;
UIAlertView *_alert;
}
-(void)showAlert:(NSString*)title message:(NSString*)message delegate:(id)delegate cancelButtonText:(NSString*)cancelButtonText otherButtonText:(NSString*)otherButtonText tag:(NSInteger)tag;
-(void)showDebugNotification:(NSString*)message textColor:(UIColor*)textColor backgroundColor:(UIColor*)backgroundColor target:(UILabel*)target;
-(void)dismiss;
+ (id)getInstance;
@end

View File

@@ -0,0 +1,83 @@
//
// Popup.m
// Created by EonaCat
// Copyright 2013 EonaCat. All rights reserved.
//
#import "Popup.h"
@implementation Popup
static Popup *_instance;
+ (id)getInstance
{
@synchronized(self)
{
if (_instance == nil)
{
_instance = [[self alloc] init];
}
}
return _instance;
}
-(void)showAlert:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonText:(NSString *)cancelButtonText otherButtonText:(NSString *)otherButtonText tag:(NSInteger)tag
{
_alert = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:delegate
cancelButtonTitle:[cancelButtonText length] == 0 ? nil : cancelButtonText
otherButtonTitles:[otherButtonText length] == 0 ? nil : otherButtonText,nil];
_alert.tag = tag;
[_alert show];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[_alert addGestureRecognizer:singleTap];
}
-(void)handleSingleTap:(UITapGestureRecognizer *)sender
{
[_alert dismissWithClickedButtonIndex:0 animated:YES];
}
-(void)dismiss
{
[_alert dismissWithClickedButtonIndex:0 animated:true];
}
-(void)showDebugNotification:(NSString *)message textColor:(UIColor *)textColor backgroundColor:(UIColor *)backgroundColor target:(UILabel *)target
{
_target = target;
_targetOldBackgroundColor = target.backgroundColor;
_targetOldTextColor = target.textColor;
_targetText = target.text;
target.textColor = textColor;
target.backgroundColor = backgroundColor;
target.text = message;
_notificationTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(debugNotificationTimeElapsed:) userInfo:nil repeats:NO];
}
- (void)debugNotificationTimeElapsed:(NSTimer*)timer
{
@try
{
UILabel *target = _target;
target.backgroundColor = _targetOldBackgroundColor;
target.textColor = _targetOldTextColor;
target.text = _targetText;
[_notificationTimer invalidate];
}
@catch (NSException *exception)
{
NSLog(@"DebugNotificationError: %@",exception.description);
}
}
@end