Skip to content

Commit 0d9b87f

Browse files
authored
App version & copyright (#7)
1 parent 1b9f24f commit 0d9b87f

4 files changed

Lines changed: 272 additions & 141 deletions

File tree

lib/screens/profile/profile_view.dart

Lines changed: 152 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,40 @@ import 'package:wooapp/widget/shimmer.dart';
2525
import 'package:wooapp/widget/stateful_wrapper.dart';
2626
import 'package:wooapp/widget/widget_retry.dart';
2727
import 'package:wooapp/widget/widget_woo_section.dart';
28+
import 'package:wooapp/widget/widget_woo_version.dart';
2829

2930
class ProfileView extends StatelessWidget {
3031
@override
3132
Widget build(BuildContext context) => StatefulWrapper(
32-
onInit: () {
33-
context.read<ProfileCubit>().getProfile();
34-
},
35-
child: Scaffold(
36-
backgroundColor: WooAppTheme.colorCommonBackground,
37-
body: BlocListener<ProfileCubit, ProfileState>(
38-
listener: (context, state) {
39-
switch (state.runtimeType) {
40-
//ToDo ...
41-
}
42-
},
43-
child: BlocBuilder<ProfileCubit, ProfileState>(
44-
builder: (context, state) {
45-
switch (state.runtimeType) {
46-
case InitialProfileState:
47-
return _loadingState(context);
48-
case LoadingProfileState:
49-
return _loadingState(context);
50-
case ContentProfileState:
51-
return _contentState(context, (state as ContentProfileState).profile);
52-
case ErrorProfileState:
53-
return _errorState(context);
54-
case NoAuthProfileState:
55-
return _noAuth(context);
56-
default:
57-
return _loadingState(context);
58-
}
59-
},
33+
onInit: () {
34+
context.read<ProfileCubit>().getProfile();
35+
},
36+
child: Scaffold(
37+
backgroundColor: WooAppTheme.colorCommonBackground,
38+
body: BlocListener<ProfileCubit, ProfileState>(
39+
listener: (context, state) {},
40+
child: BlocBuilder<ProfileCubit, ProfileState>(
41+
builder: (context, state) {
42+
switch (state.runtimeType) {
43+
case InitialProfileState:
44+
return _loadingState(context);
45+
case LoadingProfileState:
46+
return _loadingState(context);
47+
case ContentProfileState:
48+
return _contentState(
49+
context, (state as ContentProfileState).profile);
50+
case ErrorProfileState:
51+
return _errorState(context);
52+
case NoAuthProfileState:
53+
return _noAuth(context);
54+
default:
55+
return _loadingState(context);
56+
}
57+
},
58+
),
6059
),
6160
),
62-
),
63-
);
61+
);
6462

6563
Widget _noAuth(BuildContext context) => NoAuthScreen(
6664
title: tr('tab_profile'),
@@ -75,116 +73,131 @@ class ProfileView extends StatelessWidget {
7573
Widget _contentState(
7674
BuildContext context,
7775
CustomerProfile profile,
78-
) => Scaffold(
79-
appBar: AppBar(
80-
title: Text(
81-
'tab_profile',
82-
style: TextStyle(
83-
color: WooAppTheme.colorToolbarForeground,
84-
),
85-
).tr(),
86-
leading: Icon(
87-
Icons.person,
88-
color: WooAppTheme.colorToolbarForeground,
89-
),
90-
backgroundColor: WooAppTheme.colorToolbarBackground,
91-
elevation: 0,
92-
actions: [
93-
IconButton(
94-
onPressed: () {
95-
Navigator
96-
.push(context, MaterialPageRoute(builder: (_) => ProfileEditScreen()))
97-
.then((value) {
98-
if (value == true) {
99-
context.read<ProfileCubit>().forceRefreshProfile();
100-
}
101-
print('back, context = $context');
102-
});
103-
},
104-
icon: Icon(
105-
Icons.edit,
76+
) =>
77+
Scaffold(
78+
appBar: AppBar(
79+
title: Text(
80+
'tab_profile',
81+
style: TextStyle(
82+
color: WooAppTheme.colorToolbarForeground,
83+
),
84+
).tr(),
85+
leading: Icon(
86+
Icons.person,
10687
color: WooAppTheme.colorToolbarForeground,
10788
),
89+
backgroundColor: WooAppTheme.colorToolbarBackground,
90+
elevation: 0,
91+
actions: [
92+
IconButton(
93+
onPressed: () {
94+
Navigator.push(
95+
context,
96+
MaterialPageRoute(
97+
builder: (_) => ProfileEditScreen(),
98+
),
99+
).then((value) {
100+
if (value == true) {
101+
context.read<ProfileCubit>().forceRefreshProfile();
102+
}
103+
print('back, context = $context');
104+
});
105+
},
106+
icon: Icon(
107+
Icons.edit,
108+
color: WooAppTheme.colorToolbarForeground,
109+
),
110+
),
111+
],
108112
),
109-
],
110-
),
111-
backgroundColor: WooAppTheme.colorCommonBackground,
112-
body: SafeArea(
113-
child: Container(
114-
child: SingleChildScrollView(
115-
child: Column(
116-
crossAxisAlignment: CrossAxisAlignment.center,
117-
children: [
118-
Container(
119-
color: WooAppTheme.colorToolbarBackground,
120-
child: Padding(
121-
padding: EdgeInsets.only(bottom: 16),
122-
child: Column(
123-
children: [
124-
Center(
125-
child: CircleAvatar(
126-
backgroundColor: Colors.blueGrey,
127-
radius: 40,
128-
child: ClipRRect(
129-
borderRadius: BorderRadius.all(Radius.circular(40)),
130-
child: InkWell(
131-
onTap: () => Navigator
132-
.of(context)
133-
.push(MaterialPageRoute(builder: (_) => GalleryScreen([profile.avatar]))),
134-
child: CachedNetworkImage(
135-
imageUrl: profile.avatar,
136-
imageBuilder: (context, imageProvider) => Container(
137-
decoration: BoxDecoration(
138-
image: DecorationImage(
139-
image: imageProvider,
140-
fit: BoxFit.cover,
113+
backgroundColor: WooAppTheme.colorCommonBackground,
114+
body: SafeArea(
115+
child: Container(
116+
child: SingleChildScrollView(
117+
child: Column(
118+
crossAxisAlignment: CrossAxisAlignment.center,
119+
children: [
120+
Container(
121+
color: WooAppTheme.colorToolbarBackground,
122+
child: Padding(
123+
padding: EdgeInsets.only(bottom: 16),
124+
child: Column(
125+
children: [
126+
Center(
127+
child: CircleAvatar(
128+
backgroundColor: Colors.blueGrey,
129+
radius: 40,
130+
child: ClipRRect(
131+
borderRadius: BorderRadius.all(
132+
Radius.circular(40),
133+
),
134+
child: InkWell(
135+
onTap: () => Navigator.of(context).push(
136+
MaterialPageRoute(
137+
builder: (_) => GalleryScreen(
138+
[
139+
profile.avatar,
140+
],
141+
),
141142
),
142143
),
143-
),
144-
placeholder: (context, url) => Shimmer(
145-
duration: Duration(seconds: 1),
146-
enabled: true,
147-
direction: ShimmerDirection.fromLTRB(),
148-
color: WooAppTheme.colorShimmerForeground,
149-
child: Container(
150-
color: WooAppTheme.colorShimmerBackground,
144+
child: CachedNetworkImage(
145+
imageUrl: profile.avatar,
146+
imageBuilder: (context, imageProvider) =>
147+
Container(
148+
decoration: BoxDecoration(
149+
image: DecorationImage(
150+
image: imageProvider,
151+
fit: BoxFit.cover,
152+
),
153+
),
154+
),
155+
placeholder: (context, url) => Shimmer(
156+
duration: Duration(seconds: 1),
157+
enabled: true,
158+
direction: ShimmerDirection.fromLTRB(),
159+
color: WooAppTheme.colorShimmerForeground,
160+
child: Container(
161+
color:
162+
WooAppTheme.colorShimmerBackground,
163+
),
164+
),
165+
errorWidget: (context, url, error) =>
166+
Center(child: Icon(Icons.error)),
151167
),
152168
),
153-
errorWidget: (context, url, error) => Center(child: Icon(Icons.error)),
154169
),
155170
),
156171
),
157-
),
158-
),
159-
SizedBox(height: 6),
160-
Text(
161-
'${profile.username}',
162-
style: TextStyle(
163-
fontSize: 24,
164-
color: WooAppTheme.colorToolbarForeground,
165-
),
166-
overflow: TextOverflow.ellipsis,
167-
maxLines: 1,
168-
),
169-
SizedBox(height: 6),
170-
Text(
171-
'${profile.firstName} ${profile.lastName}',
172-
style: TextStyle(
173-
fontSize: 16,
174-
color: WooAppTheme.colorToolbarForeground,
175-
),
172+
SizedBox(height: 6),
173+
Text(
174+
'${profile.username}',
175+
style: TextStyle(
176+
fontSize: 24,
177+
color: WooAppTheme.colorToolbarForeground,
178+
),
179+
overflow: TextOverflow.ellipsis,
180+
maxLines: 1,
181+
),
182+
SizedBox(height: 6),
183+
Text(
184+
'${profile.firstName} ${profile.lastName}',
185+
style: TextStyle(
186+
fontSize: 16,
187+
color: WooAppTheme.colorToolbarForeground,
188+
),
189+
),
190+
],
176191
),
177-
],
192+
),
178193
),
179-
),
194+
..._profileSections(context),
195+
],
180196
),
181-
..._profileSections(context),
182-
],
197+
),
183198
),
184199
),
185-
),
186-
)
187-
);
200+
);
188201

189202
Widget _loadingState(BuildContext context) =>
190203
ProfileShimmer(_profileSections(context));
@@ -315,19 +328,21 @@ class ProfileView extends StatelessWidget {
315328
),
316329
),
317330
SizedBox(height: 16),
331+
WooVersionWidget(),
332+
SizedBox(height: 16),
318333
];
319334

320335
AppBar _appBarFallback() => AppBar(
321-
title: Text(
322-
'tab_profile',
323-
style: TextStyle(
324-
color: WooAppTheme.colorToolbarForeground,
325-
),
326-
).tr(),
327-
leading: Icon(
328-
Icons.person,
329-
color: WooAppTheme.colorToolbarForeground,
330-
),
331-
backgroundColor: WooAppTheme.colorToolbarBackground,
332-
);
336+
title: Text(
337+
'tab_profile',
338+
style: TextStyle(
339+
color: WooAppTheme.colorToolbarForeground,
340+
),
341+
).tr(),
342+
leading: Icon(
343+
Icons.person,
344+
color: WooAppTheme.colorToolbarForeground,
345+
),
346+
backgroundColor: WooAppTheme.colorToolbarBackground,
347+
);
333348
}

lib/widget/widget_woo_section.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ class WooSection extends StatelessWidget {
6363
SizedBox(width: 8),
6464
Icon(
6565
Icons.arrow_forward_ios,
66-
color: WooAppTheme.colorCommonSectionForeground,
66+
size: 16,
67+
color: WooAppTheme.colorCommonSectionForeground
68+
.withOpacity(0.35),
6769
),
70+
SizedBox(width: 6),
6871
],
6972
),
7073
),

0 commit comments

Comments
 (0)