liquid glass: settings menu navigation bar
This commit is contained in:
@@ -16,11 +16,6 @@
|
||||
|
||||
@interface DataManager : NSObject
|
||||
|
||||
typedef NS_ENUM(NSUInteger, UINavigationBarHeight) {
|
||||
UINavigationBarHeightIPad = 50,
|
||||
UINavigationBarHeightIPhone = 44
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, ControllerGyroSwitchMode) {
|
||||
ControllerGyroSwitchDisabled,
|
||||
ControllerGyroSwitchPressToToggle,
|
||||
|
||||
@@ -204,7 +204,7 @@ class ThemeManager: NSObject {
|
||||
let traits = UITraitCollection(userInterfaceStyle: .dark)
|
||||
return UIColor.label.resolvedColor(with: traits)
|
||||
} else {
|
||||
return UIColor.black
|
||||
return UIColor.white
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,24 @@ import Foundation
|
||||
|
||||
@objc static let menuSeparatorWidth: CGFloat = 0.7
|
||||
@objc static let menuSectionSeparatorWidth: CGFloat = 0.7
|
||||
|
||||
@objc static var hostViewNavigationBarHeight: CGFloat {
|
||||
switch UIDevice.current.userInterfaceIdiom {
|
||||
case .phone:
|
||||
return liquidGlassEnabled ? 54 : 44
|
||||
case .pad:
|
||||
return liquidGlassEnabled ? 54 : 50
|
||||
default:
|
||||
return liquidGlassEnabled ? 54 : 50
|
||||
}
|
||||
}
|
||||
|
||||
@objc static var settingsMenuNavigationBarHeight: CGFloat {
|
||||
// return isIPhone() ? 44 : hostViewNavigationBarHeight
|
||||
return liquidGlassEnabled ? hostViewNavigationBarHeight+5 : hostViewNavigationBarHeight
|
||||
}
|
||||
|
||||
@objc static var dockedNavBarTopAnchorOffset: CGFloat {
|
||||
return liquidGlassEnabled ? 10 : 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1389,22 +1389,26 @@ static NSMutableSet* hostList;
|
||||
|
||||
- (UIBarButtonItem *)createAddHostButton{
|
||||
// 创建按钮
|
||||
|
||||
bool liquidGlassEnabled = GenericUtils.liquidGlassEnabled;
|
||||
// bool liquidGlassEnabled = false;
|
||||
|
||||
CGFloat buttonHeight = 30;
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
button.backgroundColor = GenericUtils.liquidGlassEnabled ? UIColor.whiteColor : [ThemeManager appPrimaryColor]; // #0A85FF
|
||||
button.backgroundColor = liquidGlassEnabled ? [ThemeManager appPrimaryColor] : [ThemeManager appPrimaryColor]; // #0A85FF
|
||||
button.layer.cornerRadius = buttonHeight/2;
|
||||
button.clipsToBounds = !GenericUtils.liquidGlassEnabled;
|
||||
button.clipsToBounds = !liquidGlassEnabled;
|
||||
|
||||
// 设置图标(SF Symbol)
|
||||
|
||||
if (@available(iOS 13.0, *)) {
|
||||
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration
|
||||
configurationWithPointSize:GenericUtils.liquidGlassEnabled ? 18.7 :17
|
||||
weight:GenericUtils.liquidGlassEnabled ? UIImageSymbolWeightRegular :UIImageSymbolWeightMedium];
|
||||
configurationWithPointSize:liquidGlassEnabled ? 18.7 :17
|
||||
weight:liquidGlassEnabled ? UIImageSymbolWeightRegular :UIImageSymbolWeightMedium];
|
||||
UIImage *image = [UIImage systemImageNamed:@"plus.circle" withConfiguration:config];
|
||||
[button setImage:image forState:UIControlStateNormal];
|
||||
button.imageEdgeInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 7.6, 0.75, 0) : UIEdgeInsetsZero;;
|
||||
NSString* buttonStringHead = GenericUtils.liquidGlassEnabled ? @" " : @"";
|
||||
button.imageEdgeInsets = liquidGlassEnabled ? UIEdgeInsetsMake(0, 7.6, 0.75, 0) : UIEdgeInsetsZero;;
|
||||
NSString* buttonStringHead = liquidGlassEnabled ? @" " : @"";
|
||||
[button setTitle: [buttonStringHead stringByAppendingString:
|
||||
[LocalizationHelper localizedStringForKey:@" Add Host"]]
|
||||
forState:UIControlStateNormal]; // 注意空格用于间隔
|
||||
@@ -1413,10 +1417,10 @@ static NSMutableSet* hostList;
|
||||
}
|
||||
// [button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
||||
|
||||
button.titleLabel.font = [UIFont systemFontOfSize:GenericUtils.liquidGlassEnabled ? 17 : 16 weight:UIFontWeightMedium];
|
||||
button.titleLabel.font = [UIFont systemFontOfSize:liquidGlassEnabled ? 17 : 16 weight:UIFontWeightMedium];
|
||||
// 文字颜色设置为 tintColor 控制
|
||||
if(GenericUtils.liquidGlassEnabled) button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0.9, 0);
|
||||
button.tintColor = GenericUtils.liquidGlassEnabled ? [ThemeManager appPrimaryColor] : UIColor.whiteColor;
|
||||
if(liquidGlassEnabled) button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0.9, 0);
|
||||
button.tintColor = liquidGlassEnabled ? [ThemeManager appPrimaryColor] : UIColor.whiteColor;
|
||||
[button setTitleColor:button.tintColor forState:UIControlStateNormal];
|
||||
// button.tintColor = UIColor.whiteColor;
|
||||
// [button setTitleColor:button.tintColor forState:UIControlStateNormal];
|
||||
@@ -1484,10 +1488,6 @@ static NSMutableSet* hostList;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)getStandardNavBarHeight{
|
||||
return [self isIPhone] ? UINavigationBarHeightIPhone : UINavigationBarHeightIPad;
|
||||
}
|
||||
|
||||
- (void)applyNavBarAppearance{
|
||||
if (@available(iOS 13.0, *)) {
|
||||
self.navigationController.navigationBar.standardAppearance.backgroundColor = [UIColor clearColor]; // old ios depend on this, do not remove
|
||||
@@ -1519,6 +1519,12 @@ static NSMutableSet* hostList;
|
||||
|
||||
self->_addHostButton = [self createAddHostButton];
|
||||
self->_helpButton = [self createHelpButton];
|
||||
if (GenericUtils.liquidGlassEnabled) {
|
||||
if (@available(iOS 26.0, *)) {
|
||||
// _addHostButton.hidesSharedBackground = true;
|
||||
// _helpButton.hidesSharedBackground = true;
|
||||
}
|
||||
}
|
||||
//[self setupHostViewTitle];
|
||||
|
||||
|
||||
@@ -1535,6 +1541,10 @@ static NSMutableSet* hostList;
|
||||
UIImage *image = [[UIImage systemImageNamed:@"sidebar.left" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
[_settingsButton setImage:image];
|
||||
_settingsButton.imageInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 0, 0, 0.55) : UIEdgeInsetsMake(10, 10, 0, 0);
|
||||
if(GenericUtils.liquidGlassEnabled){
|
||||
// if(@available(iOS 26.0, *)) _settingsButton.hidesSharedBackground = YES;
|
||||
_settingsButton.tintColor = [ThemeManager appPrimaryColor];
|
||||
}
|
||||
} else {
|
||||
[_settingsButton setTitle:[LocalizationHelper localizedStringForKey:@"Settings"]];
|
||||
}
|
||||
|
||||
@@ -165,8 +165,9 @@ static CGFloat scaledValue( CGFloat v1, CGFloat min2, CGFloat max2, CGFloat min1
|
||||
// reserve height for navigation bar
|
||||
]];
|
||||
|
||||
CGFloat navBarHeight = [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone ? UINavigationBarHeightIPhone : UINavigationBarHeightIPad;
|
||||
|
||||
// CGFloat navBarHeight = [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone ? UINavigationBarHeightIPhone : UINavigationBarHeightIPad;
|
||||
CGFloat navBarHeight = GenericUtils.settingsMenuNavigationBarHeight;
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_rearNavView.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor constant:navBarHeight],
|
||||
[_rearNavView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
|
||||
@@ -911,7 +912,7 @@ const int FrontViewPositionNone = 0xff;
|
||||
}
|
||||
else{
|
||||
// _rearViewRevealWidth = _rearViewRevealWidth + 20;
|
||||
[self setupNavigationBar];
|
||||
// [self setupNavigationBar];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -963,6 +964,7 @@ const int FrontViewPositionNone = 0xff;
|
||||
navBarAppearanceStandard.backgroundImage = nil;
|
||||
_dockedNavBar.standardAppearance = navBarAppearanceStandard;
|
||||
_dockedNavBar.scrollEdgeAppearance = navBarAppearanceStandard;
|
||||
_dockedNavBar.shadowImage = nil;
|
||||
} else {
|
||||
_dockedNavBar.barTintColor = [UIColor clearColor];
|
||||
_dockedNavBar.barTintColor = [ThemeManager menuBackgroundColor];
|
||||
@@ -989,7 +991,7 @@ const int FrontViewPositionNone = 0xff;
|
||||
|
||||
// 设置导航栏约束
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_dockedNavBar.topAnchor constraintEqualToAnchor:_contentView.rearNavView.topAnchor],
|
||||
[_dockedNavBar.topAnchor constraintEqualToAnchor:_contentView.rearNavView.topAnchor constant:GenericUtils.dockedNavBarTopAnchorOffset],
|
||||
[_dockedNavBar.bottomAnchor constraintEqualToAnchor:_contentView.rearNavView.bottomAnchor],
|
||||
[_dockedNavBar.leadingAnchor constraintEqualToAnchor:_contentView.rearNavView.leadingAnchor],
|
||||
[_dockedNavBar.widthAnchor constraintEqualToConstant:_rearViewRevealWidth],
|
||||
@@ -1006,10 +1008,15 @@ const int FrontViewPositionNone = 0xff;
|
||||
[backButton setAction:@selector(foldRearView)];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
[backButton setTitle:nil];
|
||||
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:23 weight:UIImageSymbolWeightMedium ];
|
||||
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:GenericUtils.liquidGlassEnabled ? 18 : 23 weight:UIImageSymbolWeightMedium];
|
||||
|
||||
UIImage *image = [[UIImage systemImageNamed:@"sidebar.left" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
[backButton setImage:image];
|
||||
backButton.imageInsets = UIEdgeInsetsMake(20, 10, 0, 0);
|
||||
backButton.imageInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 0, 0, 0.55) : UIEdgeInsetsMake(20, 10, 0, 0);
|
||||
if(GenericUtils.liquidGlassEnabled){
|
||||
// if(@available(iOS 26.0, *)) backButton.hidesSharedBackground = YES;
|
||||
backButton.tintColor = [ThemeManager appPrimaryColor];
|
||||
}
|
||||
} else {
|
||||
[backButton setTitle:[LocalizationHelper localizedStringForKey:@"Collapse"]];
|
||||
}
|
||||
@@ -1024,10 +1031,17 @@ const int FrontViewPositionNone = 0xff;
|
||||
[_disconnectButton setAction:@selector(disconnectRemoteSession)];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
[_disconnectButton setTitle:nil];
|
||||
UIImage *image = [[UIImage imageNamed:@"disconnect.svg" ] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
UIImage *image;
|
||||
|
||||
if(GenericUtils.liquidGlassEnabled){
|
||||
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:16 weight:UIImageSymbolWeightSemibold];
|
||||
image = [[UIImage systemImageNamed:@"rectangle.portrait.and.arrow.right" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
}
|
||||
else image = [[UIImage imageNamed:@"disconnect.svg" ] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
|
||||
[_disconnectButton setImage:image];
|
||||
//_disconnectButton.imageInsets = UIEdgeInsetsMake(5, 5, 5, 5);
|
||||
if(GenericUtils.liquidGlassEnabled) _disconnectButton.imageInsets = UIEdgeInsetsMake(5, 5, 5, 5);
|
||||
|
||||
_disconnectButton.tintColor = [ThemeManager appPrimaryColor];
|
||||
} else {
|
||||
[_disconnectButton setTitle:[LocalizationHelper localizedStringForKey:@"Disconnect"]];
|
||||
@@ -1047,10 +1061,12 @@ const int FrontViewPositionNone = 0xff;
|
||||
//[moreButton setAction:@selector(moreButtonTapped:)];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
[_moreButton setTitle:nil];
|
||||
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:23 weight:UIImageSymbolWeightMedium ];
|
||||
UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:GenericUtils.liquidGlassEnabled ? 18 : 23
|
||||
weight:GenericUtils.liquidGlassEnabled ? UIImageSymbolWeightMedium : UIImageSymbolWeightMedium];
|
||||
UIImage *image = [[UIImage systemImageNamed:@"ellipsis.circle" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
[_moreButton setImage:image];
|
||||
_moreButton.imageInsets = UIEdgeInsetsMake(20, 0, 0, -10);
|
||||
_moreButton.imageInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 0, 0, 0.75) : UIEdgeInsetsMake(20, 0, 0, -10);
|
||||
if(GenericUtils.liquidGlassEnabled) _moreButton.tintColor = [ThemeManager appPrimaryColor];
|
||||
} else {
|
||||
[_moreButton setTitle:[LocalizationHelper localizedStringForKey:@"Options"]];
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ CGSize resolutionTable[RESOLUTION_TABLE_SIZE];
|
||||
}
|
||||
|
||||
// Add a bit of padding so the view doesn't end right at the button of the display
|
||||
self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width, _parentStack.frame.size.height + [self getStandardNavBarHeight] + 20);
|
||||
self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width, _parentStack.frame.size.height + GenericUtils.settingsMenuNavigationBarHeight + 20);
|
||||
double delayInSeconds = 3;
|
||||
// Convert the delay into a dispatch_time_t value
|
||||
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
||||
@@ -601,10 +601,6 @@ BOOL isCustomResolution(int resolutionSelected) {
|
||||
return [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone;
|
||||
}
|
||||
|
||||
- (CGFloat)getStandardNavBarHeight{
|
||||
return [self isIPhone] ? UINavigationBarHeightIPhone : UINavigationBarHeightIPad;
|
||||
}
|
||||
|
||||
- (void)initParentStack{
|
||||
self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
|
||||
// 可选:确保 scrollView 开启垂直滚动
|
||||
@@ -619,7 +615,7 @@ BOOL isCustomResolution(int resolutionSelected) {
|
||||
if(!_parentStack.superview){
|
||||
[self.scrollView addSubview:_parentStack];
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_parentStack.topAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.topAnchor constant: currentSettingsMenuMode == AllSettings ? [self getStandardNavBarHeight] : [self getStandardNavBarHeight]+10],
|
||||
[_parentStack.topAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.topAnchor constant: currentSettingsMenuMode == AllSettings ? GenericUtils.settingsMenuNavigationBarHeight : GenericUtils.settingsMenuNavigationBarHeight+10],
|
||||
[_parentStack.bottomAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.bottomAnchor constant:-20],
|
||||
]];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user