Skip to content

Instantly share code, notes, and snippets.

View rodericj's full-sized avatar
🐔
chicken

Roderic Campbell rodericj

🐔
chicken
View GitHub Profile
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
// The only header is in the first section
if (section != DeviceSettingsTableViewControllerSectionDeviceSettings) {
return [[UIView alloc] initWithFrame:CGRectZero];
}
// If we've already created this headerView, return it, it should never change
if (self.headerView) {
return self.headerView;
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
// The only header is in the first section
if (section != DeviceSettingsTableViewControllerSectionDeviceSettings) {
return [[UIView alloc] initWithFrame:CGRectZero];
}
// If we've already created this headerView, return it, it should never change
if (self.headerView) {
return self.headerView;
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
NSLog(@"section is %d", section);
if (section != DeviceSettingsTableViewControllerSectionDeviceSettings) {
return [[UIView alloc] initWithFrame:CGRectZero];
}
if (self.headerView) {
return self.headerView;
}
// When the connection state changes, update the label's color
RAC(headerView.batteryLabel, textColor) = [connectedStateSignal map:^id(id deviceConnectedState) {
return [deviceConnectedState integerValue] == MorseDeviceConnectedStateConnected ? [AVHexColor colorWithHex:0x666666] : [AVHexColor colorWithHex:0xF26322];
}];
// Make sure that we can see all of our associated devices
NSSet * associatedDeviceIDs = [MorseUser currentUser].associatedDevices;
[associatedDeviceIDs map:^(NSString * input)
{
return input.lowercaseString;
}];
NSSet * nearbyDeviceIDs = [[tempNearby allKeys] asSet];
if(![associatedDeviceIDs isSubsetOfSet:nearbyDeviceIDs])
{
for(NSString * deviceID in associatedDeviceIDs)
ATAssociatedDevicesNotSeen
UIView *wrapper = [UIView autoLayoutView];
[wrapper constrainToWidth:300];
self.textSubtextPairs = @[@{@"label": @"abcde",
@"detail": @"Bacon ipsum dolor sit amet sausage shank ball tip jowl shoulder spare ribs prosciutto leberkas sirloin pork cow bacon beef. Bacon drumstick tongue shank. Pancetta ribeye doner andouille tri-tip sirloin t-bone tenderloin sausage bacon. Ball tip salami pig frankfurter bacon meatloaf turkey ribeye boudin t-bone corned beef short ribs short loin tongue tenderloin. Meatball turducken swine kielbasa rump prosciutto doner, short ribs boudin shankle jowl shank pig short loin. Prosciutto drumstick pork belly shank meatball. Jowl frankfurter swine, spare ribs landjaeger strip steak flank t-bone ribeye ground round meatball kevin boudin leberkas.",
@"color" : [UIColor redColor]},
@{@"label": @"cdef",
@"deta
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
...
...
// When the gain changes
RACSignal *gainChangeSignal = [RACObserve(self, device.gain) deliverOn:[RACScheduler mainThreadScheduler]];
// cell.auxiliaryLabel.text = @" ";
RAC(cell.auxiliaryLabel, text) = [gainChangeSignal map:^id(id value) {
// Get the gain lookup table
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
- (void)viewDidLoad
{
[super viewDidLoad];
DeviceSettingsHeaderView *headerView = [[DeviceSettingsHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, DEVICE_HEADER_HEIGHT)];
[RACObserve(self, device) subscribeNext:^(MorseDevice *newDevice) {
// When the battery level changes, update the string
RACSignal *batteryChangeSignal = RACObserve(newDevice, batteryLevel);
DeviceSettingsHeaderView *headerView = [[DeviceSettingsHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, DEVICE_HEADER_HEIGHT)];
+
+ [RACObserve(self, device) subscribeNext:^(MorseDevice *newDevice) {
+
+ // When the battery level changes, update the string
+ RACSignal *batteryChangeSignal = RACObserve(newDevice, batteryLevel);
+ RAC(headerView.batteryAndWifiLabel, text) = [[batteryChangeSignal deliverOn:[RACScheduler mainThreadScheduler]] map:^id(id value) {
+
+ return [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"battery is at", nil), newDevice.batteryLevelString];
+ }];