UA-17470720-3

Jump to content


Photo
- - - - -

Theming detail view for SCSelectionCell

themes

  • Please log in to reply
5 replies to this topic

#1 vladimir

vladimir

    Starting Out

  • STV 5.0 Pro
  • Pip
  • 5 posts
Reputation: 0
Neutral

Posted 09 March 2016 - 07:45 PM

I'm using STV 5.2.1. Trying to theme all table views into dark style. Here is my theme file:

SCTableViewCell {
    backgroundColor: #132733;
    textLabel.Color: whiteColor;
}

SCTextFieldCell {
    backgroundColor: #132733;
    textLabel.Color: whiteColor;
    textField.textColor: lightGrayColor;
    textField.tintColor: lightGrayColor;
}

SCLabelCell {
    backgroundColor: #132733;
    textLabel.Color: whiteColor;
    label.textColor: lightGrayColor;
}
 

 

I see a problem where detail view for my SCSelectionCell is not completely themed. It appeared properly initially, but when selecting is changed - two things happened: newly selected line gets Blue color (instead of default white) and previous selected line gets Black text. See attached screenshots:

 

Attached File  Simulator Screen Shot Mar 9, 2016, 7.43.48 PM.png   46.62K   9 downloads - initial state of detail view

Attached File  Simulator Screen Shot Mar 9, 2016, 7.43.52 PM.png   45.97K   9 downloads - after selection is changed

 

What else should I add to my theme file to eliminate this? 

 

 



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 09 March 2016 - 08:46 PM

Hi Vladimir,

 

To be able to set this via the theme file, we will need to add a couple of new properties to SCSelectionCell called something like 'selectedCellTextColor' and 'deselectedCellTextColor'. We're releasing an update in about a couple of weeks from now, will that be enough time for you? Alternatively, you can directly modify the cells' color using cellActions.willDisplay.


  • Dave Guerin and wizgod like this

#3 vladimir

vladimir

    Starting Out

  • STV 5.0 Pro
  • Pip
  • 5 posts
Reputation: 0
Neutral

Posted 09 March 2016 - 10:12 PM

Hi Vladimir,

 

To be able to set this via the theme file, we will need to add a couple of new properties to SCSelectionCell called something like 'selectedCellTextColor' and 'deselectedCellTextColor'. We're releasing an update in about a couple of weeks from now, will that be enough time for you? Alternatively, you can directly modify the cells' color using cellActions.willDisplay.

Terek,

 

Thanks for quick reply. Couple weeks is fine, I can wait for the next release. But can you also post a code how to do it in willDisplay? 

 

-

Vladimir



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 10 March 2016 - 11:41 AM

Hi Vladimir,

 

You would actually want to implement both willDisplay and valueChanged. Here is an example from our TasksApp sample (can be optimized of course but you get the general idea):

 

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    SCDataDefinition *taskDef = [self dataDefinitionWithIBName:@"Task"];
    
    SCPropertyDefinition *categoryPDef = [taskDef propertyDefinitionWithName:@"category"];
    categoryPDef.cellActions.willDisplay = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
    {
        SCSelectionCell *selectionCell = (SCSelectionCell *)cell;
        selectionCell.cellActions.detailModelConfigured = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel)
        {
            SCSelectionSection *selectionSection = (SCSelectionSection *)[detailModel sectionAtIndex:0];
            selectionSection.cellActions.willDisplay = ^(SCTableViewCell *detailCell, NSIndexPath *detailCellIndexPath)
            {
                if([selectionSection.selectedItemIndex integerValue] == detailCellIndexPath.row)
                {
                    detailCell.textLabel.textColor = [UIColor orangeColor];  // selected color
                }
                else
                {
                    detailCell.textLabel.textColor = [UIColor greenColor];  // deselected color
                }
            };
            selectionSection.sectionActions.valueChanged = ^(SCTableViewSection *section, NSUInteger sectionIndex)
            {
                for(NSUInteger i=0; i<selectionSection.cellCount; i++)
                {
                    NSIndexPath *detailCellIndexPath = [NSIndexPath indexPathForRow:i inSection:0];
                    SCTableViewCell *detailCell = [selectionSection.ownerTableViewModel.tableView cellForRowAtIndexPath:detailCellIndexPath];
                    if([selectionSection.selectedItemIndex integerValue] == i)
                    {
                        detailCell.textLabel.textColor = [UIColor orangeColor];  // selected color
                    }
                    else
                    {
                        detailCell.textLabel.textColor = [UIColor greenColor];  // deselected color
                    }
                }
            };
        };
    };
}

  • vladimir likes this

#5 vladimir

vladimir

    Starting Out

  • STV 5.0 Pro
  • Pip
  • 5 posts
Reputation: 0
Neutral

Posted 11 March 2016 - 11:36 AM

Thanks a lot. It's a lot of code, but it worked :) Please let me know when it will be available via theme file. 

 

-

Vladimir



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 22 March 2016 - 12:49 PM

This is now available in STV 5.3.0. To implement, simply remove the code I posted above and add the following to your theme file:

 

SCSelectionSection {
selectedCellTextColor: orangeColor;
deselectedCellTextColor: greenColor;
}

 

Hope this helps :)


  • wizgod likes this





Also tagged with one or more of these keywords: themes

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users