fix: win10, border (#10753)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2025-02-10 13:50:28 +08:00 committed by GitHub
parent 2a0e8c109b
commit a039741e5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 94 additions and 27 deletions

View file

@ -2566,6 +2566,8 @@ bool get kUseCompatibleUiMode =>
isWindows &&
const [WindowsTarget.w7].contains(windowsBuildNumber.windowsVersion);
bool get isWin10 => windowsBuildNumber.windowsVersion == WindowsTarget.w10;
class ServerConfig {
late String idServer;
late String relayServer;
@ -3638,3 +3640,59 @@ extension WorkaroundFreezeLinuxMint on Widget {
}
}
}
// Don't use `extension` here, the border looks weird if using `extension` in my test.
Widget workaroundWindowBorder(BuildContext context, Widget child) {
if (!isWin10) {
return child;
}
final isLight = Theme.of(context).brightness == Brightness.light;
final borderColor = isLight ? Colors.black87 : Colors.grey;
final width = isLight ? 0.5 : 0.1;
getBorderWidget(Widget child) {
return Obx(() =>
(stateGlobal.isMaximized.isTrue || stateGlobal.fullscreen.isTrue)
? Offstage()
: child);
}
final List<Widget> borders = [
getBorderWidget(Container(
color: borderColor,
height: width + 0.1,
))
];
if (kWindowType == WindowType.Main && !isLight) {
borders.addAll([
getBorderWidget(Align(
alignment: Alignment.topLeft,
child: Container(
color: borderColor,
width: width,
),
)),
getBorderWidget(Align(
alignment: Alignment.topRight,
child: Container(
color: borderColor,
width: width,
),
)),
getBorderWidget(Align(
alignment: Alignment.bottomCenter,
child: Container(
color: borderColor,
height: width,
),
)),
]);
}
return Stack(
children: [
child,
...borders,
],
);
}