demo1.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/rendering.dart';
  3. import 'package:luojigou_thinking_core/luojigou_thinking_core.dart';
  4. class Demo1 extends StatefulWidget {
  5. const Demo1({
  6. Key? key,
  7. }) : super(key: key);
  8. @override
  9. State<StatefulWidget> createState() => _Demo1State();
  10. }
  11. class _Demo1State extends State<Demo1> with SingleTickerProviderStateMixin {
  12. late TabController _controller;
  13. @override
  14. void initState() {
  15. super.initState();
  16. _controller = TabController(length: 7, vsync: this);
  17. }
  18. bool _value = false;
  19. @override
  20. Widget build(BuildContext context) {
  21. return Scaffold(
  22. backgroundColor: Color(0xFFC8DDFF),
  23. body: ReverseRow(
  24. children: [
  25. PutAway(
  26. direction: PutAwayDirection.rtl,
  27. isPutAway: _value,
  28. child: SizedBox(
  29. width: 55,
  30. height: double.infinity,
  31. child: Column(
  32. children: [
  33. SizedBox(
  34. width: double.infinity,
  35. height: 44 + MediaQuery.of(context).padding.top,
  36. child: const Icon(Icons.arrow_back_ios),
  37. ),
  38. Expanded(
  39. child: VerticalTabBar(
  40. controller: _controller,
  41. isScrollable: true,
  42. padding: EdgeInsets.only(left: 40),
  43. labelStyle: const TextStyle(
  44. color: Color(0xFF75AAFF),
  45. fontSize: 16,
  46. height: 1,
  47. ),
  48. unselectedLabelStyle: const TextStyle(
  49. color: Color(0xFFFFFFFF),
  50. fontSize: 16,
  51. height: 1,
  52. ),
  53. labelColor: const Color(0xFF75AAFF),
  54. unselectedLabelColor: Colors.white,
  55. indicator: _TabDecoration(),
  56. tabs: [
  57. Container(
  58. padding: EdgeInsets.symmetric(horizontal: 4),
  59. height: double.infinity,
  60. color: Colors.transparent,
  61. child: Center(child: const Text('综合区')),
  62. ),
  63. Container(
  64. padding: EdgeInsets.symmetric(horizontal: 4),
  65. height: double.infinity,
  66. color: Colors.transparent,
  67. child: Center(child: const Text('中华文化')),
  68. ),
  69. Container(
  70. padding: EdgeInsets.symmetric(horizontal: 4),
  71. height: double.infinity,
  72. color: Colors.transparent,
  73. child: Center(child: const Text('科学探索')),
  74. ),
  75. Container(
  76. padding: EdgeInsets.symmetric(horizontal: 4),
  77. height: double.infinity,
  78. color: Colors.transparent,
  79. child: Center(child: const Text('自由探索')),
  80. ),
  81. Container(
  82. padding: EdgeInsets.symmetric(horizontal: 4),
  83. height: double.infinity,
  84. color: Colors.transparent,
  85. child: Center(child: const Text('思维探索')),
  86. ),
  87. Container(
  88. padding: EdgeInsets.symmetric(horizontal: 4),
  89. height: double.infinity,
  90. color: Colors.transparent,
  91. child: Center(child: const Text('思维探索')),
  92. ),
  93. Container(
  94. padding: EdgeInsets.symmetric(horizontal: 4),
  95. height: double.infinity,
  96. color: Colors.transparent,
  97. child: Center(child: const Text('思维探索')),
  98. ),
  99. ],
  100. ),
  101. ),
  102. ],
  103. ),
  104. ),
  105. ),
  106. Expanded(
  107. child: GestureDetector(
  108. onTap: () {
  109. setState(() {
  110. _value = !_value;
  111. });
  112. },
  113. child: Container(
  114. decoration: const BoxDecoration(
  115. color: Colors.white,
  116. borderRadius: BorderRadius.only(
  117. topLeft: Radius.circular(20),
  118. bottomLeft: Radius.circular(20),
  119. ),
  120. boxShadow: [],
  121. ),
  122. child: Center(
  123. child: Container(
  124. height: 220,
  125. width: 220,
  126. color: Colors.red,
  127. ),
  128. ),
  129. ),
  130. ),
  131. ),
  132. ],
  133. ),
  134. );
  135. }
  136. }
  137. class _TabDecoration extends Decoration {
  138. @override
  139. BoxPainter createBoxPainter([VoidCallback? onChanged]) {
  140. return _BoxPainter(onChanged);
  141. }
  142. }
  143. class _BoxPainter extends BoxPainter {
  144. _BoxPainter(VoidCallback? onChanged) : super(onChanged);
  145. @override
  146. void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
  147. if (configuration.size == null) return;
  148. final size = configuration.size!;
  149. final paint = Paint()..color = const Color(0xFF75AAFF);
  150. final dotx = offset.dx + size.width / 2;
  151. final doty = offset.dy + size.height - 8;
  152. canvas.drawCircle(Offset(dotx, doty), 2, paint);
  153. double h = 18.8;
  154. double w = 60;
  155. final path = Path();
  156. path.moveTo(dotx - w, doty + 8);
  157. path.lineTo(dotx, doty + 8 + 20);
  158. path.lineTo(dotx + w, doty + 8);
  159. path.reset();
  160. path.moveTo(dotx - w, doty + 8);
  161. path.cubicTo(dotx - w / 2 - 10, doty + 8, dotx - w / 2 + 10, doty + 8 + h,
  162. dotx, doty + 8 + h);
  163. path.cubicTo(dotx + w / 2 - 10, doty + 8 + h, dotx + w / 2 + 10, doty + 8,
  164. dotx + w, doty + 8);
  165. canvas.drawPath(path, paint..color = const Color(0xFFC8DDFF));
  166. }
  167. }