mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding favicon_fade for gradient river of news in iphone app.
This commit is contained in:
parent
4ea82f11f9
commit
2e98a334a1
3 changed files with 34 additions and 17 deletions
|
@ -77,8 +77,10 @@ class Feed(models.Model):
|
|||
'updated_seconds_ago': seconds_timesince(self.last_update),
|
||||
'subs': self.num_subscribers,
|
||||
'favicon_color': self.favicon_color,
|
||||
'favicon_fade': self.favicon_fade(),
|
||||
'favicon_fetching': bool(not (self.favicon_not_found or self.favicon_color))
|
||||
}
|
||||
print self.favicon_color, self.favicon_fade()
|
||||
|
||||
if include_favicon:
|
||||
try:
|
||||
|
@ -354,6 +356,17 @@ class Feed(models.Model):
|
|||
self.save_feed_stories_last_month(verbose)
|
||||
# self.save_feed_story_history_statistics()
|
||||
|
||||
def favicon_fade(self):
|
||||
color = self.favicon_color
|
||||
if color:
|
||||
splitter = lambda s, p: [s[i:i+p] for i in range(0, len(s), p)]
|
||||
red, green, blue = splitter(color[:6], 2)
|
||||
fade_red = hex(max(int(red, 16) - 60, 0))[2:].zfill(2)
|
||||
fade_green = hex(max(int(green, 16) - 60, 0))[2:].zfill(2)
|
||||
fade_blue = hex(max(int(blue, 16) - 60, 0))[2:].zfill(2)
|
||||
return "%s%s%s" % (fade_red, fade_green, fade_blue)
|
||||
|
||||
|
||||
def save_feed_stories_last_month(self, verbose=False):
|
||||
month_ago = datetime.datetime.utcnow() - datetime.timedelta(days=30)
|
||||
stories_last_month = MStory.objects(story_feed_id=self.pk,
|
||||
|
|
|
@ -208,7 +208,7 @@
|
|||
<object class="IBUILabel" id="607536273">
|
||||
<reference key="NSNextResponder" ref="247257992"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{172, 65}, {119, 15}}</string>
|
||||
<string key="NSFrame">{{172, 61}, {119, 15}}</string>
|
||||
<reference key="NSSuperview" ref="247257992"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
|
@ -238,7 +238,7 @@
|
|||
<object class="IBUILabel" id="753396836">
|
||||
<reference key="NSNextResponder" ref="247257992"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 28}, {271, 34}}</string>
|
||||
<string key="NSFrame">{{20, 24}, {271, 34}}</string>
|
||||
<reference key="NSSuperview" ref="247257992"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="450494992"/>
|
||||
|
@ -267,7 +267,7 @@
|
|||
<object class="IBUILabel" id="654553903">
|
||||
<reference key="NSNextResponder" ref="247257992"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{43, 2}, {248, 21}}</string>
|
||||
<string key="NSFrame">{{43, -1}, {248, 21}}</string>
|
||||
<reference key="NSSuperview" ref="247257992"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="1001310564"/>
|
||||
|
@ -308,7 +308,7 @@
|
|||
<object class="IBUILabel" id="450494992">
|
||||
<reference key="NSNextResponder" ref="247257992"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{20, 65}, {150, 15}}</string>
|
||||
<string key="NSFrame">{{20, 61}, {150, 15}}</string>
|
||||
<reference key="NSSuperview" ref="247257992"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="607536273"/>
|
||||
|
@ -335,7 +335,7 @@
|
|||
<object class="IBUIImageView" id="1001310564">
|
||||
<reference key="NSNextResponder" ref="247257992"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{2, 37}, {16, 16}}</string>
|
||||
<string key="NSFrame">{{2, 33}, {16, 16}}</string>
|
||||
<reference key="NSSuperview" ref="247257992"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="753396836"/>
|
||||
|
@ -346,7 +346,7 @@
|
|||
<object class="IBUIImageView" id="302108260">
|
||||
<reference key="NSNextResponder" ref="247257992"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{21, 5}, {16, 16}}</string>
|
||||
<string key="NSFrame">{{21, 2}, {16, 16}}</string>
|
||||
<reference key="NSSuperview" ref="247257992"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="654553903"/>
|
||||
|
@ -355,7 +355,7 @@
|
|||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{300, 84}</string>
|
||||
<string key="NSFrameSize">{300, 91}</string>
|
||||
<reference key="NSSuperview" ref="183700415"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="302108260"/>
|
||||
|
@ -367,7 +367,7 @@
|
|||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{320, 85}</string>
|
||||
<string key="NSFrameSize">{320, 92}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="247257992"/>
|
||||
|
@ -377,7 +377,7 @@
|
|||
<int key="IBUIAccessoryType">1</int>
|
||||
<reference key="IBUIContentView" ref="247257992"/>
|
||||
<string key="IBUIReuseIdentifier">RiverFeedDetailCellIdentifier</string>
|
||||
<real value="85" key="IBUIRowHeight"/>
|
||||
<real value="81" key="IBUIRowHeight"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#import "Utilities.h"
|
||||
|
||||
#define kTableViewRowHeight 65;
|
||||
#define kTableViewRiverRowHeight 85;
|
||||
#define kTableViewRiverRowHeight 81;
|
||||
|
||||
@implementation FeedDetailViewController
|
||||
|
||||
|
@ -439,18 +439,22 @@
|
|||
cell.feedFavicon.image = [Utilities getImage:feedIdStr];
|
||||
|
||||
CAGradientLayer *gradient = [CAGradientLayer layer];
|
||||
gradient.frame = CGRectMake(0, 0, cell.frame.size.width, 27);
|
||||
gradient.frame = CGRectMake(0, 0, cell.frame.size.width, 21);
|
||||
unsigned int color = 0;
|
||||
unsigned int colorFade = 0;
|
||||
NSString *favicon_color = [feed objectForKey:@"favicon_color"];
|
||||
if ([favicon_color class] == [NSNull class]) {
|
||||
favicon_color = @"505050";
|
||||
}
|
||||
NSString *red = [favicon_color substringFrom:0 to:2];
|
||||
NSString *green = [favicon_color substringFrom:2 to:4];
|
||||
NSString *blue = [favicon_color substringFrom:4 to:6];
|
||||
NSString *favicon_fade = [feed objectForKey:@"favicon_fade"];
|
||||
if ([favicon_fade class] == [NSNull class]) {
|
||||
favicon_fade = @"303030";
|
||||
}
|
||||
NSScanner *scanner = [NSScanner scannerWithString:favicon_color];
|
||||
[scanner scanHexInt:&color];
|
||||
gradient.colors = [NSArray arrayWithObjects:(id)[UIColorFromRGB(color) CGColor], (id)[[UIColor blackColor] CGColor], nil];
|
||||
NSScanner *scannerFade = [NSScanner scannerWithString:favicon_fade];
|
||||
[scannerFade scanHexInt:&colorFade];
|
||||
gradient.colors = [NSArray arrayWithObjects:(id)[UIColorFromRGB(color) CGColor], (id)[UIColorFromRGB(colorFade) CGColor], nil];
|
||||
if (isStoryRead) {
|
||||
gradient.opacity = .15;
|
||||
}
|
||||
|
@ -466,7 +470,7 @@
|
|||
cell.storyDate.textColor = [UIColor colorWithRed:0.14f green:0.18f blue:0.42f alpha:1.0];
|
||||
cell.storyDate.font = [UIFont fontWithName:@"Helvetica-Bold" size:10];
|
||||
cell.storyUnreadIndicator.alpha = 1;
|
||||
cell.feedTitle.textColor = [UIColor colorWithRed:0.58f green:0.58f blue:0.58f alpha:1.0];
|
||||
cell.feedTitle.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1.0];
|
||||
cell.feedTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:11];
|
||||
|
||||
cell.feedFavicon.alpha = 1;
|
||||
|
@ -479,7 +483,7 @@
|
|||
cell.storyDate.textColor = [UIColor colorWithRed:0.14f green:0.18f blue:0.42f alpha:0.5];
|
||||
cell.storyDate.font = [UIFont fontWithName:@"Helvetica" size:10];
|
||||
cell.storyUnreadIndicator.alpha = 0.15f;
|
||||
cell.feedTitle.textColor = [UIColor colorWithRed:0.4f green:0.4f blue:0.4f alpha:0.7];
|
||||
cell.feedTitle.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
|
||||
cell.feedTitle.font = [UIFont fontWithName:@"Helvetica" size:11];
|
||||
cell.feedFavicon.alpha = 0.5f;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue