feat: screen adaptation; set font family to 'Noto Sans CJK SC'
This commit is contained in:
+33
-20
@@ -59,6 +59,7 @@ class MyApp extends StatelessWidget {
|
|||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
|
fontFamily: 'Noto Sans CJK SC',
|
||||||
),
|
),
|
||||||
home: const MyHomePage(),
|
home: const MyHomePage(),
|
||||||
);
|
);
|
||||||
@@ -144,9 +145,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (MediaQuery.of(context).size.shortestSide < 10) {
|
var shortestSide = MediaQuery.of(context).size.shortestSide;
|
||||||
|
if (shortestSide < 10) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var scale = shortestSide / 2000;
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if ([
|
if ([
|
||||||
@@ -170,11 +175,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Center(
|
Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24 * scale),
|
||||||
color: Colors.grey.shade700.withOpacity(0.9),
|
color: Colors.grey.shade700.withOpacity(0.9),
|
||||||
),
|
),
|
||||||
width: 460,
|
width: 460 * scale,
|
||||||
height: 360,
|
height: 360 * scale,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
@@ -187,8 +192,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Status.found: 'assets/ok.gif',
|
Status.found: 'assets/ok.gif',
|
||||||
Status.notFound: 'assets/no.gif',
|
Status.notFound: 'assets/no.gif',
|
||||||
}[status]!,
|
}[status]!,
|
||||||
width: 200,
|
width: 200 * scale,
|
||||||
height: 200,
|
height: 200 * scale,
|
||||||
fit: BoxFit.fitHeight,
|
fit: BoxFit.fitHeight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -198,9 +203,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Status.found: '小浣熊成功找到${codes.length}个二维码!',
|
Status.found: '小浣熊成功找到${codes.length}个二维码!',
|
||||||
Status.notFound: '小浣熊找了一圈,啥也没发现……',
|
Status.notFound: '小浣熊找了一圈,啥也没发现……',
|
||||||
}[status]!,
|
}[status]!,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 28,
|
fontSize: 28 * scale,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -212,7 +217,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
(code) {
|
(code) {
|
||||||
var centerAndSize = getCenterAndSizeOfPoints(code.points);
|
var centerAndSize = getCenterAndSizeOfPoints(code.points);
|
||||||
var center = centerAndSize.center - currentWindowPos;
|
var center = centerAndSize.center - currentWindowPos;
|
||||||
var size = max(centerAndSize.size, 300);
|
var size = max(centerAndSize.size, 300) * scale;
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: center.dx - size / 2,
|
left: center.dx - size / 2,
|
||||||
top: center.dy - size / 2,
|
top: center.dy - size / 2,
|
||||||
@@ -229,10 +234,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'二维码内容:',
|
'二维码内容:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 28,
|
fontSize: 28 * scale,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
@@ -240,11 +245,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
code.content.split('').join('\u{200B}'),
|
code.content.split('').join('\u{200B}'),
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 28,
|
fontSize: 28 * scale,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
minFontSize: 16,
|
minFontSize: 1,
|
||||||
maxFontSize: 46,
|
maxFontSize: 46,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -252,7 +257,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
FilledButton(
|
Flexible(
|
||||||
|
child: FittedBox(
|
||||||
|
child: FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Clipboard.setData(
|
Clipboard.setData(
|
||||||
ClipboardData(text: code.content),
|
ClipboardData(text: code.content),
|
||||||
@@ -262,13 +269,17 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: const Text(
|
child: Text(
|
||||||
'复制',
|
'复制',
|
||||||
style: TextStyle(fontSize: 28),
|
style: TextStyle(fontSize: 28 * scale),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: size / 20),
|
SizedBox(width: size / 20),
|
||||||
FilledButton(
|
Flexible(
|
||||||
|
child: FittedBox(
|
||||||
|
child: FilledButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var url = code.content;
|
var url = code.content;
|
||||||
if (await canLaunchUrlString(url)) {
|
if (await canLaunchUrlString(url)) {
|
||||||
@@ -277,9 +288,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text(
|
child: Text(
|
||||||
'打开',
|
'打开',
|
||||||
style: TextStyle(fontSize: 28),
|
style: TextStyle(fontSize: 28 * scale),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user