9#import "RDPOverlayStyle.h"
12void RDPApplyKeyCapColors(UIButtonConfiguration *config, BOOL latched, BOOL pressed);
14BOOL RDPSupportLiquidGlass(
void);
16UIVisualEffectView *RDPCreateGlassCapsuleView(
void)
18 UIVisualEffect *effect;
19#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000
20 if (@available(iOS 26.0, *))
22 effect = [UIGlassEffect effectWithStyle:UIGlassEffectStyleRegular];
27 effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemChromeMaterial];
30 UIVisualEffectView *view = [[[UIVisualEffectView alloc] initWithEffect:effect] autorelease];
31#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000
32 if (@available(iOS 26.0, *))
34 [view setCornerConfiguration:[UICornerConfiguration capsuleConfiguration]];
39 [view setClipsToBounds:YES];
40 [[view layer] setCornerCurve:kCACornerCurveContinuous];
45void RDPUpdateGlassCapsuleCorners(UIVisualEffectView *view)
47 if (RDPSupportLiquidGlass() == YES)
52 CGSize size = [view bounds].size;
53 [[view layer] setCornerRadius:MIN(size.width, size.height) * 0.5];
56UIImage *RDPWindowsLogoImage(CGFloat size)
58 UIGraphicsImageRenderer *renderer =
59 [[[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(size, size)] autorelease];
62 UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *context) {
63 const CGFloat gap = MAX(1.0, round(size * 0.08));
64 const CGFloat tile = (size - gap) * 0.5;
65 [[UIColor blackColor] setFill];
66 UIRectFill(CGRectMake(0, 0, tile, tile));
67 UIRectFill(CGRectMake(tile + gap, 0, tile, tile));
68 UIRectFill(CGRectMake(0, tile + gap, tile, tile));
69 UIRectFill(CGRectMake(tile + gap, tile + gap, tile, tile));
71 return [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
74UIButton *RDPCreateKeyButton(NSString *title, UIImage *image)
76 UIButtonConfiguration *config = [UIButtonConfiguration grayButtonConfiguration];
77 [config setCornerStyle:UIButtonConfigurationCornerStyleMedium];
78 [config setContentInsets:NSDirectionalEdgeInsetsMake(4.0, 4.0, 4.0, 4.0)];
82 [config setTitle:title];
83 [config setTitleLineBreakMode:NSLineBreakByClipping];
85 else if (image != nil)
87 [config setImage:image];
94 RDPApplyKeyCapColors(config, NO, NO);
96 UIButton *btn = [UIButton buttonWithConfiguration:config primaryAction:nil];
97 [btn setExclusiveTouch:YES];
98 [btn setConfigurationUpdateHandler:^(UIButton *button) {
99 UIButtonConfiguration *updated = [[[button configuration] copy] autorelease];
100 RDPApplyKeyCapColors(updated, [button isSelected], [button isHighlighted]);
101 [button setConfiguration:updated];
106UIButton *RDPCreateTabButton(NSString *title)
108 UIButton *btn = RDPCreateKeyButton(title, nil);
113 UIButtonConfiguration *config = [[[btn configuration] copy] autorelease];
114 [config setCornerStyle:UIButtonConfigurationCornerStyleCapsule];
116 [btn setConfiguration:config];
120void RDPApplyKeyCapColors(UIButtonConfiguration *config, BOOL latched, BOOL pressed)
124 background = pressed ? [UIColor secondaryLabelColor] : [UIColor labelColor];
126 background = [UIColor colorWithDynamicProvider:^UIColor *(UITraitCollection *traits) {
127 if ([traits userInterfaceStyle] == UIUserInterfaceStyleDark)
128 return pressed ? [UIColor systemGray2Color] : [UIColor systemGray3Color];
129 return pressed ? [UIColor systemGray4Color] : [UIColor whiteColor];
132 [[config background] setBackgroundColor:background];
134 setBaseForegroundColor:latched ? [UIColor systemBackgroundColor] : [UIColor labelColor]];
137BOOL RDPSupportLiquidGlass(
void)
139#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000
140 if (@available(iOS 26.0, *))