|
1 | 1 | import 'dart:io';
|
2 |
| -import 'package:profanity_filter/profanity_filter.dart'; |
| 2 | + |
3 | 3 | import 'package:dotted_border/dotted_border.dart';
|
4 | 4 | import 'package:femunity/core/common/error_text.dart';
|
5 | 5 | import 'package:femunity/core/common/loader.dart';
|
6 |
| -import 'package:femunity/core/constants/constants.dart'; |
7 | 6 | import 'package:femunity/core/utils.dart';
|
8 | 7 | import 'package:femunity/features/communities/controller/community_controller.dart';
|
9 | 8 | import 'package:femunity/features/posts/controller/posts_controller.dart';
|
10 | 9 | import 'package:femunity/models/community_model.dart';
|
11 | 10 | import 'package:femunity/theme/pallate.dart';
|
12 | 11 | import 'package:flutter/material.dart';
|
13 | 12 | import 'package:flutter_riverpod/flutter_riverpod.dart';
|
| 13 | +import 'package:profanity_filter/profanity_filter.dart'; |
14 | 14 |
|
15 | 15 | class AddPostsTypeScreen extends ConsumerStatefulWidget {
|
16 | 16 | final String type;
|
17 |
| - const AddPostsTypeScreen({super.key, required this.type}); |
| 17 | + |
| 18 | + const AddPostsTypeScreen({Key? key, required this.type}) : super(key: key); |
18 | 19 |
|
19 | 20 | @override
|
20 | 21 | ConsumerState<ConsumerStatefulWidget> createState() =>
|
@@ -99,128 +100,216 @@ class _AddPostsTypeScreenState extends ConsumerState<AddPostsTypeScreen> {
|
99 | 100 | final isTypeLink = widget.type == 'Link';
|
100 | 101 | final isLoading = ref.watch(postControllerProvider);
|
101 | 102 | return Scaffold(
|
| 103 | + backgroundColor: currentTheme.backgroundColor, |
102 | 104 | appBar: AppBar(
|
103 |
| - title: Text('Post ${widget.type}'), |
| 105 | + backgroundColor: Colors.black, |
| 106 | + elevation: 0, |
| 107 | + leading: IconButton( |
| 108 | + icon: const Icon( |
| 109 | + Icons.arrow_back_ios, |
| 110 | + color: Colors.white, |
| 111 | + ), |
| 112 | + onPressed: () => Navigator.of(context).pop(), |
| 113 | + ), |
| 114 | + title: |
| 115 | + Text('Add ${widget.type}', style: TextStyle(color: Colors.white)), |
104 | 116 | actions: [
|
105 | 117 | TextButton(
|
106 | 118 | onPressed: sharePost,
|
107 | 119 | style: ButtonStyle(
|
108 |
| - foregroundColor: |
109 |
| - MaterialStateProperty.all<Color>(const Color(0xFFFEB2B2)), |
110 |
| - ), |
| 120 | + // foregroundColor: MaterialStateProperty.all<Color>( |
| 121 | + // currentTheme.accentIconColor), |
| 122 | + ), |
111 | 123 | child: Text(
|
112 | 124 | 'Share',
|
113 | 125 | style: TextStyle(
|
114 |
| - fontSize: 18, |
115 |
| - color: Theme.of(context).brightness == Brightness.dark |
116 |
| - ? Color(0xffFEB2B2) |
117 |
| - : Color.fromARGB(255, 0, 0, 0)), |
| 126 | + fontSize: 18, |
| 127 | + fontWeight: FontWeight.bold, |
| 128 | + color: Colors.white, |
| 129 | + ), |
118 | 130 | ),
|
119 | 131 | ),
|
120 | 132 | ],
|
121 | 133 | ),
|
122 | 134 | body: isLoading
|
123 | 135 | ? const Loader()
|
124 | 136 | : Padding(
|
125 |
| - padding: const EdgeInsets.all(8.0), |
126 |
| - child: Column( |
127 |
| - children: [ |
128 |
| - TextField( |
129 |
| - controller: titleController, |
130 |
| - decoration: const InputDecoration( |
131 |
| - hintText: 'What should the title be?', |
132 |
| - filled: true, |
133 |
| - border: InputBorder.none, |
134 |
| - contentPadding: EdgeInsets.all(18), |
| 137 | + padding: const EdgeInsets.all(20.0), |
| 138 | + child: SingleChildScrollView( |
| 139 | + child: Column( |
| 140 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 141 | + children: [ |
| 142 | + const Text( |
| 143 | + 'Title', |
| 144 | + style: |
| 145 | + TextStyle(fontSize: 24, fontWeight: FontWeight.bold), |
135 | 146 | ),
|
136 |
| - maxLength: 30, |
137 |
| - ), |
138 |
| - const SizedBox( |
139 |
| - height: 10, |
140 |
| - ), |
141 |
| - if (isTypeImage) |
142 |
| - GestureDetector( |
143 |
| - onTap: selectBannerImage, |
144 |
| - child: DottedBorder( |
145 |
| - borderType: BorderType.RRect, |
146 |
| - radius: const Radius.circular(10), |
147 |
| - dashPattern: const [10, 4], |
148 |
| - strokeCap: StrokeCap.round, |
149 |
| - color: currentTheme.textTheme.bodyText2!.color!, |
150 |
| - child: Container( |
151 |
| - width: double.infinity, |
152 |
| - height: 150, |
153 |
| - decoration: BoxDecoration( |
154 |
| - borderRadius: BorderRadius.circular(10), |
155 |
| - ), |
156 |
| - child: bannerFile != null |
157 |
| - ? Image.file(bannerFile!) |
158 |
| - : const Center( |
159 |
| - child: Icon( |
160 |
| - Icons.camera_alt_outlined, |
161 |
| - size: 40, |
162 |
| - ), |
163 |
| - )), |
164 |
| - ), |
165 |
| - ), |
166 |
| - if (isTypeText) |
| 147 | + const SizedBox(height: 10), |
167 | 148 | TextField(
|
168 |
| - controller: descriptionController, |
169 |
| - decoration: const InputDecoration( |
170 |
| - hintText: 'Voice your thoughts!', |
171 |
| - hintStyle: TextStyle( |
172 |
| - fontWeight: FontWeight.w500, |
173 |
| - ), |
| 149 | + controller: titleController, |
| 150 | + decoration: InputDecoration( |
| 151 | + hintText: 'What should the title be?', |
| 152 | + hintStyle: currentTheme.textTheme.bodyText2! |
| 153 | + .copyWith(color: currentTheme.hintColor), |
174 | 154 | filled: true,
|
175 |
| - border: InputBorder.none, |
176 |
| - contentPadding: EdgeInsets.all(18), |
| 155 | + fillColor: Colors.purple[900], |
| 156 | + border: OutlineInputBorder( |
| 157 | + borderRadius: BorderRadius.circular(15), |
| 158 | + borderSide: BorderSide.none, |
| 159 | + ), |
| 160 | + contentPadding: const EdgeInsets.all(18), |
177 | 161 | ),
|
178 |
| - maxLines: 5, |
| 162 | + maxLength: 30, |
| 163 | + style: currentTheme.textTheme.bodyText2! |
| 164 | + .copyWith(fontWeight: FontWeight.bold), |
179 | 165 | ),
|
180 |
| - if (isTypeLink) |
181 |
| - TextField( |
182 |
| - controller: linkController, |
183 |
| - decoration: const InputDecoration( |
184 |
| - hintText: 'Enter link here', |
185 |
| - hintStyle: TextStyle( |
186 |
| - fontWeight: FontWeight.w500, |
187 |
| - ), |
188 |
| - filled: true, |
189 |
| - border: InputBorder.none, |
190 |
| - contentPadding: EdgeInsets.all(18), |
| 166 | + const SizedBox(height: 20), |
| 167 | + if (isTypeImage) |
| 168 | + Column( |
| 169 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 170 | + children: [ |
| 171 | + const Text( |
| 172 | + 'Image', |
| 173 | + style: TextStyle( |
| 174 | + fontSize: 24, fontWeight: FontWeight.bold), |
| 175 | + ), |
| 176 | + const SizedBox(height: 10), |
| 177 | + GestureDetector( |
| 178 | + onTap: selectBannerImage, |
| 179 | + child: DottedBorder( |
| 180 | + borderType: BorderType.RRect, |
| 181 | + radius: const Radius.circular(10), |
| 182 | + dashPattern: const [10, 4], |
| 183 | + strokeCap: StrokeCap.round, |
| 184 | + color: currentTheme.textTheme.bodyText2!.color!, |
| 185 | + child: Container( |
| 186 | + width: double.infinity, |
| 187 | + height: 150, |
| 188 | + decoration: BoxDecoration( |
| 189 | + borderRadius: BorderRadius.circular(10), |
| 190 | + ), |
| 191 | + child: bannerFile != null |
| 192 | + ? ClipRRect( |
| 193 | + borderRadius: BorderRadius.circular(10), |
| 194 | + child: Image.file( |
| 195 | + bannerFile!, |
| 196 | + fit: BoxFit.cover, |
| 197 | + ), |
| 198 | + ) |
| 199 | + : const Center( |
| 200 | + child: Icon( |
| 201 | + Icons.camera_alt_outlined, |
| 202 | + size: 40, |
| 203 | + ), |
| 204 | + ), |
| 205 | + ), |
| 206 | + ), |
| 207 | + ), |
| 208 | + ], |
| 209 | + ), |
| 210 | + if (isTypeText) |
| 211 | + Column( |
| 212 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 213 | + children: [ |
| 214 | + const Text( |
| 215 | + 'Text', |
| 216 | + style: TextStyle( |
| 217 | + fontSize: 24, fontWeight: FontWeight.bold), |
| 218 | + ), |
| 219 | + const SizedBox(height: 10), |
| 220 | + TextField( |
| 221 | + controller: descriptionController, |
| 222 | + decoration: InputDecoration( |
| 223 | + hintText: 'Voice your thoughts!', |
| 224 | + hintStyle: currentTheme.textTheme.bodyText2! |
| 225 | + .copyWith(color: currentTheme.hintColor), |
| 226 | + filled: true, |
| 227 | + fillColor: Colors.green[600], |
| 228 | + border: OutlineInputBorder( |
| 229 | + borderRadius: BorderRadius.circular(15), |
| 230 | + borderSide: BorderSide.none, |
| 231 | + ), |
| 232 | + contentPadding: const EdgeInsets.all(18), |
| 233 | + ), |
| 234 | + maxLines: 5, |
| 235 | + style: currentTheme.textTheme.bodyText2! |
| 236 | + .copyWith(fontWeight: FontWeight.bold), |
| 237 | + ), |
| 238 | + ], |
| 239 | + ), |
| 240 | + if (isTypeLink) |
| 241 | + Column( |
| 242 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 243 | + children: [ |
| 244 | + const Text( |
| 245 | + 'Link', |
| 246 | + style: TextStyle( |
| 247 | + fontSize: 24, fontWeight: FontWeight.bold), |
| 248 | + ), |
| 249 | + const SizedBox(height: 10), |
| 250 | + TextField( |
| 251 | + controller: linkController, |
| 252 | + decoration: InputDecoration( |
| 253 | + hintText: 'Enter link here', |
| 254 | + hintStyle: currentTheme.textTheme.bodyText2! |
| 255 | + .copyWith(color: currentTheme.hintColor), |
| 256 | + filled: true, |
| 257 | + fillColor: Colors.orange[800], |
| 258 | + border: OutlineInputBorder( |
| 259 | + borderRadius: BorderRadius.circular(15), |
| 260 | + borderSide: BorderSide.none, |
| 261 | + ), |
| 262 | + contentPadding: const EdgeInsets.all(18), |
| 263 | + ), |
| 264 | + maxLines: 2, |
| 265 | + style: currentTheme.textTheme.bodyText2! |
| 266 | + .copyWith(fontWeight: FontWeight.bold), |
| 267 | + ), |
| 268 | + ], |
191 | 269 | ),
|
192 |
| - maxLines: 2, |
| 270 | + const SizedBox(height: 20), |
| 271 | + const Text( |
| 272 | + 'Select Community', |
| 273 | + style: |
| 274 | + TextStyle(fontSize: 24, fontWeight: FontWeight.bold), |
193 | 275 | ),
|
194 |
| - const SizedBox(height: 20), |
195 |
| - const Align( |
196 |
| - alignment: Alignment.topLeft, |
197 |
| - child: Text('Select Community'), |
198 |
| - ), |
199 |
| - ref.watch(userCommunitiesProvider).when( |
200 |
| - data: (data) { |
201 |
| - communities = data; |
| 276 | + const SizedBox(height: 10), |
| 277 | + ref.watch(userCommunitiesProvider).when( |
| 278 | + data: (data) { |
| 279 | + communities = data; |
202 | 280 |
|
203 |
| - if (data.isEmpty) { |
204 |
| - return const SizedBox(); |
205 |
| - } |
206 |
| - return DropdownButton( |
| 281 | + if (data.isEmpty) { |
| 282 | + return const SizedBox(); |
| 283 | + } |
| 284 | + return DropdownButton( |
207 | 285 | value: selectedCommunity ?? data[0],
|
208 |
| - items: data |
209 |
| - .map((e) => DropdownMenuItem( |
210 |
| - value: e, child: Text(e.name))) |
211 |
| - .toList(), |
212 |
| - onChanged: (val) { |
| 286 | + onChanged: (value) { |
213 | 287 | setState(() {
|
214 |
| - selectedCommunity = val; |
| 288 | + selectedCommunity = value as Community?; |
215 | 289 | });
|
216 |
| - }); |
217 |
| - }, |
218 |
| - error: (error, StackTrace) => ErrorText( |
219 |
| - error: error.toString(), |
| 290 | + }, |
| 291 | + items: data |
| 292 | + .map( |
| 293 | + (e) => DropdownMenuItem( |
| 294 | + value: e, |
| 295 | + child: Text( |
| 296 | + e.name, |
| 297 | + style: currentTheme.textTheme.bodyText2! |
| 298 | + .copyWith( |
| 299 | + fontWeight: FontWeight.bold, |
| 300 | + ), |
| 301 | + ), |
| 302 | + ), |
| 303 | + ) |
| 304 | + .toList(), |
| 305 | + ); |
| 306 | + }, |
| 307 | + loading: () => const LinearProgressIndicator(), |
| 308 | + error: (error, stackTrace) => |
| 309 | + ErrorText(error: error.toString()), |
220 | 310 | ),
|
221 |
| - loading: () => const Loader(), |
222 |
| - ), |
223 |
| - ], |
| 311 | + ], |
| 312 | + ), |
224 | 313 | ),
|
225 | 314 | ),
|
226 | 315 | );
|
|
0 commit comments