mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-05 20:23:48 +00:00
[ios] Changed settings to SwiftUI
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
090ed5044a
commit
fdbb41e0fd
@@ -1,6 +1,15 @@
|
||||
NS_SWIFT_NAME(Settings)
|
||||
NS_SWIFT_NAME(SettingsBridge)
|
||||
@interface MWMSettings : NSObject
|
||||
|
||||
+ (BOOL)buildings3dViewEnabled;
|
||||
+ (void)setBuildings3dViewEnabled:(BOOL)buildings3dViewEnabled;
|
||||
|
||||
+ (BOOL)perspectiveViewEnabled;
|
||||
+ (void)setPerspectiveViewEnabled:(BOOL)perspectiveViewEnabled;
|
||||
|
||||
+ (BOOL)autoZoomEnabled;
|
||||
+ (void)setAutoZoomEnabled:(BOOL)autoZoomEnabled;
|
||||
|
||||
+ (BOOL)autoDownloadEnabled;
|
||||
+ (void)setAutoDownloadEnabled:(BOOL)autoDownloadEnabled;
|
||||
|
||||
@@ -16,6 +25,9 @@ NS_SWIFT_NAME(Settings)
|
||||
+ (MWMTheme)theme;
|
||||
+ (void)setTheme:(MWMTheme)theme;
|
||||
|
||||
+ (NSInteger)powerManagement;
|
||||
+ (void)setPowerManagement:(NSInteger)powerManagement;
|
||||
|
||||
+ (BOOL)routingDisclaimerApproved;
|
||||
+ (void)setRoutingDisclaimerApproved;
|
||||
|
||||
@@ -40,5 +52,6 @@ NS_SWIFT_NAME(Settings)
|
||||
+ (void)initializeLogging;
|
||||
+ (BOOL)isFileLoggingEnabled;
|
||||
+ (void)setFileLoggingEnabled:(BOOL)fileLoggingEnabled;
|
||||
+ (NSInteger)logFileSize;
|
||||
|
||||
@end
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <CoreApi/Framework.h>
|
||||
#include <CoreApi/Logger.h>
|
||||
|
||||
using namespace power_management;
|
||||
|
||||
namespace
|
||||
{
|
||||
char const * kAutoDownloadEnabledKey = "AutoDownloadEnabled";
|
||||
@@ -24,6 +26,57 @@ NSString * const kUDFileLoggingEnabledKey = @"FileLoggingEnabledKey";
|
||||
|
||||
@implementation MWMSettings
|
||||
|
||||
+ (BOOL)buildings3dViewEnabled;
|
||||
{
|
||||
bool _ = true, on = true;
|
||||
GetFramework().Load3dMode(_, on);
|
||||
if (GetFramework().GetPowerManager().GetScheme() == power_management::Scheme::EconomyMaximum) {
|
||||
return false;
|
||||
} else {
|
||||
return on;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)setBuildings3dViewEnabled:(BOOL)buildings3dViewEnabled;
|
||||
{
|
||||
auto &f = GetFramework();
|
||||
bool _ = true, is3dBuildings = true;
|
||||
f.Load3dMode(_, is3dBuildings);
|
||||
is3dBuildings = static_cast<bool>(buildings3dViewEnabled);
|
||||
f.Save3dMode(_, is3dBuildings);
|
||||
f.Allow3dMode(_, is3dBuildings);
|
||||
}
|
||||
|
||||
+ (BOOL)perspectiveViewEnabled;
|
||||
{
|
||||
bool _ = true, on = true;
|
||||
auto &f = GetFramework();
|
||||
f.Load3dMode(on, _);
|
||||
return on;
|
||||
}
|
||||
|
||||
+ (void)setPerspectiveViewEnabled:(BOOL)perspectiveViewEnabled;
|
||||
{
|
||||
auto &f = GetFramework();
|
||||
bool is3d = true, _ = true;
|
||||
f.Load3dMode(is3d, _);
|
||||
is3d = static_cast<bool>(perspectiveViewEnabled);
|
||||
f.Save3dMode(is3d, _);
|
||||
f.Allow3dMode(is3d, _);
|
||||
}
|
||||
|
||||
+ (BOOL)autoZoomEnabled
|
||||
{
|
||||
return GetFramework().LoadAutoZoom();
|
||||
}
|
||||
|
||||
+ (void)setAutoZoomEnabled:(BOOL)autoZoomEnabled
|
||||
{
|
||||
auto &f = GetFramework();
|
||||
f.AllowAutoZoom(autoZoomEnabled);
|
||||
f.SaveAutoZoom(autoZoomEnabled);
|
||||
}
|
||||
|
||||
+ (BOOL)autoDownloadEnabled
|
||||
{
|
||||
bool autoDownloadEnabled = true;
|
||||
@@ -101,6 +154,29 @@ NSString * const kUDFileLoggingEnabledKey = @"FileLoggingEnabledKey";
|
||||
[MWMThemeManager invalidate];
|
||||
}
|
||||
|
||||
+ (NSInteger)powerManagement
|
||||
{
|
||||
Scheme scheme = GetFramework().GetPowerManager().GetScheme();
|
||||
if (scheme == Scheme::EconomyMaximum) {
|
||||
return 2;
|
||||
} else if (scheme == Scheme::Auto) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+ (void)setPowerManagement:(NSInteger)powerManagement
|
||||
{
|
||||
Scheme scheme = Scheme::Normal;
|
||||
if (powerManagement == 2) {
|
||||
scheme = Scheme::EconomyMaximum;
|
||||
} else if (powerManagement == 1) {
|
||||
scheme = Scheme::Auto;
|
||||
}
|
||||
GetFramework().GetPowerManager().SetScheme(scheme);
|
||||
}
|
||||
|
||||
+ (BOOL)routingDisclaimerApproved
|
||||
{
|
||||
bool enabled = false;
|
||||
@@ -185,4 +261,10 @@ NSString * const kUDFileLoggingEnabledKey = @"FileLoggingEnabledKey";
|
||||
[Logger setFileLoggingEnabled:fileLoggingEnabled];
|
||||
}
|
||||
|
||||
+ (NSInteger)logFileSize
|
||||
{
|
||||
uint64_t logFileSize = [Logger getLogFileSize];
|
||||
return logFileSize;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user