|
|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:queuing_system/core/config/size_config.dart';
|
|
|
|
|
|
|
|
|
|
@ -31,8 +30,8 @@ class AppText extends StatefulWidget {
|
|
|
|
|
final TextDecoration textDecoration;
|
|
|
|
|
final bool isCopyable;
|
|
|
|
|
|
|
|
|
|
AppText(
|
|
|
|
|
this.text, {
|
|
|
|
|
const AppText(
|
|
|
|
|
this.text, {Key key,
|
|
|
|
|
this.color = Colors.black,
|
|
|
|
|
this.fontWeight,
|
|
|
|
|
this.variant,
|
|
|
|
|
@ -59,7 +58,7 @@ class AppText extends StatefulWidget {
|
|
|
|
|
this.textDecoration,
|
|
|
|
|
this.letterSpacing,
|
|
|
|
|
this.isCopyable = false,
|
|
|
|
|
});
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_AppTextState createState() => _AppTextState();
|
|
|
|
|
@ -72,9 +71,9 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
@override
|
|
|
|
|
void didUpdateWidget(covariant AppText oldWidget) {
|
|
|
|
|
setState(() {
|
|
|
|
|
if (widget.style == "overline")
|
|
|
|
|
if (widget.style == "overline") {
|
|
|
|
|
text = widget.text.toUpperCase();
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
text = widget.text;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -84,9 +83,9 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
hidden = widget.readMore;
|
|
|
|
|
if (widget.style == "overline")
|
|
|
|
|
if (widget.style == "overline") {
|
|
|
|
|
text = widget.text.toUpperCase();
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
text = widget.text;
|
|
|
|
|
}
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -133,7 +132,7 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
widget.readMore &&
|
|
|
|
|
text.length > widget.maxLength)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0),
|
|
|
|
|
padding: const EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0),
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
@ -158,42 +157,40 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
if (widget.isCopyable) {
|
|
|
|
|
return Theme(
|
|
|
|
|
data: ThemeData(
|
|
|
|
|
textSelectionColor: Colors.lightBlueAccent,
|
|
|
|
|
textSelectionTheme: const TextSelectionThemeData(selectionColor: Colors.lightBlueAccent),
|
|
|
|
|
),
|
|
|
|
|
child: Container(
|
|
|
|
|
child: SelectableText(
|
|
|
|
|
!hidden
|
|
|
|
|
? text
|
|
|
|
|
: (text.substring(
|
|
|
|
|
0,
|
|
|
|
|
text.length > widget.maxLength
|
|
|
|
|
? widget.maxLength
|
|
|
|
|
: text.length)),
|
|
|
|
|
textAlign: widget.textAlign,
|
|
|
|
|
// overflow: widget.maxLines != null
|
|
|
|
|
// ? ((widget.maxLines > 1)
|
|
|
|
|
// ? TextOverflow.fade
|
|
|
|
|
// : TextOverflow.ellipsis)
|
|
|
|
|
// : null,
|
|
|
|
|
maxLines: widget.maxLines ?? null,
|
|
|
|
|
style: widget.style != null
|
|
|
|
|
? _getFontStyle().copyWith(
|
|
|
|
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
|
|
|
|
color: widget.color,
|
|
|
|
|
fontWeight: widget.fontWeight ?? _getFontWeight(),
|
|
|
|
|
height: widget.fontHeight)
|
|
|
|
|
: TextStyle(
|
|
|
|
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
|
|
|
|
color:
|
|
|
|
|
widget.color != null ? widget.color : Color(0xff000000),
|
|
|
|
|
fontSize: widget.fontSize ?? _getFontSize(),
|
|
|
|
|
letterSpacing: widget.letterSpacing ??
|
|
|
|
|
(widget.variant == "overline" ? 1.5 : null),
|
|
|
|
|
fontWeight: widget.fontWeight ?? _getFontWeight(),
|
|
|
|
|
fontFamily: widget.fontFamily ?? 'Poppins',
|
|
|
|
|
decoration: widget.textDecoration,
|
|
|
|
|
height: widget.fontHeight),
|
|
|
|
|
),
|
|
|
|
|
child: SelectableText(
|
|
|
|
|
!hidden
|
|
|
|
|
? text
|
|
|
|
|
: (text.substring(
|
|
|
|
|
0,
|
|
|
|
|
text.length > widget.maxLength
|
|
|
|
|
? widget.maxLength
|
|
|
|
|
: text.length)),
|
|
|
|
|
textAlign: widget.textAlign,
|
|
|
|
|
// overflow: widget.maxLines != null
|
|
|
|
|
// ? ((widget.maxLines > 1)
|
|
|
|
|
// ? TextOverflow.fade
|
|
|
|
|
// : TextOverflow.ellipsis)
|
|
|
|
|
// : null,
|
|
|
|
|
maxLines: widget.maxLines,
|
|
|
|
|
style: widget.style != null
|
|
|
|
|
? _getFontStyle().copyWith(
|
|
|
|
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
|
|
|
|
color: widget.color,
|
|
|
|
|
fontWeight: widget.fontWeight ?? _getFontWeight(),
|
|
|
|
|
height: widget.fontHeight)
|
|
|
|
|
: TextStyle(
|
|
|
|
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
|
|
|
|
color:
|
|
|
|
|
widget.color ?? const Color(0xff000000),
|
|
|
|
|
fontSize: widget.fontSize ?? _getFontSize(),
|
|
|
|
|
letterSpacing: widget.letterSpacing ??
|
|
|
|
|
(widget.variant == "overline" ? 1.5 : null),
|
|
|
|
|
fontWeight: widget.fontWeight ?? _getFontWeight(),
|
|
|
|
|
fontFamily: widget.fontFamily ?? 'Poppins',
|
|
|
|
|
decoration: widget.textDecoration,
|
|
|
|
|
height: widget.fontHeight),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
@ -211,7 +208,7 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
? TextOverflow.fade
|
|
|
|
|
: TextOverflow.ellipsis)
|
|
|
|
|
: null,
|
|
|
|
|
maxLines: widget.maxLines ?? null,
|
|
|
|
|
maxLines: widget.maxLines,
|
|
|
|
|
style: widget.style != null
|
|
|
|
|
? _getFontStyle().copyWith(
|
|
|
|
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
|
|
|
|
@ -220,7 +217,7 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
height: widget.fontHeight)
|
|
|
|
|
: TextStyle(
|
|
|
|
|
fontStyle: widget.italic ? FontStyle.italic : null,
|
|
|
|
|
color: widget.color != null ? widget.color : Colors.black,
|
|
|
|
|
color: widget.color ?? Colors.black,
|
|
|
|
|
fontSize: widget.fontSize ?? _getFontSize(),
|
|
|
|
|
letterSpacing: widget.letterSpacing ??
|
|
|
|
|
(widget.variant == "overline" ? 1.5 : null),
|
|
|
|
|
@ -257,7 +254,7 @@ class _AppTextState extends State<AppText> {
|
|
|
|
|
case "button":
|
|
|
|
|
return Theme.of(context).textTheme.button;
|
|
|
|
|
default:
|
|
|
|
|
return TextStyle();
|
|
|
|
|
return const TextStyle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|