| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/showcase/content_suggestions/sc_content_suggestions_data_source.h" | 5 #import "ios/showcase/content_suggestions/sc_content_suggestions_data_source.h" |
| 6 | 6 |
| 7 #include "components/strings/grit/components_strings.h" | 7 #include "components/strings/grit/components_strings.h" |
| 8 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink
.h" | 8 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink
.h" |
| 9 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet
cher.h" | 9 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet
cher.h" |
| 10 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion
_identifier.h" | 10 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion
_identifier.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 brightness:drand48() / 2 + 0.5 | 169 brightness:drand48() / 2 + 0.5 |
| 170 alpha:1.0]; | 170 alpha:1.0]; |
| 171 | 171 |
| 172 NSString* monogram = | 172 NSString* monogram = |
| 173 [NSString stringWithFormat:@"%c", arc4random_uniform(26) + 'A']; | 173 [NSString stringWithFormat:@"%c", arc4random_uniform(26) + 'A']; |
| 174 UIColor* textColor = | 174 UIColor* textColor = |
| 175 drand48() > 0.5 ? [UIColor whiteColor] : [UIColor blackColor]; | 175 drand48() > 0.5 ? [UIColor whiteColor] : [UIColor blackColor]; |
| 176 | 176 |
| 177 return [FaviconAttributes attributesWithMonogram:monogram | 177 return [FaviconAttributes attributesWithMonogram:monogram |
| 178 textColor:textColor | 178 textColor:textColor |
| 179 backgroundColor:backgroundColor]; | 179 backgroundColor:backgroundColor |
| 180 defaultBackgroundColor:NO]; |
| 180 } | 181 } |
| 181 | 182 |
| 182 // Returns a random date between now and three days before now. | 183 // Returns a random date between now and three days before now. |
| 183 - (NSDate*)randomDate { | 184 - (NSDate*)randomDate { |
| 184 int offset = arc4random_uniform(259200); | 185 int offset = arc4random_uniform(259200); |
| 185 return [NSDate dateWithTimeIntervalSinceNow:-offset]; | 186 return [NSDate dateWithTimeIntervalSinceNow:-offset]; |
| 186 } | 187 } |
| 187 | 188 |
| 188 // Returns an article with the fields set except the IDInSection. | 189 // Returns an article with the fields set except the IDInSection. |
| 189 - (SCContentSuggestionsItem*)article { | 190 - (SCContentSuggestionsItem*)article { |
| 190 SCContentSuggestionsItem* suggestion = | 191 SCContentSuggestionsItem* suggestion = |
| 191 [[SCContentSuggestionsItem alloc] initWithType:0]; | 192 [[SCContentSuggestionsItem alloc] initWithType:0]; |
| 192 suggestion.title = @"Title"; | 193 suggestion.title = @"Title"; |
| 193 suggestion.subtitle = @"Subtitle for this greeeeeaaaaaat suggestion!"; | 194 suggestion.subtitle = @"Subtitle for this greeeeeaaaaaat suggestion!"; |
| 194 suggestion.publisher = @"Publisher of the new"; | 195 suggestion.publisher = @"Publisher of the new"; |
| 195 suggestion.hasImage = YES; | 196 suggestion.hasImage = YES; |
| 196 suggestion.publishDate = [self randomDate]; | 197 suggestion.publishDate = [self randomDate]; |
| 197 suggestion.attributes = [self randomColorFaviconAttributes]; | 198 suggestion.attributes = [self randomColorFaviconAttributes]; |
| 198 suggestion.suggestionIdentifier = [[ContentSuggestionIdentifier alloc] init]; | 199 suggestion.suggestionIdentifier = [[ContentSuggestionIdentifier alloc] init]; |
| 199 suggestion.suggestionIdentifier.sectionInfo = self.articleSection; | 200 suggestion.suggestionIdentifier.sectionInfo = self.articleSection; |
| 200 return suggestion; | 201 return suggestion; |
| 201 } | 202 } |
| 202 | 203 |
| 203 @end | 204 @end |
| OLD | NEW |