@@ -13,6 +13,7 @@ class AddBlog extends StatefulWidget {
1313
1414class _AddBlogState extends State <AddBlog > {
1515 final titleController = TextEditingController ();
16+ final summaryController = TextEditingController ();
1617 final contentController = TextEditingController ();
1718 String ? image;
1819 @override
@@ -25,59 +26,101 @@ class _AddBlogState extends State<AddBlog> {
2526 return ListView (
2627 padding: const EdgeInsets .fromLTRB (15 , 10 , 15 , 10 ),
2728 children: [
28- Row (mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [
29- CircleAvatar (
30- backgroundImage: image == null
31- ? const AssetImage ("assets/images/logo.jpeg" )
32- as ImageProvider <Object >
33- : FileImage (
34- File (image! ),
35- ),
36- radius: 70 ,
29+ TapEffect (
30+ onClick: () async {
31+ final pickedFile =
32+ await ImagePicker .platform.getImageFromSource (
33+ source: ImageSource .gallery,
34+ );
35+ if (pickedFile != null ) {
36+ setState (() {
37+ image = pickedFile.path;
38+ });
39+ }
40+ },
41+ child: Card (
42+ shape: RoundedRectangleBorder (
43+ borderRadius: BorderRadius .circular (10 ),
44+ side: BorderSide (
45+ color: Colors .grey.shade400,
46+ ),
47+ ),
48+ child: SizedBox .square (
49+ dimension: MediaQuery .of (context).size.width / 2.3 ,
50+ child: image != null
51+ ? Image .file (
52+ File (image! ),
53+ fit: BoxFit .cover,
54+ )
55+ : Row (
56+ mainAxisAlignment: MainAxisAlignment .center,
57+ children: [
58+ const Icon (Icons .add),
59+ const SizedBox .square (dimension: 10 ),
60+ Text (
61+ "Add a banner" ,
62+ style: Theme .of (context).textTheme.bodyLarge,
63+ ),
64+ ],
65+ ),
66+ ),
3767 ),
38- IconButton (
39- iconSize: 40 ,
40- icon: const Icon (
41- Icons .add_a_photo_rounded,
68+ ),
69+ const SizedBox .square (dimension: 10 ),
70+ TextFormField (
71+ maxLines: 1 ,
72+ controller: titleController,
73+ readOnly: controller.isLoading,
74+ decoration: InputDecoration (
75+ labelText: "Blog title" ,
76+ labelStyle: Theme .of (context).textTheme.bodyMedium,
77+ hintText: "Enter blog title" ,
78+ border: OutlineInputBorder (
79+ borderRadius: BorderRadius .circular (10 ),
80+ borderSide: BorderSide (
81+ color: Colors .grey.shade200,
82+ ),
4283 ),
43- onPressed: () async {
44- final pickedFile =
45- await ImagePicker .platform.getImageFromSource (
46- source: ImageSource .gallery,
47- );
48- if (pickedFile != null ) {
49- setState (() {
50- image = pickedFile.path;
51- });
52- }
53- },
5484 ),
55- ] ),
56- CommonTextField (
57- titleText : "Title" ,
58- enableBorder : true ,
59- hintText : "Enter title" ,
85+ ),
86+ const SizedBox . square (dimension : 10 ),
87+ TextFormField (
88+ maxLines : 3 ,
89+ controller : summaryController ,
6090 readOnly: controller.isLoading,
61- controller: titleController,
91+ decoration: InputDecoration (
92+ labelText: "Blog summary" ,
93+ labelStyle: Theme .of (context).textTheme.bodyMedium,
94+ hintText: "Enter blog summary" ,
95+ border: OutlineInputBorder (
96+ borderRadius: BorderRadius .circular (10 ),
97+ borderSide: BorderSide (
98+ color: Colors .grey.shade200,
99+ ),
100+ ),
101+ ),
62102 ),
63- const SizedBox .square (dimension: 20 ),
103+ const SizedBox .square (dimension: 10 ),
64104 TextFormField (
65- maxLines: 15 ,
105+ maxLines: 9 ,
66106 controller: contentController,
67107 readOnly: controller.isLoading,
68108 decoration: InputDecoration (
69- // helperText: "Description",
109+ labelText: "Description" ,
110+ labelStyle: Theme .of (context).textTheme.bodyMedium,
70111 hintText: "Enter description" ,
71112 border: OutlineInputBorder (
113+ borderRadius: BorderRadius .circular (10 ),
72114 borderSide: BorderSide (
73115 color: Colors .grey.shade200,
74116 ),
75117 ),
76118 ),
77119 ),
78- const SizedBox .square (dimension: 20 ),
120+ const SizedBox .square (dimension: 10 ),
79121 CustomButton (
80- text: "Add Blog Post" ,
122+ text: "Publish" ,
123+ buttonRadius: 10 ,
81124 loading: controller.isLoading,
82125 buttonColor: controller.isLoading
83126 ? null
@@ -105,6 +148,7 @@ class _AddBlogState extends State<AddBlog> {
105148 BlogService .createBlog ({
106149 "title" : titleController.text,
107150 "content" : contentController.text,
151+ "summary" : summaryController.text,
108152 "league" : widget.league,
109153 "image" : image,
110154 });
0 commit comments