time_axis.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/resources.dart';
  3. import 'package:liftmanager/utils/theme_utils.dart';
  4. class LogisticsInformationItem extends StatefulWidget {
  5. final Color topColor;
  6. final Color centerColor;
  7. final Color bottomColor;
  8. final Color titleColor;
  9. final Color textColor;
  10. final String title;
  11. final String text;
  12. LogisticsInformationItem({
  13. this.topColor:Colours.app_main,
  14. this.centerColor:Colours.app_main,
  15. this.bottomColor:Colours.app_main,
  16. this.titleColor:Colours.time_axis_title,
  17. this.textColor:Colours.time_axis_text,
  18. this.title,
  19. this.text,
  20. });
  21. @override
  22. _LogisticsInformationItemState createState() =>
  23. _LogisticsInformationItemState();
  24. }
  25. class _LogisticsInformationItemState extends State<LogisticsInformationItem> {
  26. double item_height = 0.0;
  27. GlobalKey textKey = new GlobalKey();
  28. @override
  29. void initState() {
  30. super.initState();
  31. ///监听是否渲染完
  32. WidgetsBinding widgetsBinding = WidgetsBinding.instance;
  33. widgetsBinding.addPostFrameCallback((callback) {
  34. ///获取相应控件的size
  35. RenderObject renderObject = textKey.currentContext.findRenderObject();
  36. setState(() {
  37. item_height = renderObject.semanticBounds.size.height;
  38. });
  39. });
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. return Container(
  44. color: ThemeUtils.getTabsBg(context),
  45. padding: EdgeInsets.only(left: 15, right: 15),
  46. child: Row(
  47. children: [
  48. Container(
  49. width: 10,
  50. height: item_height,
  51. child: Column(
  52. mainAxisAlignment: MainAxisAlignment.center,
  53. children: [
  54. Expanded(
  55. child: Container(
  56. width: 0.9,
  57. color: widget.topColor,
  58. )),
  59. Container(
  60. height: 10,
  61. width: 10,
  62. decoration: BoxDecoration(
  63. color: widget.centerColor,
  64. borderRadius: BorderRadius.all(Radius.circular(5)),
  65. ),
  66. ),
  67. Expanded(
  68. child: Container(
  69. width: 0.9,
  70. color: widget.bottomColor,
  71. )),
  72. ],
  73. ),
  74. ),
  75. ///右侧的文案
  76. Expanded(
  77. child: Padding(
  78. key: textKey,
  79. padding: const EdgeInsets.only(left: 20, top: 10, bottom: 10),
  80. child: Column(
  81. crossAxisAlignment: CrossAxisAlignment.start,
  82. children: <Widget>[
  83. Text(
  84. widget.title,
  85. style: TextStyle(fontSize: 14, color: widget.titleColor),
  86. ),
  87. SizedBox(height: 8,),
  88. Text(
  89. widget.text,
  90. style: TextStyle(fontSize: 12, color: widget.textColor),
  91. )
  92. ],
  93. ),
  94. ),
  95. ),
  96. ],
  97. ),
  98. );
  99. }
  100. }