mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feat: Android TV support (#503)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
7ab8c015b9
commit
c299492d6d
168 changed files with 12019 additions and 3073 deletions
42
lib/widgets/media_query_scaler.dart
Normal file
42
lib/widgets/media_query_scaler.dart
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class MediaQueryScaler extends StatelessWidget {
|
||||
final Widget child;
|
||||
final bool enable;
|
||||
final double scale;
|
||||
|
||||
const MediaQueryScaler({
|
||||
required this.child,
|
||||
required this.enable,
|
||||
this.scale = 1.35,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!enable) return child;
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final screenSize = MediaQuery.sizeOf(context) * scale;
|
||||
|
||||
final scaledMedia = mediaQuery.copyWith(
|
||||
navigationMode: NavigationMode.directional,
|
||||
size: screenSize,
|
||||
padding: mediaQuery.padding * scale,
|
||||
viewInsets: mediaQuery.viewInsets * scale,
|
||||
viewPadding: mediaQuery.viewPadding * scale,
|
||||
devicePixelRatio: mediaQuery.devicePixelRatio * scale,
|
||||
);
|
||||
|
||||
return FittedBox(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
width: screenSize.width,
|
||||
height: screenSize.height,
|
||||
child: MediaQuery(
|
||||
data: scaledMedia,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue