add auto-size-text for installCard button
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
a2cb295a11
commit
1249776a21
flutter
@ -377,7 +377,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
fontSize: 13),
|
fontSize: 13),
|
||||||
).marginOnly(bottom: 20),
|
).marginOnly(bottom: 20),
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
Button(
|
FixedWidthButton(
|
||||||
|
width: 150,
|
||||||
padding: 8,
|
padding: 8,
|
||||||
isOutline: true,
|
isOutline: true,
|
||||||
text: translate(btnText),
|
text: translate(btnText),
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
import '../../common.dart';
|
import '../../common.dart';
|
||||||
|
|
||||||
class Button extends StatefulWidget {
|
class Button extends StatefulWidget {
|
||||||
GestureTapCallback onTap;
|
final GestureTapCallback onTap;
|
||||||
String text;
|
final String text;
|
||||||
double? textSize;
|
final double? textSize;
|
||||||
double? minWidth;
|
final double? minWidth;
|
||||||
bool isOutline;
|
final bool isOutline;
|
||||||
double? padding;
|
final double? padding;
|
||||||
Color? textColor;
|
final Color? textColor;
|
||||||
double? radius;
|
final double? radius;
|
||||||
Color? borderColor;
|
final Color? borderColor;
|
||||||
|
|
||||||
Button({
|
Button({
|
||||||
Key? key,
|
Key? key,
|
||||||
@ -82,3 +83,89 @@ class _ButtonState extends State<Button> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FixedWidthButton extends StatefulWidget {
|
||||||
|
final GestureTapCallback onTap;
|
||||||
|
final String text;
|
||||||
|
final double? textSize;
|
||||||
|
final double width;
|
||||||
|
final bool isOutline;
|
||||||
|
final double? padding;
|
||||||
|
final Color? textColor;
|
||||||
|
final double? radius;
|
||||||
|
final Color? borderColor;
|
||||||
|
final int? maxLines;
|
||||||
|
|
||||||
|
FixedWidthButton({
|
||||||
|
Key? key,
|
||||||
|
required this.width,
|
||||||
|
this.maxLines,
|
||||||
|
this.isOutline = false,
|
||||||
|
this.textSize,
|
||||||
|
this.padding,
|
||||||
|
this.textColor,
|
||||||
|
this.radius,
|
||||||
|
this.borderColor,
|
||||||
|
required this.onTap,
|
||||||
|
required this.text,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FixedWidthButton> createState() => _FixedWidthButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FixedWidthButtonState extends State<FixedWidthButton> {
|
||||||
|
RxBool hover = false.obs;
|
||||||
|
RxBool pressed = false.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Obx(() => InkWell(
|
||||||
|
onTapDown: (_) => pressed.value = true,
|
||||||
|
onTapUp: (_) => pressed.value = false,
|
||||||
|
onTapCancel: () => pressed.value = false,
|
||||||
|
onHover: (value) => hover.value = value,
|
||||||
|
onTap: widget.onTap,
|
||||||
|
child: Container(
|
||||||
|
width: widget.width,
|
||||||
|
padding: EdgeInsets.all(widget.padding ?? 4.5),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: pressed.value
|
||||||
|
? MyTheme.accent
|
||||||
|
: (widget.isOutline ? Colors.transparent : MyTheme.button),
|
||||||
|
border: Border.all(
|
||||||
|
color: pressed.value
|
||||||
|
? MyTheme.accent
|
||||||
|
: hover.value
|
||||||
|
? MyTheme.hoverBorder
|
||||||
|
: (widget.isOutline
|
||||||
|
? widget.borderColor ?? MyTheme.border
|
||||||
|
: MyTheme.button),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(widget.radius ?? 5),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: AutoSizeText(
|
||||||
|
translate(
|
||||||
|
widget.text,
|
||||||
|
),
|
||||||
|
maxLines: widget.maxLines ?? 1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: widget.textSize ?? 12.0,
|
||||||
|
color: widget.isOutline
|
||||||
|
? widget.textColor ??
|
||||||
|
Theme.of(context).textTheme.titleLarge?.color
|
||||||
|
: Colors.white),
|
||||||
|
).marginSymmetric(horizontal: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -50,6 +50,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.9.0"
|
version: "2.9.0"
|
||||||
|
auto_size_text:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: auto_size_text
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
back_button_interceptor:
|
back_button_interceptor:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -119,28 +126,28 @@ packages:
|
|||||||
name: cached_network_image
|
name: cached_network_image
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.2.2"
|
version: "3.2.1"
|
||||||
cached_network_image_platform_interface:
|
cached_network_image_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: cached_network_image_platform_interface
|
name: cached_network_image_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "1.0.0"
|
||||||
cached_network_image_web:
|
cached_network_image_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: cached_network_image_web
|
name: cached_network_image_web
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.1"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -161,7 +168,7 @@ packages:
|
|||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.0"
|
||||||
code_builder:
|
code_builder:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -243,8 +250,8 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "318ebd0a70cc5868911591c04f84bf1541f1bf4e"
|
ref: "541f05f766c3f72984ff40b70dd3c7d061f2ce61"
|
||||||
resolved-ref: "318ebd0a70cc5868911591c04f84bf1541f1bf4e"
|
resolved-ref: "541f05f766c3f72984ff40b70dd3c7d061f2ce61"
|
||||||
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
|
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
@ -504,7 +511,7 @@ packages:
|
|||||||
name: icons_launcher
|
name: icons_launcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.5"
|
version: "2.0.4"
|
||||||
image:
|
image:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -602,7 +609,7 @@ packages:
|
|||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.5"
|
version: "0.1.4"
|
||||||
menu_base:
|
menu_base:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -616,7 +623,7 @@ packages:
|
|||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.7.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -693,7 +700,7 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.2"
|
version: "1.8.1"
|
||||||
path_drawing:
|
path_drawing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -959,7 +966,7 @@ packages:
|
|||||||
name: sqflite
|
name: sqflite
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0+1"
|
version: "2.0.3+1"
|
||||||
sqflite_common:
|
sqflite_common:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1301,7 +1308,7 @@ packages:
|
|||||||
name: zxing2
|
name: zxing2
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.1"
|
version: "0.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.18.0 <3.0.0"
|
dart: ">=2.17.1 <3.0.0"
|
||||||
flutter: ">=3.3.0"
|
flutter: ">=3.0.0"
|
||||||
|
@ -98,6 +98,7 @@ dependencies:
|
|||||||
uni_links: ^0.5.1
|
uni_links: ^0.5.1
|
||||||
uni_links_desktop: ^0.1.3
|
uni_links_desktop: ^0.1.3
|
||||||
path: ^1.8.1
|
path: ^1.8.1
|
||||||
|
auto_size_text: ^3.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
icons_launcher: ^2.0.4
|
icons_launcher: ^2.0.4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user