Bokmark changes
This commit is contained in:
parent
3e1581e28e
commit
0fe8d98538
@ -408,7 +408,51 @@
|
|||||||
loadObject.responseJSON = jsonDictionary;
|
loadObject.responseJSON = jsonDictionary;
|
||||||
|
|
||||||
// Store the new page data if we didn't load page data from the cache.
|
// Store the new page data if we didn't load page data from the cache.
|
||||||
NSDictionary *pageJSON = [jsonDictionary objectForKey:KeyPage ofType:[NSDictionary class]];
|
|
||||||
|
//MARK: Temp code for bookmark test
|
||||||
|
NSMutableDictionary *mutablepageJSON = [NSMutableDictionary dictionaryWithDictionary:[jsonDictionary dict:KeyPage]];
|
||||||
|
if ([@"myFeed" isEqualToString:[mutablepageJSON string:KeyPageType]]) {
|
||||||
|
NSMutableDictionary *navigationBar = [NSMutableDictionary dictionaryWithDictionary:mutablepageJSON[@"navigationBar"]];
|
||||||
|
navigationBar[@"pattern"] = @"ABookmark";
|
||||||
|
mutablepageJSON[@"navigationBar"] = navigationBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *KeyBookmarkName = @"bookmarkName";
|
||||||
|
NSString *KeyBrowserUrl = @"browserUrl";
|
||||||
|
NSArray *bookMarkEligiblePageTypes = @[@{KeyBookmarkName: @"feedback", KeyPageType: @"selectFeedbackSource"}, @{KeyBookmarkName: @"perks", KeyPageType: @"webPunchOut_UAD", KeyBrowserUrl: @"https://www.verizon.com/digital/nsa/secure/ui/products/producthub/home?intcmp=uad-screen&tabbar=true"}, @{KeyBookmarkName: @"plans", KeyPageType: @"webPunchOut_UAD", KeyBrowserUrl: @"https://www.verizon.com/digital/nsa/secure/ui/cpc/mvm?pmd=y&tabbar=true&intcmp=uad-screen&tabbar=true"}];
|
||||||
|
|
||||||
|
for (NSDictionary *bookmark in bookMarkEligiblePageTypes) {
|
||||||
|
if ([[bookmark string:KeyPageType] isEqualToString:[mutablepageJSON string:KeyPageType]]) {
|
||||||
|
NSString *browserUrl = [bookmark string:KeyBrowserUrl];
|
||||||
|
if (browserUrl) {
|
||||||
|
if ([browserUrl isEqualToString:[mutablepageJSON string:KeyBrowserUrl]]) {
|
||||||
|
mutablepageJSON[KeyBookmarkName] = [bookmark string:KeyBookmarkName];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mutablepageJSON[KeyBookmarkName] = [bookmark string:KeyBookmarkName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Bookmarks list
|
||||||
|
if ([@"bookmark" isEqualToString:[mutablepageJSON string:KeyPageType]]) {
|
||||||
|
NSDictionary *noBookmarksMolecule = @{@"moleculeName": @"listItem", @"molecule": @{@"moleculeName": @"label", @"text": @"No saved bookmarks"}};
|
||||||
|
|
||||||
|
NSArray *jsonBookmarks = [mutablepageJSON array:@"molecules"];
|
||||||
|
NSMutableArray *newBookmarksArray = [NSMutableArray new];
|
||||||
|
NSArray *ud_bookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:@"savedBookmarks"];
|
||||||
|
for (NSDictionary *bookmark in jsonBookmarks) {
|
||||||
|
if ([ud_bookmarks containsObject:[bookmark string:@"bookmarkName"]]) {
|
||||||
|
[newBookmarksArray addObject:bookmark];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newBookmarksArray.count == 0) {
|
||||||
|
[newBookmarksArray addObject:noBookmarksMolecule];
|
||||||
|
}
|
||||||
|
mutablepageJSON[@"molecules"] = newBookmarksArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *pageJSON = [NSDictionary dictionaryWithDictionary:mutablepageJSON];
|
||||||
if (!loadObject.pageDataFromCache) {
|
if (!loadObject.pageDataFromCache) {
|
||||||
loadObject.pageJSON = pageJSON;
|
loadObject.pageJSON = pageJSON;
|
||||||
loadObject.pageType = [pageJSON string:KeyPageType];
|
loadObject.pageType = [pageJSON string:KeyPageType];
|
||||||
@ -431,7 +475,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adds the modules received from server to any modules we grabbed from the cache.
|
// Adds the modules received from server to any modules we grabbed from the cache.
|
||||||
NSDictionary *modules = [jsonDictionary dict:KeyModuleMap];
|
NSMutableDictionary *tempModules = [NSMutableDictionary dictionaryWithDictionary:[jsonDictionary dict:KeyModuleMap]];
|
||||||
|
if ([@"myFeed" isEqualToString:loadObject.pageType]) {
|
||||||
|
NSMutableDictionary *patterns = [NSMutableDictionary dictionaryWithDictionary:[tempModules dict: @"navigationPatterns"]];
|
||||||
|
NSMutableDictionary *patternA = [NSMutableDictionary dictionaryWithDictionary:[patterns dict:@"A"]];
|
||||||
|
NSMutableArray *additionalRightButtons = [NSMutableArray arrayWithArray:[patternA arrayForKey:@"additionalRightButtons"]];
|
||||||
|
[additionalRightButtons insertObject:@{@"accessibilityText" : @"Bookmarks", @"moleculeName" : @"navigationImageButton", @"image" : @"star.fill", @"action" : @{
|
||||||
|
@"analyticsData" : @{
|
||||||
|
@"vzdl.page.linkName" : @"global monarch nav: vz icon"
|
||||||
|
},
|
||||||
|
@"actionType" : @"openPage",
|
||||||
|
@"pageType": @"bookmarks"
|
||||||
|
}} atIndex:0];
|
||||||
|
patternA[@"additionalRightButtons"] = additionalRightButtons;
|
||||||
|
patterns[@"ABookmark"] = patternA;
|
||||||
|
tempModules[@"navigationPatterns"] = patterns;
|
||||||
|
[tempModules addEntriesFromDictionary:@{@"bookmark": @{@"bookmarkAction": @{KeyActionType: KeyActionTypeOpen, KeyPageType: @"saveBookmark"}, @"bookmarks": @[@{@"bookmarkName": @"plans", @"bookmarked": @YES, KeyBrowserUrl: @"https://www.verizon.com/digital/nsa/secure/ui/cpc/mvm?pmd=y&tabbar=true&intcmp=uad-screen&tabbar=true"}, @{@"bookmarkName": @"perks", @"bookmarked": @NO, KeyBrowserUrl: @"https://www.verizon.com/digital/nsa/secure/ui/products/producthub/home?intcmp=uad-screen&tabbar=true"}]}}];
|
||||||
|
}
|
||||||
|
NSDictionary *modules = [NSDictionary dictionaryWithDictionary:tempModules];
|
||||||
if (loadObject.modulesJSON && modules) {
|
if (loadObject.modulesJSON && modules) {
|
||||||
NSMutableDictionary *mutableModules = [NSMutableDictionary dictionaryWithDictionary:loadObject.modulesJSON];
|
NSMutableDictionary *mutableModules = [NSMutableDictionary dictionaryWithDictionary:loadObject.modulesJSON];
|
||||||
[mutableModules addEntriesFromDictionary:modules];
|
[mutableModules addEntriesFromDictionary:modules];
|
||||||
|
|||||||
@ -518,6 +518,11 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!image) {
|
||||||
|
image = [UIImage systemImageNamed:imageName];
|
||||||
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user