@@ -9,90 +9,178 @@ import '../../../extension/extension.dart';
99import '../../../theme/theme.dart' ;
1010import '../../../widget/html_view_widget.dart' ;
1111
12- class CommentParent extends StatelessWidget {
13- const CommentParent ({super .key, required this .parent});
12+ class CommentParent extends StatefulWidget {
13+ const CommentParent ({super .key, required this .parent, this .onParentTapped });
1414
1515 final CommentBase parent;
16+ final VoidCallback ? onParentTapped;
1617
1718 @override
18- Widget build (BuildContext context) {
19- final text = parse (parent.message).documentElement? .text ?? '' ;
19+ State <CommentParent > createState () => _CommentParentState ();
20+ }
21+
22+ class _CommentParentState extends State <CommentParent > {
23+ final tag = UniqueKey ();
24+
25+ late TextStyle textStyle = DefaultTextStyle .of (context).style;
26+ late Color bgColor = context.theme.colors.cardHighlight;
27+ late final parentHtml = HtmlView (
28+ textHtml: widget.parent.message,
29+ textStyle: textStyle,
30+ renderMode: RenderMode .column,
31+ padding: EdgeInsets .zero,
32+ );
33+
34+ @override
35+ void didChangeDependencies () {
36+ bgColor = context.theme.colors.cardHighlight;
37+ textStyle = DefaultTextStyle .of (context).style;
38+
39+ super .didChangeDependencies ();
40+ }
41+
42+ PageRoute buildPageRoute (BuildContext context) {
43+ return PageRouteBuilder (
44+ opaque: false ,
45+ barrierDismissible: true ,
46+ pageBuilder:
47+ (_, __, ___) => Center (
48+ child: BackdropFilter (
49+ filter: ImageFilter .blur (sigmaX: 6 , sigmaY: 6 ),
50+ child: ConstrainedBox (
51+ constraints: BoxConstraints (
52+ maxWidth: Device .getWidth (context) * .9 ,
53+ maxHeight: Device .getHeight (context) * .5 ,
54+ ),
55+ child: Hero (
56+ tag: tag,
57+ child: DecoratedBox (
58+ decoration: BoxDecoration (
59+ borderRadius: AppStyles .borderRadius,
60+ color: bgColor,
61+ ),
62+ child: SingleChildScrollView (
63+ padding: const EdgeInsets .all (16 ),
64+ child: parentHtml,
65+ ),
66+ ),
67+ ),
68+ ),
69+ ),
70+ ),
71+ );
72+ }
2073
74+ @override
75+ Widget build (BuildContext context) {
76+ final text = parse (widget.parent.message).documentElement? .text ?? '' ;
2177 if (text.isEmpty) {
2278 return const SizedBox ();
2379 }
2480
25- final tag = UniqueKey ();
26- final textStyle = DefaultTextStyle .of (context).style;
27- final bgColor = context.theme.colors.cardHighlight;
28-
2981 return Padding (
30- padding: const EdgeInsets .all (10 ),
82+ // TODO: bottom padding Для iconbutton?
83+ padding: const EdgeInsets .symmetric (vertical: 10 , horizontal: 6 ),
3184 child: Hero (
3285 tag: tag,
3386 child: DecoratedBox (
3487 decoration: BoxDecoration (
35- borderRadius: AppStyles .borderRadius ,
88+ borderRadius: AppStyles .borderRadiusSm ,
3689 color: bgColor,
3790 ),
38- child: Padding (
39- padding: const EdgeInsets .all (8 ),
40- child: Column (
41- crossAxisAlignment: CrossAxisAlignment .start,
42- children: [
43- Text (
44- text,
45- maxLines: 2 ,
46- overflow: TextOverflow .ellipsis,
47- style: textStyle,
48- ),
49- IconButton .outlined (
50- visualDensity: VisualDensity .compact,
51- icon: const Icon (
52- Icons .remove_red_eye_sharp,
53- size: 16 ,
54- ),
55- onPressed: () => Navigator .of (
56- context,
57- rootNavigator: true ,
58- ).push (
59- PageRouteBuilder (
60- opaque: false ,
61- barrierDismissible: true ,
62- pageBuilder: (_, __, ___) => Center (
63- child: BackdropFilter (
64- filter: ImageFilter .blur (sigmaX: 6 , sigmaY: 6 ),
65- child: ConstrainedBox (
66- constraints: BoxConstraints (
67- maxWidth: Device .getWidth (context) * .9 ,
68- maxHeight: Device .getHeight (context) * .5 ,
69- ),
70- child: Hero (
71- tag: tag,
72- child: DecoratedBox (
73- decoration: BoxDecoration (
74- borderRadius: AppStyles .borderRadius,
75- color: bgColor,
76- ),
77- child: SingleChildScrollView (
78- padding: const EdgeInsets .all (16 ),
79- child: HtmlView (
80- textHtml: parent.message,
81- textStyle: textStyle,
82- renderMode: RenderMode .column,
83- padding: EdgeInsets .zero,
84- ),
91+ child: Stack (
92+ alignment: Alignment .bottomCenter,
93+ children: [
94+ ConstrainedBox (
95+ constraints: const BoxConstraints (maxHeight: 100 ),
96+ child: SingleChildScrollView (
97+ padding: const EdgeInsets .fromLTRB (10 , 0 , 10 , 40 ),
98+ child: Column (
99+ crossAxisAlignment: CrossAxisAlignment .stretch,
100+ children: [
101+ GestureDetector (
102+ onTap: widget.onParentTapped,
103+ behavior: HitTestBehavior .translucent,
104+ child: Padding (
105+ padding: const EdgeInsets .only (top: 10 , bottom: 8 ),
106+ child: Row (
107+ spacing: 4 ,
108+ children: [
109+ Icon (
110+ Icons .arrow_upward,
111+ size: 18 ,
112+ color: context.theme.colors.primary,
113+ ),
114+ SelectableText .rich (
115+ TextSpan (
116+ text: 'ответил на ' ,
117+ style: textStyle,
118+ children: [
119+ TextSpan (
120+ text: 'сообщение от ' ,
121+ style: textStyle.copyWith (
122+ color: context.theme.colors.primary,
123+ ),
124+ children: [
125+ TextSpan (
126+ text: widget.parent.author.alias,
127+ style: textStyle.copyWith (
128+ color: context.theme.colors.primary,
129+ fontWeight: FontWeight .w500,
130+ ),
131+ ),
132+ ],
133+ ),
134+ const TextSpan (text: ':' ),
135+ ],
85136 ),
137+ onTap: widget.onParentTapped,
86138 ),
87- ) ,
139+ ] ,
88140 ),
89141 ),
90142 ),
143+ parentHtml,
144+ ],
145+ ),
146+ ),
147+ ),
148+ Positioned .fill (
149+ top: 60 ,
150+ child: IgnorePointer (
151+ child: DecoratedBox (
152+ decoration: BoxDecoration (
153+ borderRadius: AppStyles .borderRadius,
154+ gradient: LinearGradient (
155+ begin: Alignment .topCenter,
156+ end: Alignment .bottomCenter,
157+ colors: [
158+ bgColor.withValues (alpha: .1 ),
159+ bgColor.withValues (alpha: .3 ),
160+ bgColor.withValues (alpha: .6 ),
161+ bgColor.withValues (alpha: .9 ),
162+ bgColor,
163+ ],
164+ ),
91165 ),
92166 ),
93167 ),
94- ],
95- ),
168+ ),
169+ Positioned (
170+ bottom: 0 ,
171+ right: 0 ,
172+ child: IconButton .filled (
173+ visualDensity: VisualDensity .compact,
174+ icon: const Icon (Icons .remove_red_eye_sharp, size: 16 ),
175+ tooltip: 'Показать полностью' ,
176+ onPressed:
177+ () => Navigator .of (
178+ context,
179+ rootNavigator: true ,
180+ ).push (buildPageRoute (context)),
181+ ),
182+ ),
183+ ],
96184 ),
97185 ),
98186 ),
0 commit comments