1
1
import 'dart:io' ;
2
-
3
2
import 'package:flutter/material.dart' ;
4
3
import 'package:flutter/rendering.dart' ;
5
4
import 'package:flutter_twitter_clone/helper/constant.dart' ;
6
5
import 'package:flutter_twitter_clone/helper/theme.dart' ;
7
6
import 'package:flutter_twitter_clone/helper/utility.dart' ;
8
7
import 'package:flutter_twitter_clone/model/feedModel.dart' ;
9
8
import 'package:flutter_twitter_clone/model/user.dart' ;
9
+ import 'package:flutter_twitter_clone/page/feed/composeTweet/widget/composeBottomIconWidget.dart' ;
10
+ import 'package:flutter_twitter_clone/page/feed/composeTweet/widget/composeTweetImage.dart' ;
10
11
import 'package:flutter_twitter_clone/state/authState.dart' ;
11
12
import 'package:flutter_twitter_clone/state/feedState.dart' ;
12
13
import 'package:flutter_twitter_clone/widgets/customAppBar.dart' ;
13
14
import 'package:flutter_twitter_clone/widgets/customWidgets.dart' ;
14
15
import 'package:flutter_twitter_clone/widgets/newWidget/customUrlText.dart' ;
15
- import 'package:flutter_twitter_clone/widgets/tweet/widgets/bottomIconWidget.dart' ;
16
- import 'package:flutter_twitter_clone/widgets/tweet/widgets/tweetImage.dart' ;
17
16
import 'package:provider/provider.dart' ;
18
17
18
+ class ComposeTweetPage extends StatefulWidget {
19
+ ComposeTweetPage ({Key key, this .isRetweet, this .isTweet = true }) : super (key: key);
19
20
20
- class FeedPostReplyPage extends StatefulWidget {
21
- FeedPostReplyPage ({Key key, this .isRetweet}) : super (key: key);
22
-
23
- // final String postId;
24
21
final bool isRetweet;
25
- _FeedPostReplyPageState createState () => _FeedPostReplyPageState ();
22
+ final bool isTweet;
23
+ _ComposeTweetReplyPageState createState () => _ComposeTweetReplyPageState ();
26
24
}
27
25
28
- class _FeedPostReplyPageState extends State <FeedPostReplyPage > {
26
+ class _ComposeTweetReplyPageState extends State <ComposeTweetPage > {
29
27
bool isScrollingDown = false ;
30
28
FeedModel model;
31
29
ScrollController scrollcontroller;
@@ -42,7 +40,6 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
42
40
43
41
@override
44
42
void initState () {
45
- // postId = widget.postId;
46
43
var feedState = Provider .of <FeedState >(context, listen: false );
47
44
model = feedState.tweetToReplyModel;
48
45
scrollcontroller = ScrollController ();
@@ -92,8 +89,8 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
92
89
_textEditingController.text.length > 280 ) {
93
90
return ;
94
91
}
95
- var state = Provider .of <FeedState >(context);
96
- var authState = Provider .of <AuthState >(context);
92
+ var state = Provider .of <FeedState >(context, listen : false );
93
+ var authState = Provider .of <AuthState >(context, listen : false );
97
94
screenloader.showLoader (context);
98
95
var user = authState.userModel;
99
96
var profilePic = user.profilePic ?? dummyProfilePic;
@@ -137,16 +134,14 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
137
134
138
135
@override
139
136
Widget build (BuildContext context) {
140
- var state = Provider .of <FeedState >(
141
- context,
142
- );
137
+ var state = Provider .of <FeedState >(context);
143
138
144
139
return Scaffold (
145
140
appBar: CustomAppBar (
146
141
title: customTitleText ('' ),
147
142
onActionPressed: _submitButton,
148
143
isCrossButton: true ,
149
- submitButtonText: widget.isRetweet ? 'Retweet' : 'Reply' ,
144
+ submitButtonText: widget.isTweet ? 'Tweet' : widget. isRetweet ? 'Retweet' : 'Reply' ,
150
145
isSubmitDisable: _textEditingController.text == null ||
151
146
_textEditingController.text.isEmpty ||
152
147
_textEditingController.text.length > 280 ||
@@ -160,12 +155,12 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
160
155
SingleChildScrollView (
161
156
controller: scrollcontroller,
162
157
child: widget.isRetweet
163
- ? _FeedPostRetweetPageView (this )
164
- : _FeedPostReplyPageView (this ),
158
+ ? _ComposeRetweet (this )
159
+ : _ComposeTweet (this ),
165
160
),
166
161
Align (
167
162
alignment: Alignment .bottomCenter,
168
- child: BottomIconWidget (
163
+ child: ComposeBottomIconWidget (
169
164
textEditingController: _textEditingController,
170
165
onImageIconSelcted: _onImageIconSelcted,
171
166
),
@@ -177,11 +172,11 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
177
172
}
178
173
}
179
174
180
- class _FeedPostRetweetPageView
181
- extends WidgetView <FeedPostReplyPage , _FeedPostReplyPageState > {
182
- _FeedPostRetweetPageView (this .viewState) : super (viewState);
175
+ class _ComposeRetweet
176
+ extends WidgetView <ComposeTweetPage , _ComposeTweetReplyPageState > {
177
+ _ComposeRetweet (this .viewState) : super (viewState);
183
178
184
- final _FeedPostReplyPageState viewState;
179
+ final _ComposeTweetReplyPageState viewState;
185
180
Widget _tweet (BuildContext context, FeedModel model) {
186
181
return Column (
187
182
crossAxisAlignment: CrossAxisAlignment .start,
@@ -283,12 +278,14 @@ class _FeedPostRetweetPageView
283
278
Expanded (
284
279
child: _descriptionEntry (),
285
280
),
286
- SizedBox (width: 16 ,)
281
+ SizedBox (
282
+ width: 16 ,
283
+ )
287
284
],
288
285
),
289
286
Padding (
290
287
padding: EdgeInsets .only (right: 16 , left: 80 , bottom: 8 ),
291
- child: TweetImage (
288
+ child: ComposeTweetImage (
292
289
image: viewState._image,
293
290
onCrossIconPressed: viewState._onCrossIconPressed,
294
291
),
@@ -308,11 +305,11 @@ class _FeedPostRetweetPageView
308
305
}
309
306
}
310
307
311
- class _FeedPostReplyPageView
312
- extends WidgetView <FeedPostReplyPage , _FeedPostReplyPageState > {
313
- _FeedPostReplyPageView (this .viewState) : super (viewState);
308
+ class _ComposeTweet
309
+ extends WidgetView <ComposeTweetPage , _ComposeTweetReplyPageState > {
310
+ _ComposeTweet (this .viewState) : super (viewState);
314
311
315
- final _FeedPostReplyPageState viewState;
312
+ final _ComposeTweetReplyPageState viewState;
316
313
317
314
Widget _descriptionEntry () {
318
315
return TextField (
@@ -321,7 +318,7 @@ class _FeedPostReplyPageView
321
318
maxLines: null ,
322
319
decoration: InputDecoration (
323
320
border: InputBorder .none,
324
- hintText: 'Tweet your reply' ,
321
+ hintText: widget.isTweet ? 'What \' s happening?' : 'Tweet your reply' ,
325
322
hintStyle: TextStyle (fontSize: 18 )),
326
323
);
327
324
}
@@ -434,6 +431,7 @@ class _FeedPostReplyPageView
434
431
child: Column (
435
432
crossAxisAlignment: CrossAxisAlignment .start,
436
433
children: < Widget > [
434
+ viewState.widget.isTweet ? SizedBox .shrink () :
437
435
_tweerCard (context),
438
436
Row (
439
437
crossAxisAlignment: CrossAxisAlignment .start,
@@ -447,7 +445,7 @@ class _FeedPostReplyPageView
447
445
)
448
446
],
449
447
),
450
- TweetImage (
448
+ ComposeTweetImage (
451
449
image: viewState._image,
452
450
onCrossIconPressed: viewState._onCrossIconPressed,
453
451
),
0 commit comments