[ios] One more menu item

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk 2022-11-18 00:21:42 +01:00 committed by Roman Tsisyk
parent dc29c33275
commit 9eb900db59
14 changed files with 69 additions and 88 deletions

View file

@ -31,4 +31,6 @@ NS_SWIFT_NAME(Settings)
+ (BOOL)isTrackWarningAlertShown;
+ (void)setTrackWarningAlertShown:(BOOL)shown;
+ (NSString *)donateUrl;
@end

View file

@ -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

View file

@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}

View file

@ -1,15 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_menu_discovery.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

View file

@ -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"
}
}
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M32.3 25.1Q29.95 23 27.825 21 25.7 19 24.1 17.1t-2.55-3.675Q20.6 11.65 20.6 10q0-2.6 1.75-4.35Q24.1 3.9 26.7 3.9q1.5 0 2.975.825T32.3 6.95q1.15-1.4 2.625-2.225Q36.4 3.9 37.9 3.9q2.6 0 4.35 1.75Q44 7.4 44 10q0 1.65-.95 3.425T40.5 17.1Q38.9 19 36.775 21T32.3 25.1Zm-4 19.8-15.55-4.45V23.6h4.7l12.75 4.8q1.35.5 2.275 1.625.925 1.125.925 3.225h-3.2q-2.45 0-3.575-.15t-2.375-.55l-3.65-1.2-.5 1.4 3.75 1.3q1.15.4 2.575.55 1.425.15 2.925.15h9.75q2.85 0 3.875 1.1T44 38.8v1.3ZM2 43.3V23.6h7.7v19.7Z"/></svg>

After

Width:  |  Height:  |  Size: 571 B

View file

@ -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"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

View file

@ -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() {

View file

@ -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: