TorchLight
Overview
With this complete application for Iphone 4G/4S devices you can turn your mobile phone into a flash light.
Application features:
- S.O.S Mode
- Blink with speed settings
- Light on by default
- Hold Button for light
- Sleep Timer
- Double Tap Toggles Screen
- iPhone Retina support
The App is ready for building and uploading into the iTunes store.
TorchLight app uses buttons at the bottom of the screen for user navigation. With first and third button user can switch between SOS mode and Blink mode lighting. Easily turn on and off the light by clicking on the main red button.
"Blink" Mode screen includes a slider that is used to control the blink speed. "Settings" screen allows user to change options:
Light by default by setting this option to ON flash will turn on each time the main view appears
Hold button for light by setting this option to ON user is required to hold ON-part button if he wants to keep flashing.
Double tap toggles screen by setting this option to ON double tap on main view will set it to black color, so that iPhone will appear to be in standby state.
Sleep Time tapping on this switch will present time picker where user can define how long does he want flash to be on, after main view appears.
Please note: light by default and Hold button for light are mutually exclusive in regard to ON states.
Project requires following frameworks:
- AVFoundation.framework
- Foundation.framework
- UIKit.framework
- CoreGraphics.framework
AppDelegate
Application delegate in method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Creates MainViewController that presents main view for application and controls for turning device torch/flash on and off.
MainViewController
MainViewController is main controller that handles most important part of user interaction and feedback. Even it appears that main switch is one control it is actually consisted of two buttons, touching down either one invokes following method:
- (IBAction)onOrOffButtonTouchedDown:(id)sender
While releasing the button invokes:
- (IBAction)onOrOffButtonReleased:(id)sender
If user tapped on ON-part of the composite switch, flashing will occurred, however total flashing duration, speed and repetition depend on current application settings and mode of operation. In case where user tapped on OFF-part of the composite switch, all flashing actions are stopped.
There are three modes or states that are related to device flash.
- Normal mode – Turning on or holding the ON-part button keeps flash constantly on.
- SOS mode – Turning on or holding the ON-part button makes flash fire in pattern that is interpreted as SOS signal in Morse code.
- Blink mode – Turning on or holding the ON-part button makes flash fire in constant intervals, based on current position of slider that is made visible in this mode.
User can switch between different modes by tapping on SOS mode or Blink mode buttons. Both of them invoke following method:
- (IBAction)modeButtonPressed:(id)sender
Each call of this method will adjust mode of operation and cancel flashing actions if there are any.
If user application is currently in Blink mode the blink speed slider will be visible, by moving slider position user will adjust flashing speed, if flash is in ON state. Method called by moving slider:
- (IBAction)valueChangedForSlider:(id)sender
Last visible button is Settings button. Tapping on Settings button will call following method:
- (IBAction)settingsButtonPressed:(id)sender
This method will present Settings View, standard application behaviour can be modified.
SettingsViewController
SettingsViewController presents settings view on which user can modify some of following behaviours:
- Light by default – by setting this option to ON flash will turn on each time the main view appears
- Hold button for light – by setting this option to ON user is required to hold ON-part button if he wants to keep flashing.
- Double tap toggles screen – by setting this option to ON double tap on main view will set it to black color, so that iPhone will appear to be in standby state.
- Sleep Time – tapping on this switch will present time picker where user can define how long does he want flash to be on, after main view appears.
Please note: Light by default and Hold button for light are mutualy exclusive in regard to ON states.
Each of these switches invoke following method:
- (IBAction)switchButtonPressed:(id)sender
TorchController
TorchController is essentially interface class between MainViewController and device hardware. It encapsulates all flashing operations logic within these methods:
- (void)setSleepTime:(int)seconds
- (void)setBlinkSpeed:(float)blinkSpeed
- (void)startSOSMode
- (void)stopSOSMode
By calling setSleepTime: method it's parameter is used to determine time in which flash will be on.
Calling setBlinkSpeed: with blinkSpeed greater than 0 will start flashing, with greater speed as blinkSpeed is closer to 1, while if it is actually 1 flash will be turned on constantly. Duration of this effect in indefinite, and is canceled by calling this method again with blinkSpeed equal to 0.
More item by Chupa Team
RSS reader
Google Maps
Hotel App Template
