click_tel_item.dart 2.6 KB

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