Skip to content

Commit

Permalink
Bug fix: Edited tag does not get updated immediately (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhav-khurana authored Dec 9, 2023
1 parent 518c5c8 commit c11e7b3
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/views/after_auth_screens/add_post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import 'package:talawa/views/base_view.dart';
late AddPostViewModel model;

/// AddPost returns a widget to add(upload) the post.
class AddPost extends StatelessWidget {
class AddPost extends StatefulWidget {
const AddPost({super.key, this.drawerKey});

/// DrawerKey.
final GlobalKey<ScaffoldState>? drawerKey;

@override
State<AddPost> createState() => _AddPostState();
}

class _AddPostState extends State<AddPost> {
@override
Widget build(BuildContext context) {
// final Uint8List imageBytes = base64Decode(sampleBase64Image);
Expand Down Expand Up @@ -100,15 +105,16 @@ class AddPost extends StatelessWidget {
// button to add hastags to the post.
TextButton(
key: const Key('add_post_text_btn2'),
onPressed: () {
showDialog(
onPressed: () async {
final TextEditingController hashController =
TextEditingController();
hashController.text = model.textHashTagController.text;
await showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Enter the Tag"),
content: TextField(
controller: model.textHashTagController,
),
content: TextField(controller: hashController),
actions: [
TextButton(
key: const Key("add_hashtag_button"),
Expand All @@ -132,11 +138,14 @@ class AddPost extends StatelessWidget {
);
},
);
setState(() {
model.textHashTagController.text = hashController.text;
});
},
child: Text(
model.textHashTagController.text == ""
? '# ${AppLocalizations.of(context)!.strictTranslate("Add tag")}'
: model.textHashTagController.text,
: '# ${model.textHashTagController.text}',
style: Theme.of(context).textTheme.titleLarge,
),
),
Expand Down

0 comments on commit c11e7b3

Please sign in to comment.