Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
|
|
@ -0,0 +1,62 @@
|
|||
typedef NS_ENUM(NSInteger, MWMActionBarButtonType) {
|
||||
MWMActionBarButtonTypeBooking,
|
||||
MWMActionBarButtonTypeBookingSearch,
|
||||
MWMActionBarButtonTypeBookmark,
|
||||
MWMActionBarButtonTypeTrack,
|
||||
MWMActionBarButtonTypeSaveTrackRecording,
|
||||
MWMActionBarButtonTypeNotSaveTrackRecording,
|
||||
MWMActionBarButtonTypeCall,
|
||||
MWMActionBarButtonTypeDownload,
|
||||
MWMActionBarButtonTypeMore,
|
||||
MWMActionBarButtonTypeOpentable,
|
||||
MWMActionBarButtonTypeRouteAddStop,
|
||||
MWMActionBarButtonTypeRouteFrom,
|
||||
MWMActionBarButtonTypeRouteRemoveStop,
|
||||
MWMActionBarButtonTypeRouteTo,
|
||||
MWMActionBarButtonTypeAvoidToll,
|
||||
MWMActionBarButtonTypeAvoidDirty,
|
||||
MWMActionBarButtonTypeAvoidFerry
|
||||
} NS_SWIFT_NAME(ActionBarButtonType);
|
||||
|
||||
typedef NS_ENUM(NSInteger, MWMBookmarksButtonState) {
|
||||
MWMBookmarksButtonStateSave,
|
||||
MWMBookmarksButtonStateDelete,
|
||||
MWMBookmarksButtonStateRecover,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
NSString * titleForButton(MWMActionBarButtonType type, BOOL isSelected);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@class MWMActionBarButton;
|
||||
@class MWMCircularProgress;
|
||||
|
||||
NS_SWIFT_NAME(ActionBarButtonDelegate)
|
||||
@protocol MWMActionBarButtonDelegate <NSObject>
|
||||
|
||||
- (void)tapOnButtonWithType:(MWMActionBarButtonType)type;
|
||||
|
||||
@end
|
||||
|
||||
NS_SWIFT_NAME(ActionBarButton)
|
||||
@interface MWMActionBarButton : UIView
|
||||
|
||||
@property(nonatomic, readonly) MWMActionBarButtonType type;
|
||||
@property(nonatomic, readonly, nullable) MWMCircularProgress *mapDownloadProgress;
|
||||
|
||||
+ (MWMActionBarButton *)buttonWithDelegate:(id<MWMActionBarButtonDelegate>)delegate
|
||||
buttonType:(MWMActionBarButtonType)type
|
||||
isSelected:(BOOL)isSelected
|
||||
isEnabled:(BOOL)isEnabled;
|
||||
|
||||
- (void)setBookmarkButtonState:(MWMBookmarksButtonState)state;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
#import "MWMActionBarButton.h"
|
||||
#import "MWMButton.h"
|
||||
#import "MWMCircularProgress.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
static NSString * const kUDDidHighlightRouteToButton = @"kUDDidHighlightPoint2PointButton";
|
||||
|
||||
NSString *titleForButton(MWMActionBarButtonType type, BOOL isSelected) {
|
||||
switch (type) {
|
||||
case MWMActionBarButtonTypeDownload:
|
||||
return L(@"download");
|
||||
case MWMActionBarButtonTypeBooking:
|
||||
case MWMActionBarButtonTypeOpentable:
|
||||
return L(@"book_button");
|
||||
case MWMActionBarButtonTypeBookingSearch:
|
||||
return L(@"booking_search");
|
||||
case MWMActionBarButtonTypeCall:
|
||||
return L(@"placepage_call_button");
|
||||
case MWMActionBarButtonTypeBookmark:
|
||||
case MWMActionBarButtonTypeTrack:
|
||||
return L(isSelected ? @"delete" : @"save");
|
||||
case MWMActionBarButtonTypeSaveTrackRecording:
|
||||
return L(@"save");
|
||||
case MWMActionBarButtonTypeNotSaveTrackRecording:
|
||||
return L(@"delete");
|
||||
case MWMActionBarButtonTypeRouteFrom:
|
||||
return L(@"p2p_from_here");
|
||||
case MWMActionBarButtonTypeRouteTo:
|
||||
return L(@"p2p_to_here");
|
||||
case MWMActionBarButtonTypeMore:
|
||||
return L(@"placepage_more_button");
|
||||
case MWMActionBarButtonTypeRouteAddStop:
|
||||
return L(@"placepage_add_stop");
|
||||
case MWMActionBarButtonTypeRouteRemoveStop:
|
||||
return L(@"placepage_remove_stop");
|
||||
case MWMActionBarButtonTypeAvoidToll:
|
||||
return L(@"avoid_tolls");
|
||||
case MWMActionBarButtonTypeAvoidDirty:
|
||||
return L(@"avoid_unpaved");
|
||||
case MWMActionBarButtonTypeAvoidFerry:
|
||||
return L(@"avoid_ferry");
|
||||
}
|
||||
}
|
||||
|
||||
@interface MWMActionBarButton () <MWMCircularProgressProtocol>
|
||||
|
||||
@property(nonatomic) MWMActionBarButtonType type;
|
||||
@property(nonatomic) MWMCircularProgress *mapDownloadProgress;
|
||||
@property(weak, nonatomic) IBOutlet MWMButton *button;
|
||||
@property(weak, nonatomic) IBOutlet UILabel *label;
|
||||
@property(weak, nonatomic) IBOutlet UIView *extraBackground;
|
||||
@property(weak, nonatomic) id<MWMActionBarButtonDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMActionBarButton
|
||||
|
||||
- (void)configButton:(BOOL)isSelected enabled:(BOOL)isEnabled {
|
||||
self.label.text = titleForButton(self.type, isSelected);
|
||||
self.extraBackground.hidden = YES;
|
||||
self.button.coloring = MWMButtonColoringBlack;
|
||||
[self.button.imageView setContentMode:UIViewContentModeScaleAspectFit];
|
||||
|
||||
switch (self.type) {
|
||||
case MWMActionBarButtonTypeDownload: {
|
||||
if (self.mapDownloadProgress)
|
||||
return;
|
||||
|
||||
self.mapDownloadProgress = [MWMCircularProgress downloaderProgressForParentView:self.button];
|
||||
self.mapDownloadProgress.delegate = self;
|
||||
|
||||
MWMCircularProgressStateVec affectedStates =
|
||||
@[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected)];
|
||||
|
||||
[self.mapDownloadProgress setImageName:@"ic_download" forStates:affectedStates];
|
||||
[self.mapDownloadProgress setColoring:MWMButtonColoringBlue forStates:affectedStates];
|
||||
break;
|
||||
}
|
||||
case MWMActionBarButtonTypeBooking:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_booking_logo"] forState:UIControlStateNormal];
|
||||
self.label.styleName = @"PPActionBarTitlePartner";
|
||||
self.backgroundColor = [UIColor bookingBackground];
|
||||
if (!IPAD) {
|
||||
self.extraBackground.backgroundColor = [UIColor bookingBackground];
|
||||
self.extraBackground.hidden = NO;
|
||||
}
|
||||
break;
|
||||
case MWMActionBarButtonTypeBookingSearch:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_booking_search"] forState:UIControlStateNormal];
|
||||
self.label.styleName = @"PPActionBarTitlePartner";
|
||||
self.backgroundColor = [UIColor bookingBackground];
|
||||
if (!IPAD) {
|
||||
self.extraBackground.backgroundColor = [UIColor bookingBackground];
|
||||
self.extraBackground.hidden = NO;
|
||||
}
|
||||
break;
|
||||
case MWMActionBarButtonTypeOpentable:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_opentable"] forState:UIControlStateNormal];
|
||||
self.label.styleName = @"PPActionBarTitlePartner";
|
||||
self.backgroundColor = [UIColor opentableBackground];
|
||||
if (!IPAD) {
|
||||
self.extraBackground.backgroundColor = [UIColor opentableBackground];
|
||||
self.extraBackground.hidden = NO;
|
||||
}
|
||||
break;
|
||||
case MWMActionBarButtonTypeCall:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_placepage_phone_number"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeBookmark:
|
||||
[self setupBookmarkButton:isSelected];
|
||||
break;
|
||||
case MWMActionBarButtonTypeTrack:
|
||||
[self.button setImage:[[UIImage imageNamed:@"ic_route_manager_trash"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
self.button.coloring = MWMButtonColoringRed;
|
||||
break;
|
||||
case MWMActionBarButtonTypeSaveTrackRecording:
|
||||
[self.button setImage:[UIImage systemImageNamed:@"square.and.arrow.down" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:22 weight:UIImageSymbolWeightSemibold]] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeNotSaveTrackRecording:
|
||||
[self.button setImage:[UIImage systemImageNamed:@"trash.fill" withConfiguration:[UIImageSymbolConfiguration configurationWithPointSize:22 weight:UIImageSymbolWeightSemibold]] forState:UIControlStateNormal];
|
||||
self.button.coloring = MWMButtonColoringRed;
|
||||
break;
|
||||
case MWMActionBarButtonTypeRouteFrom:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_route_from"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeRouteTo:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_route_to"] forState:UIControlStateNormal];
|
||||
if ([self needsToHighlightRouteToButton])
|
||||
self.button.coloring = MWMButtonColoringBlue;
|
||||
break;
|
||||
case MWMActionBarButtonTypeMore:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_placepage_more"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeRouteAddStop:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_add_route_point"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeRouteRemoveStop:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_remove_route_point"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeAvoidToll:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_avoid_tolls"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeAvoidDirty:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_avoid_dirty"] forState:UIControlStateNormal];
|
||||
break;
|
||||
case MWMActionBarButtonTypeAvoidFerry:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_avoid_ferry"] forState:UIControlStateNormal];
|
||||
break;
|
||||
}
|
||||
|
||||
self.button.enabled = isEnabled;
|
||||
}
|
||||
|
||||
+ (MWMActionBarButton *)buttonWithDelegate:(id<MWMActionBarButtonDelegate>)delegate
|
||||
buttonType:(MWMActionBarButtonType)type
|
||||
isSelected:(BOOL)isSelected
|
||||
isEnabled:(BOOL)isEnabled {
|
||||
MWMActionBarButton *button = [NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil].firstObject;
|
||||
button.delegate = delegate;
|
||||
button.type = type;
|
||||
[button configButton:isSelected enabled:isEnabled];
|
||||
return button;
|
||||
}
|
||||
|
||||
- (void)progressButtonPressed:(MWMCircularProgress *)progress {
|
||||
[self.delegate tapOnButtonWithType:self.type];
|
||||
}
|
||||
|
||||
- (IBAction)tap {
|
||||
if (self.type == MWMActionBarButtonTypeRouteTo)
|
||||
[self disableRouteToButtonHighlight];
|
||||
|
||||
[self.delegate tapOnButtonWithType:self.type];
|
||||
}
|
||||
|
||||
- (void)setBookmarkButtonState:(MWMBookmarksButtonState)state {
|
||||
switch (state) {
|
||||
case MWMBookmarksButtonStateSave:
|
||||
self.label.text = L(@"save");
|
||||
self.button.selected = false;
|
||||
break;
|
||||
case MWMBookmarksButtonStateDelete:
|
||||
self.label.text = L(@"delete");
|
||||
if (!self.button.selected)
|
||||
[self.button.imageView startAnimating];
|
||||
self.button.selected = true;
|
||||
break;
|
||||
case MWMBookmarksButtonStateRecover:
|
||||
self.label.text = L(@"restore");
|
||||
self.button.selected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setupBookmarkButton:(BOOL)isSelected {
|
||||
MWMButton *btn = self.button;
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_off"] forState:UIControlStateNormal];
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_on"] forState:UIControlStateSelected];
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_on"] forState:UIControlStateHighlighted];
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_on"] forState:UIControlStateDisabled];
|
||||
|
||||
[btn setSelected:isSelected];
|
||||
|
||||
NSUInteger const animationImagesCount = 11;
|
||||
NSMutableArray *animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
|
||||
for (NSUInteger i = 0; i < animationImagesCount; ++i) {
|
||||
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"ic_bookmarks_%@", @(i + 1)]];
|
||||
animationImages[i] = image;
|
||||
}
|
||||
UIImageView *animationIV = btn.imageView;
|
||||
animationIV.animationImages = animationImages;
|
||||
animationIV.animationRepeatCount = 1;
|
||||
}
|
||||
|
||||
- (BOOL)needsToHighlightRouteToButton {
|
||||
return ![NSUserDefaults.standardUserDefaults boolForKey:kUDDidHighlightRouteToButton];
|
||||
}
|
||||
|
||||
- (void)disableRouteToButtonHighlight {
|
||||
[NSUserDefaults.standardUserDefaults setBool:true forKey:kUDDidHighlightRouteToButton];
|
||||
}
|
||||
|
||||
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
|
||||
[super traitCollectionDidChange:previousTraitCollection];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
if ([self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection])
|
||||
// Update button for the current selection state.
|
||||
[self.button setSelected:self.button.isSelected];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
||||
return [self pointInside:point withEvent:event] ? self.button : nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMActionBarButton"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="MWMActionBarButton" propertyAccessControl="none">
|
||||
<rect key="frame" x="0.0" y="0.0" width="80" height="48"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="R50-Tj-X0W">
|
||||
<rect key="frame" x="0.0" y="0.0" width="80" height="48"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W07-Hz-J60" customClass="MWMButton">
|
||||
<rect key="frame" x="0.0" y="2" width="80" height="33"/>
|
||||
<connections>
|
||||
<action selector="tap" destination="iN0-l3-epB" eventType="touchUpInside" id="yKY-7K-Wyl"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="80" translatesAutoresizingMaskIntoConstraints="NO" id="rrI-0A-w3s">
|
||||
<rect key="frame" x="0.0" y="32" width="80" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="14" id="BBl-pC-RJq"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="PPActionBarTitle"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="R50-Tj-X0W" secondAttribute="trailing" id="2jF-U9-Gei"/>
|
||||
<constraint firstAttribute="trailing" secondItem="rrI-0A-w3s" secondAttribute="trailing" id="LPs-Yx-xz6"/>
|
||||
<constraint firstItem="rrI-0A-w3s" firstAttribute="top" secondItem="W07-Hz-J60" secondAttribute="bottom" constant="-3" id="SMD-s3-Tz5"/>
|
||||
<constraint firstItem="W07-Hz-J60" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="2" id="UJy-Ef-B7E"/>
|
||||
<constraint firstItem="rrI-0A-w3s" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="X6f-tU-o9a"/>
|
||||
<constraint firstItem="R50-Tj-X0W" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="ZHQ-XD-E90"/>
|
||||
<constraint firstAttribute="bottom" secondItem="rrI-0A-w3s" secondAttribute="bottom" constant="2" id="Zsi-G2-yc8"/>
|
||||
<constraint firstAttribute="bottom" secondItem="R50-Tj-X0W" secondAttribute="bottom" id="adE-76-Hab"/>
|
||||
<constraint firstItem="R50-Tj-X0W" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="qid-13-F5b"/>
|
||||
<constraint firstItem="W07-Hz-J60" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="rBR-of-5Ha"/>
|
||||
<constraint firstAttribute="trailing" secondItem="W07-Hz-J60" secondAttribute="trailing" id="teM-gm-CX7"/>
|
||||
</constraints>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="button" destination="W07-Hz-J60" id="dAN-CS-btL"/>
|
||||
<outlet property="extraBackground" destination="R50-Tj-X0W" id="c90-1d-BSU"/>
|
||||
<outlet property="label" destination="rrI-0A-w3s" id="LMD-pz-agZ"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="139" y="154"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
Loading…
Add table
Add a link
Reference in a new issue