diff --git a/iphone/Maps/Core/Settings/MWMSettings.h b/iphone/Maps/Core/Settings/MWMSettings.h index 4579c000df..64cc572467 100644 --- a/iphone/Maps/Core/Settings/MWMSettings.h +++ b/iphone/Maps/Core/Settings/MWMSettings.h @@ -31,4 +31,6 @@ NS_SWIFT_NAME(Settings) + (BOOL)isTrackWarningAlertShown; + (void)setTrackWarningAlertShown:(BOOL)shown; ++ (NSString *)donateUrl; + @end diff --git a/iphone/Maps/Core/Settings/MWMSettings.mm b/iphone/Maps/Core/Settings/MWMSettings.mm index 36294c7d16..8e22dc612b 100644 --- a/iphone/Maps/Core/Settings/MWMSettings.mm +++ b/iphone/Maps/Core/Settings/MWMSettings.mm @@ -77,9 +77,9 @@ NSString * const kUDTrackWarningAlertWasShown = @"TrackWarningAlertWasShown"; if ([MWMCarPlayService shared].isCarplayActivated) { UIUserInterfaceStyle style = [[MWMCarPlayService shared] interfaceStyle]; switch (style) { - case UIUserInterfaceStyleLight: return MWMThemeDay; - case UIUserInterfaceStyleDark: return MWMThemeNight; - case UIUserInterfaceStyleUnspecified: break; + case UIUserInterfaceStyleLight: return MWMThemeDay; + case UIUserInterfaceStyleDark: return MWMThemeNight; + case UIUserInterfaceStyleUnspecified: break; } } auto ud = NSUserDefaults.standardUserDefaults; @@ -148,4 +148,12 @@ NSString * const kUDTrackWarningAlertWasShown = @"TrackWarningAlertWasShown"; [ud setBool:shown forKey:kUDTrackWarningAlertWasShown]; [ud synchronize]; } + ++ (NSString *)donateUrl +{ + std::string url; + if (settings::Get("DonateUrl", url)) return @(url.c_str()); + return nil; +} + @end diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/Contents.json b/iphone/Maps/Images.xcassets/Bottom Menu/Contents.json index da4a164c91..73c00596a7 100644 --- a/iphone/Maps/Images.xcassets/Bottom Menu/Contents.json +++ b/iphone/Maps/Images.xcassets/Bottom Menu/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_booking_search.imageset/icTypeHotel.pdf b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_booking_search.imageset/icTypeHotel.pdf deleted file mode 100644 index 44d9c228a2..0000000000 Binary files a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_booking_search.imageset/icTypeHotel.pdf and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_discovery.imageset/Contents.json b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_discovery.imageset/Contents.json deleted file mode 100644 index 4ba8fb33b1..0000000000 --- a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_discovery.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "ic_menu_discovery.pdf" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "template" - } -} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_discovery.imageset/ic_menu_discovery.pdf b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_discovery.imageset/ic_menu_discovery.pdf deleted file mode 100644 index 1e0375726e..0000000000 Binary files a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_discovery.imageset/ic_menu_discovery.pdf and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_booking_search.imageset/Contents.json b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_donate.imageset/Contents.json similarity index 51% rename from iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_booking_search.imageset/Contents.json rename to iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_donate.imageset/Contents.json index 725d7e5511..a12c271ac5 100644 --- a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_booking_search.imageset/Contents.json +++ b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_donate.imageset/Contents.json @@ -1,15 +1,15 @@ { "images" : [ { - "idiom" : "universal", - "filename" : "icTypeHotel.pdf" + "filename" : "ic_menu_donate.svg", + "idiom" : "universal" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 }, "properties" : { "template-rendering-intent" : "template" } -} \ No newline at end of file +} diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_donate.imageset/ic_menu_donate.svg b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_donate.imageset/ic_menu_donate.svg new file mode 100644 index 0000000000..2ddaeefa50 --- /dev/null +++ b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_donate.imageset/ic_menu_donate.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/Contents.json b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/Contents.json deleted file mode 100644 index 6e955e770b..0000000000 --- a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/Contents.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "ic_menu_showcase.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "ic_menu_showcase@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "filename" : "ic_menu_showcase@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "template" - } -} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase.png b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase.png deleted file mode 100644 index 38d763ba0f..0000000000 Binary files a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase.png and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase@2x.png b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase@2x.png deleted file mode 100644 index 30af8a65ba..0000000000 Binary files a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase@2x.png and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase@3x.png b/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase@3x.png deleted file mode 100644 index 455ab799fc..0000000000 Binary files a/iphone/Maps/Images.xcassets/Bottom Menu/ic_menu_showcase.imageset/ic_menu_showcase@3x.png and /dev/null differ diff --git a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift index 9a3002adcb..f2e0da5ca2 100644 --- a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift +++ b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift @@ -1,8 +1,8 @@ protocol BottomMenuInteractorProtocol: AnyObject { func close() func addPlace() - func downloadRoutes() func downloadMaps() + func donate() func openSettings() func shareLocation(cell: BottomMenuItemCell) } @@ -43,8 +43,13 @@ extension BottomMenuInteractor: BottomMenuInteractorProtocol { delegate?.addPlace() } - func downloadRoutes() { + func donate() { close() + guard var url = Settings.donateUrl() else { return } + if url == "https://organicmaps.app/donate/" { + url = L("translated_om_site_url") + "donate/" + } + viewController?.openUrl(url, inSafari: true) } func downloadMaps() { diff --git a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift index 95114d7ba6..a792e2c886 100644 --- a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift +++ b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift @@ -5,8 +5,8 @@ protocol BottomMenuPresenterProtocol: UITableViewDelegate, UITableViewDataSource class BottomMenuPresenter: NSObject { enum CellType: Int, CaseIterable { case addPlace - //case downloadRoutes case downloadMaps + case donate case settings case share } @@ -26,6 +26,8 @@ class BottomMenuPresenter: NSObject { self.interactor = interactor self.sections = sections } + + let disableDonate = Settings.donateUrl() == nil } extension BottomMenuPresenter: BottomMenuPresenterProtocol { @@ -42,45 +44,49 @@ extension BottomMenuPresenter { } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - section == Sections.layers.rawValue ? 1 : CellType.allCases.count + section == Sections.layers.rawValue ? 1 : CellType.allCases.count - (disableDonate ? 1 : 0) } + private func correctedRow(_ row: Int) -> Int { + disableDonate && row >= CellType.donate.rawValue ? row + 1 : row + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if indexPath.section == Sections.layers.rawValue { let cell = tableView.dequeueReusableCell(cell: BottomMenuLayersCell.self)! cell.onClose = { [weak self] in self?.onClosePressed() } return cell } - if indexPath.section == Sections.items.rawValue { - let cell = tableView.dequeueReusableCell(cell: BottomMenuItemCell.self)! - switch CellType(rawValue: indexPath.row)! { - case .addPlace: - let enabled = MWMNavigationDashboardManager.shared().state == .hidden && FrameworkHelper.canEditMap() - cell.configure(imageName: "ic_add_place", - title: L("placepage_add_place_button"), - badgeCount: 0, - enabled: enabled) -// case .downloadRoutes: -// cell.configure(imageName: "ic_menu_routes", title: L("download_guides")) - case .downloadMaps: - cell.configure(imageName: "ic_menu_download", - title: L("download_maps"), - badgeCount: MapsAppDelegate.theApp().badgeNumber(), - enabled: true) - case .settings: - cell.configure(imageName: "ic_menu_settings", - title: L("settings"), - badgeCount: 0, - enabled: true) - case .share: - cell.configure(imageName: "ic_menu_share", - title: L("share_my_location"), - badgeCount: 0, - enabled: true) - } - return cell + let cell = tableView.dequeueReusableCell(cell: BottomMenuItemCell.self)! + switch CellType(rawValue: correctedRow(indexPath.row))! { + case .addPlace: + let enabled = MWMNavigationDashboardManager.shared().state == .hidden && FrameworkHelper.canEditMap() + cell.configure(imageName: "ic_add_place", + title: L("placepage_add_place_button"), + badgeCount: 0, + enabled: enabled) + case .downloadMaps: + cell.configure(imageName: "ic_menu_download", + title: L("download_maps"), + badgeCount: MapsAppDelegate.theApp().badgeNumber(), + enabled: true) + case .donate: + cell.configure(imageName: "ic_menu_donate", + title: L("donate"), + badgeCount: 0, + enabled: true) + case .settings: + cell.configure(imageName: "ic_menu_settings", + title: L("settings"), + badgeCount: 0, + enabled: true) + case .share: + cell.configure(imageName: "ic_menu_share", + title: L("share_my_location"), + badgeCount: 0, + enabled: true) } - fatalError() + return cell } } @@ -93,13 +99,13 @@ extension BottomMenuPresenter { return } tableView.deselectRow(at: indexPath, animated: true) - switch CellType(rawValue: indexPath.row)! { + switch CellType(rawValue: correctedRow(indexPath.row))! { case .addPlace: interactor.addPlace() -// case .downloadRoutes: -// interactor.downloadRoutes() case .downloadMaps: interactor.downloadMaps() + case .donate: + interactor.donate() case .settings: interactor.openSettings() case .share: