Browse Source

MyText加入textalagin

liukai 1 year ago
parent
commit
a02f2dbd74
2 changed files with 6 additions and 15 deletions
  1. 5 15
      lib/comm/widget/my_text_view.dart
  2. 1 0
      pubspec.yaml

+ 5 - 15
lib/comm/widget/my_text_view.dart

@@ -40,13 +40,13 @@ class MyTextView extends StatelessWidget {
   Color? borderColor = Colors.transparent;
   Color? borderColor = Colors.transparent;
   String content = "";
   String content = "";
   bool? singleLine = false;
   bool? singleLine = false;
-  bool? isBold = false;
   VoidCallback? onClick;
   VoidCallback? onClick;
   bool? isFontLight;
   bool? isFontLight;
   bool? isFontRegular;
   bool? isFontRegular;
   bool? isFontMedium;
   bool? isFontMedium;
   bool? isFontBold;
   bool? isFontBold;
   FontWeight? fontWeight;
   FontWeight? fontWeight;
+  TextAlign? textAlign;
 
 
   MyTextView(this.content,
   MyTextView(this.content,
       {this.textColor,
       {this.textColor,
@@ -66,14 +66,13 @@ class MyTextView extends StatelessWidget {
       this.margin,
       this.margin,
       this.fontSize,
       this.fontSize,
       this.singleLine,
       this.singleLine,
-      this.isBold,
       this.isFontLight,
       this.isFontLight,
       this.isFontRegular,
       this.isFontRegular,
       this.isFontMedium,
       this.isFontMedium,
       this.isFontBold,
       this.isFontBold,
       this.fontWeight,
       this.fontWeight,
+      this.textAlign,
       this.onClick}) {
       this.onClick}) {
-
     if (padding != null) {
     if (padding != null) {
       if (padding != null && padding! > 0) {
       if (padding != null && padding! > 0) {
         paddingLeft = padding;
         paddingLeft = padding;
@@ -95,25 +94,15 @@ class MyTextView extends StatelessWidget {
     onClick ??= () {};
     onClick ??= () {};
 
 
     if (isFontLight != null && isFontLight!) {
     if (isFontLight != null && isFontLight!) {
-
-       fontWeight = FontWeight.w300;
-
+      fontWeight = FontWeight.w300;
     } else if (isFontRegular != null && isFontRegular!) {
     } else if (isFontRegular != null && isFontRegular!) {
-
       fontWeight = FontWeight.w400;
       fontWeight = FontWeight.w400;
-
     } else if (isFontMedium != null && isFontMedium!) {
     } else if (isFontMedium != null && isFontMedium!) {
-
       fontWeight = FontWeight.w500;
       fontWeight = FontWeight.w500;
-
     } else if (isFontBold != null && isFontBold!) {
     } else if (isFontBold != null && isFontBold!) {
-
       fontWeight = FontWeight.w700;
       fontWeight = FontWeight.w700;
-
-    }  else {
-
+    } else {
       fontWeight = FontWeight.normal;
       fontWeight = FontWeight.normal;
-
     }
     }
   }
   }
 
 
@@ -131,6 +120,7 @@ class MyTextView extends StatelessWidget {
           onTap: onClick,
           onTap: onClick,
           child: Text(
           child: Text(
             content,
             content,
+            textAlign: textAlign ?? TextAlign.start,
             style: TextStyle(
             style: TextStyle(
               color: textColor,
               color: textColor,
               fontSize: fontSize ?? 14,
               fontSize: fontSize ?? 14,

+ 1 - 0
pubspec.yaml

@@ -87,6 +87,7 @@ flutter:
     - assets/images/job/
     - assets/images/job/
     - assets/images/talent/
     - assets/images/talent/
     - assets/images/message/
     - assets/images/message/
+    - assets/images/home/
 
 
   # An image asset can refer to one or more resolution-specific "variants", see
   # An image asset can refer to one or more resolution-specific "variants", see
   # https://flutter.dev/assets-and-images/#resolution-aware.
   # https://flutter.dev/assets-and-images/#resolution-aware.