click_tel_item.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/resources.dart';
  3. class ClickTelItem extends StatelessWidget {
  4. const ClickTelItem({
  5. Key key,
  6. this.onTap,
  7. @required this.title,
  8. this.content: "",
  9. this.hintText:"",
  10. this.textAlign: TextAlign.start,
  11. this.maxLines: 1
  12. }): super(key: key);
  13. final GestureTapCallback onTap;
  14. final String title;
  15. final String content;
  16. final String hintText;
  17. final TextAlign textAlign;
  18. final int maxLines;
  19. @override
  20. Widget build(BuildContext context) {
  21. return InkWell(
  22. onTap: onTap,
  23. child: Container(
  24. padding: const EdgeInsets.fromLTRB(15, 15.0, 15.0, 15.0),
  25. constraints: BoxConstraints(
  26. maxHeight: double.infinity,
  27. minHeight: 50.0
  28. ),
  29. width: double.infinity,
  30. decoration: BoxDecoration(
  31. color: Colors.white,
  32. border: Border(
  33. bottom: Divider.createBorderSide(context, width: 0.6),
  34. )
  35. ),
  36. child: Row(
  37. //为了数字类文字居中
  38. crossAxisAlignment: maxLines == 1 ? CrossAxisAlignment.center : CrossAxisAlignment.start,
  39. children: <Widget>[
  40. Padding(
  41. padding: const EdgeInsets.only(right: 5.0),
  42. child: Text(title),
  43. ),
  44. const Spacer(),
  45. Expanded(
  46. flex: 4,
  47. child: Padding(
  48. padding: const EdgeInsets.only(right: 8.0, left: 16.0),
  49. child: Text(
  50. content.length==0?hintText:content,
  51. maxLines: maxLines,
  52. textAlign: maxLines == 1 ? TextAlign.right : textAlign,
  53. overflow: TextOverflow.ellipsis,
  54. style: TextStyle(fontSize: 14,color: content.length==0?Colours.text_gray_c:Colors.black))
  55. ),
  56. ),
  57. Gaps.vLine,
  58. Offstage(
  59. offstage: onTap == null ? true:false,
  60. child: Opacity(
  61. // 无点击事件时,隐藏箭头图标
  62. opacity: onTap == null ? 0 : 1,
  63. child: Padding(
  64. padding: EdgeInsets.only(top: maxLines == 1 ? 0.0 : 2.0,left: 10),
  65. child: Images.iconTel,
  66. ),
  67. )
  68. )
  69. ],
  70. ),
  71. ),
  72. );
  73. }
  74. }