-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathMainProfile.dart
127 lines (119 loc) · 3.28 KB
/
MainProfile.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import 'package:blogapp/Blog/Blogs.dart';
import 'package:blogapp/Model/profileModel.dart';
import 'package:blogapp/NetworkHandler.dart';
import 'package:flutter/material.dart';
class MainProfile extends StatefulWidget {
MainProfile({Key key}) : super(key: key);
@override
_MainProfileState createState() => _MainProfileState();
}
class _MainProfileState extends State<MainProfile> {
bool circular = true;
NetworkHandler networkHandler = NetworkHandler();
ProfileModel profileModel = ProfileModel();
@override
void initState() {
super.initState();
fetchData();
}
void fetchData() async {
var response = await networkHandler.get("/profile/getData");
setState(() {
profileModel = ProfileModel.fromJson(response["data"]);
circular = false;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffEEEEFF),
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.white10,
// leading: IconButton(
// icon: Icon(Icons.arrow_back),
// onPressed: () {},
// color: Colors.black,
// ),
actions: <Widget>[
IconButton(
icon: Icon(Icons.edit),
onPressed: () {},
color: Colors.black,
),
],
),
body: circular
? Center(child: CircularProgressIndicator())
: ListView(
children: <Widget>[
head(),
Divider(
thickness: 0.8,
),
otherDetails("About", profileModel.about),
otherDetails("Name", profileModel.name),
otherDetails("Profession", profileModel.profession),
otherDetails("DOB", profileModel.DOB),
Divider(
thickness: 0.8,
),
SizedBox(
height: 20,
),
Blogs(
url: "/blogpost/getOwnBlog",
),
],
),
);
}
Widget head() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Center(
child: CircleAvatar(
radius: 50,
backgroundImage: NetworkHandler().getImage(profileModel.username),
),
),
Text(
profileModel.username,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Text(profileModel.titleline)
],
),
);
}
Widget otherDetails(String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"$label :",
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 5,
),
Text(
value,
style: TextStyle(fontSize: 15),
)
],
),
);
}
}