[MAPSME-5412] [ios] Fixed bottom menu badge visibility.

This commit is contained in:
Ilya Grechuhin 2017-08-22 14:37:23 +03:00 committed by Vladimir Byko-Ianko
parent 9737c23b18
commit 19dab4908a
6 changed files with 29 additions and 37 deletions

View file

@ -36,4 +36,6 @@
- (void)showMap;
- (void)showAlertIfRequired;
- (NSUInteger)badgeNumber;
@end

View file

@ -22,7 +22,9 @@
#include "Framework.h"
#include "map/gps_tracker.hpp"
#include "platform/http_thread_apple.h"
#include "platform/local_country_file_utils.hpp"
// If you have a "missing header error" here, then please run configure.sh script in the root repo
// folder.
@ -855,12 +857,18 @@ using namespace osm_auth_ios;
}
- (void)updateApplicationIconBadgeNumber
{
auto const number = [self badgeNumber];
[UIApplication sharedApplication].applicationIconBadgeNumber = number;
[[MWMBottomMenuViewController controller] updateBadgeVisible:number != 0];
}
- (NSUInteger)badgeNumber
{
auto & s = GetFramework().GetStorage();
storage::Storage::UpdateInfo updateInfo{};
s.GetUpdateInfo(s.GetRootId(), updateInfo);
[UIApplication sharedApplication].applicationIconBadgeNumber =
updateInfo.m_numberOfMwmFilesToUpdate;
return updateInfo.m_numberOfMwmFilesToUpdate + (platform::migrate::NeedMigrate() ? 1 : 0);
}
#pragma mark - MWMFrameworkStorageObserver

View file

@ -3,10 +3,6 @@
#import "MWMButton.h"
#import "MWMCommon.h"
#include "Framework.h"
#include "platform/local_country_file_utils.hpp"
namespace
{
CGFloat constexpr kAdditionalHeight = 64;
@ -16,22 +12,17 @@ CGFloat constexpr kDefaultMenuButtonWidth = 60;
@interface MWMBottomMenuView ()
@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * mainButtonsHeight;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * additionalButtonsHeight;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * separatorHeight;
@property(weak, nonatomic) IBOutlet UIView * downloadBadge;
@property(weak, nonatomic) IBOutlet MWMButton * searchButton;
@property(weak, nonatomic) IBOutlet MWMButton * menuButton;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * menuButtonWidth;
@property(nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray * mainButtonConstraintsLeftToRight;
@property(nonatomic) CGFloat layoutDuration;
@property(nonatomic) CGRect availableArea;
@property(nonatomic) IBOutletCollection(NSLayoutConstraint) NSArray * mainButtonConstraintsLeftToRight;
@property(weak, nonatomic) IBOutlet MWMButton * menuButton;
@property(weak, nonatomic) IBOutlet MWMButton * searchButton;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * additionalButtonsHeight;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * mainButtonsHeight;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * menuButtonWidth;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * separatorHeight;
@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
@property(weak, nonatomic) IBOutlet UIView * downloadBadge;
@end
@ -41,7 +32,6 @@ CGFloat constexpr kDefaultMenuButtonWidth = 60;
{
[super awakeFromNib];
self.additionalButtons.hidden = YES;
self.downloadBadge.hidden = YES;
if (isInterfaceRightToLeft())
{
@ -191,15 +181,6 @@ CGFloat constexpr kDefaultMenuButtonWidth = 60;
[self setNeedsLayout];
}
- (void)updateBadge
{
auto & s = GetFramework().GetStorage();
storage::Storage::UpdateInfo updateInfo{};
s.GetUpdateInfo(s.GetRootId(), updateInfo);
self.downloadBadge.hidden =
(updateInfo.m_numberOfMwmFilesToUpdate == 0) && !platform::migrate::NeedMigrate();
}
#pragma mark - Properties
- (void)setState:(MWMBottomMenuState)state
@ -212,7 +193,6 @@ CGFloat constexpr kDefaultMenuButtonWidth = 60;
[self morphMenuButtonTemplate:@"ic_menu_" direct:isActive];
_state = state;
[self refreshLayout];
[self updateBadge];
}
- (void)updateAvailableArea:(CGRect)frame

View file

@ -13,6 +13,7 @@
delegate:(id<MWMBottomMenuControllerProtocol>)delegate;
- (void)mwm_refreshUI;
- (void)updateBadgeVisible:(BOOL)visible;
+ (void)updateAvailableArea:(CGRect)frame;

View file

@ -7,6 +7,7 @@
#import "MWMCommon.h"
#import "MWMMapViewControlsManager.h"
#import "MapViewController.h"
#import "MapsAppDelegate.h"
#import "SwiftBridge.h"
#include "Framework.h"
@ -42,6 +43,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
@property(weak, nonatomic) IBOutlet MWMButton * searchButton;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * mainButtonsHeight;
@property(weak, nonatomic) IBOutlet UICollectionView * additionalButtons;
@property(weak, nonatomic) IBOutlet UIView * downloadBadge;
@property(weak, nonatomic) MapViewController * controller;
@property(weak, nonatomic) id<MWMBottomMenuControllerProtocol> delegate;
@ -97,7 +99,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
}
- (void)mwm_refreshUI { [self.view mwm_refreshUI]; }
- (void)updateBadgeVisible:(BOOL)visible { self.downloadBadge.hidden = !visible; }
#pragma mark - Refresh Collection View layout
- (void)refreshLayout
@ -170,12 +172,9 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
}
case MWMBottomMenuViewCellDownload:
{
auto & s = GetFramework().GetStorage();
storage::Storage::UpdateInfo updateInfo{};
s.GetUpdateInfo(s.GetRootId(), updateInfo);
[cell configureWithImageName:@"ic_menu_download"
label:L(@"download_maps")
badgeCount:updateInfo.m_numberOfMwmFilesToUpdate
badgeCount:[[MapsAppDelegate theApp] badgeNumber]
isEnabled:YES];
}
break;
@ -355,6 +354,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
});
}];
view.state = state;
[self updateBadgeVisible:[[MapsAppDelegate theApp] badgeNumber] != 0];
}
- (MWMBottomMenuState)state { return self.menuView.state; }

View file

@ -13,6 +13,7 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMBottomMenuViewController">
<connections>
<outlet property="additionalButtons" destination="hSd-fM-qKd" id="tT1-ml-chk"/>
<outlet property="downloadBadge" destination="WLn-2O-Ivv" id="BPU-t1-YS6"/>
<outlet property="mainButtonsHeight" destination="HtR-j8-Qpc" id="uZ3-Im-taa"/>
<outlet property="searchButton" destination="IzQ-aQ-aPH" id="XWA-9H-Hvg"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
@ -164,7 +165,7 @@
<connections>
<outlet property="additionalButtons" destination="hSd-fM-qKd" id="Rgj-Fo-JK8"/>
<outlet property="additionalButtonsHeight" destination="fsD-HQ-mF9" id="zki-cR-ZH6"/>
<outlet property="downloadBadge" destination="WLn-2O-Ivv" id="f9u-k6-l9u"/>
<outlet property="downloadBadge" destination="WLn-2O-Ivv" id="0Aw-al-hGI"/>
<outlet property="mainButtonsHeight" destination="HtR-j8-Qpc" id="eF8-KH-F9n"/>
<outlet property="menuButton" destination="YLY-C4-SBu" id="A5G-Bc-IlQ"/>
<outlet property="menuButtonWidth" destination="ams-2s-vhw" id="Til-tN-VJX"/>