<commit_before>// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include "SearchWidgetView.h"
#include "WidgetSearchResultTableViewCell.h"
#include "SearchWidgetMenuContext.h"
#include "WidgetQueryContext.h"
#include "MenuItemModel.h"
#include "ViewController.h"
#include "WidgetSearchResultTableViewCell.h"
#include "ISearchNavigationHandler.h"
#import <WrldSearchWidget/WRLDSearchQuery.h>

namespace ExampleApp
{
    namespace SearchMenu
    {
        namespace View
        {
            SearchWidgetView::SearchWidgetView(WRLDSearchModel* searchModel,
                                               id<WRLDSearchProvider> searchProvider,
                                               id<WRLDSuggestionProvider> suggestionProvider,
                                               bool isNavigationEnabled,
                                               ExampleAppMessaging::TMessageBus& messageBus)
            : m_pSearchModel(searchModel)
            , m_tagCollection(messageBus)
            , m_hasSearchResults(false)
            , m_hasPopulatedData(false)
            , m_isNavigationHidden(!isNavigationEnabled)
            {
                m_pMenuModel = [[WRLDSearchMenuModel alloc] init];
                m_pSearchProviderHandle = [m_pSearchModel addSearchProvider: searchProvider];
                m_pSuggestionProviderHandle = [m_pSearchModel addSuggestionProvider: suggestionProvider];

                m_pSearchWidgetView = [[[WRLDSearchWidgetView alloc] init] autorelease];
                [m_pSearchWidgetView useSearchModel:m_pSearchModel];
                [m_pSearchWidgetView useMenuModel:m_pMenuModel];

                [m_pSearchWidgetView displaySearchProvider: m_pSearchProviderHandle];
                [m_pSearchWidgetView displaySuggestionProvider: m_pSuggestionProviderHandle];

                UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
                UIEdgeInsets safeInsets = [rootViewController safeInsets];
                
                CGRect screenRect = rootViewController.view.bounds;
                
                CGFloat screenWidth = screenRect.size.width;
                CGFloat iphoneMargin = 20;
                CGFloat iPadMargin = 20;
                CGFloat iPhoneWidgetWidth = screenWidth - 2*iphoneMargin;
                CGFloat iPadWidgetWidth = 375;
                
                CGFloat heightIphone = screenRect.size.height - 2*iphoneMargin;
                CGFloat heightIpad = screenRect.size.height - 2*iPadMargin;

                CGRect iPadFrame = CGRectMake(iPadMargin, safeInsets.top,  iPadWidgetWidth , heightIpad) ;
                CGRect iPhoneFrame = CGRectMake(iphoneMargin, safeInsets.top, iPhoneWidgetWidth , heightIphone);
            
                CGRect searchFrame = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? iPadFrame : iPhoneFrame;
                
                CGFloat searchBoxHeight = 50;
                m_widgetAnimationOffset = - searchFrame.origin.y - searchBoxHeight;

                m_pSearchWidgetView.frame = searchFrame;

                CGAffineTransform transform = CGAffineTransformMakeTranslation(0.0,m_widgetAnimationOffset);
                m_pSearchWidgetView.transform = transform;

                NSBundle* resourceBundle = [NSBundle bundleForClass:[WidgetSearchResultTableViewCell class]];
                UINib* nib = [UINib nibWithNibName: @"WidgetSearchResultTableViewCell" bundle:resourceBundle];

                [m_pSearchWidgetView registerNib:nib forUseWithResultsTableCellIdentifier:@"WidgetSearchResultTableViewCell"];

                m_pMenuGroups = [[NSMutableDictionary alloc] init];
                m_pMenuOptions = [[NSMutableDictionary alloc] init];
                
                m_pSpeechCapture = [[WRLDSpeechCapture alloc] initWithFrame: [UIScreen mainScreen].bounds];
                [m_pSearchWidgetView enableVoiceSearch:m_pSpeechCapture];
                
                AddEventListeners();<commit_msg>Fix for [MPLY-9994]: Search Widget no longer occludes iPhone X home-bar. Buddy: <NAME>.<commit_after>// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include "SearchWidgetView.h"
#include "WidgetSearchResultTableViewCell.h"
#include "SearchWidgetMenuContext.h"
#include "WidgetQueryContext.h"
#include "MenuItemModel.h"
#include "ViewController.h"
#include "WidgetSearchResultTableViewCell.h"
#include "ISearchNavigationHandler.h"
#import <WrldSearchWidget/WRLDSearchQuery.h>

namespace ExampleApp
{
    namespace SearchMenu
    {
        namespace View
        {
            SearchWidgetView::SearchWidgetView(WRLDSearchModel* searchModel,
                                               id<WRLDSearchProvider> searchProvider,
                                               id<WRLDSuggestionProvider> suggestionProvider,
                                               bool isNavigationEnabled,
                                               ExampleAppMessaging::TMessageBus& messageBus)
            : m_pSearchModel(searchModel)
            , m_tagCollection(messageBus)
            , m_hasSearchResults(false)
            , m_hasPopulatedData(false)
            , m_isNavigationHidden(!isNavigationEnabled)
            {
                m_pMenuModel = [[WRLDSearchMenuModel alloc] init];
                m_pSearchProviderHandle = [m_pSearchModel addSearchProvider: searchProvider];
                m_pSuggestionProviderHandle = [m_pSearchModel addSuggestionProvider: suggestionProvider];

                m_pSearchWidgetView = [[[WRLDSearchWidgetView alloc] init] autorelease];
                [m_pSearchWidgetView useSearchModel:m_pSearchModel];
                [m_pSearchWidgetView useMenuModel:m_pMenuModel];

                [m_pSearchWidgetView displaySearchProvider: m_pSearchProviderHandle];
                [m_pSearchWidgetView displaySuggestionProvider: m_pSuggestionProviderHandle];

                UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
                UIEdgeInsets safeInsets = [rootViewController safeInsets];
                
                CGRect screenRect = rootViewController.view.bounds;
                
                CGFloat screenWidth = screenRect.size.width;
                CGFloat iphoneMargin = 20;
                CGFloat iPadMargin = 20;
                CGFloat iPhoneWidgetWidth = screenWidth - 2*iphoneMargin;
                CGFloat iPadWidgetWidth = 375;
                
                CGFloat heightIphone = screenRect.size.height - 2*iphoneMargin - safeInsets.bottom;
                CGFloat heightIpad = screenRect.size.height - 2*iPadMargin - safeInsets.bottom;

                CGRect iPadFrame = CGRectMake(iPadMargin, safeInsets.top,  iPadWidgetWidth , heightIpad) ;
                CGRect iPhoneFrame = CGRectMake(iphoneMargin, safeInsets.top, iPhoneWidgetWidth , heightIphone);
            
                CGRect searchFrame = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? iPadFrame : iPhoneFrame;
                
                CGFloat searchBoxHeight = 50;
                m_widgetAnimationOffset = - searchFrame.origin.y - searchBoxHeight;

                m_pSearchWidgetView.frame = searchFrame;

                CGAffineTransform transform = CGAffineTransformMakeTranslation(0.0,m_widgetAnimationOffset);
                m_pSearchWidgetView.transform = transform;

                NSBundle* resourceBundle = [NSBundle bundleForClass:[WidgetSearchResultTableViewCell class]];
                UINib* nib = [UINib nibWithNibName: @"WidgetSearchResultTableViewCell" bundle:resourceBundle];

                [m_pSearchWidgetView registerNib:nib forUseWithResultsTableCellIdentifier:@"WidgetSearchResultTableViewCell"];

                m_pMenuGroups = [[NSMutableDictionary alloc] init];
                m_pMenuOptions = [[NSMutableDictionary alloc] init];
                
                m_pSpeechCapture = [[WRLDSpeechCapture alloc] initWithFrame: [UIScreen mainScreen].bounds];
                [m_pSearchWidgetView enableVoiceSearch:m_pSpeechCapture];
                
                AddEventListeners();
{'fraction_non_alphanumeric': 0.06637490882567469, 'fraction_numerical': 0.005835156819839533, 'mean_word_length': 2.329421286928369, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2359857', 'n_tokens_mistral': 2160, 'n_tokens_neox': 1993, 'n_words': 357}