Skip to content

Commit 81762f3

Browse files
authored
Help section (#14)
* Help sections patch 1 * Help sections patch 2 * Help sections patch 2
1 parent b3ccb34 commit 81762f3

6 files changed

Lines changed: 145 additions & 85 deletions

File tree

assets/help_anim.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lib/api/interceptor_logger.dart

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,60 @@ import 'package:dio/dio.dart';
22
import 'package:flutter/foundation.dart';
33

44
class PrinterInterceptor extends Interceptor {
5+
static const tag = '[HTTP] ';
56

67
@override
78
Future onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
8-
if (kDebugMode) print('''-------------------> HTTP REQUEST
9-
Method: ${options.method}
10-
Headers: ${options.headers}
11-
Path: ${options.baseUrl}${options.path}
12-
Query parameters: ${options.queryParameters}
13-
Data: ${options.data}
14-
Content type: ${options.contentType}
15-
-------------------> END HTTP REQUEST''');
9+
if (kDebugMode) {
10+
var log = '';
11+
log += '$tag------------------->\n';
12+
log += '$tag[${options.method}] ${options.baseUrl}${options.path}\n';
13+
if (options.headers.isNotEmpty) {
14+
log += '$tag${options.headers}\n';
15+
}
16+
if (options.queryParameters.isNotEmpty) {
17+
log += '$tag${options.queryParameters}\n';
18+
}
19+
if (options.data != null) {
20+
log += '$tag${options.data}\n';
21+
}
22+
log += '$tag------------------->\n';
23+
print(log);
24+
}
1625
return super.onRequest(options, handler);
1726
}
1827

1928
@override
2029
Future onResponse(Response response, ResponseInterceptorHandler handler) async {
21-
if (kDebugMode) print('''<------------------- HTTP RESPONSE
22-
Status code: ${response.statusCode}
23-
Headers: ${response.headers}
24-
Response data: ${response.data}
25-
Path: ${response.realUri}
26-
<------------------- END HTTP RESPONSE''');
30+
if (kDebugMode) {
31+
var log = '';
32+
log += '$tag<-------------------\n';
33+
log += '$tag[${response.statusCode}] ${response.realUri}\n';
34+
if (response.data != null) {
35+
log += '$tag${response.data}\n';
36+
}
37+
log += '$tag<-------------------\n';
38+
print(log);
39+
}
2740
super.onResponse(response, handler);
2841
}
2942

3043
@override
3144
void onError(DioError err, ErrorInterceptorHandler handler) async {
32-
if (kDebugMode) print('''<------------------- HTTP ERROR
33-
Headers: ${err.response?.headers.map ?? {}}
34-
Response: ${err.response}
35-
Error type: ${err.type}
36-
Error message: ${err.message}
37-
Path: ${err.response?.realUri}
38-
<------------------- END HTTP ERROR''');
45+
if (kDebugMode) {
46+
var log = '';
47+
log += '$tag<-------------------\n';
48+
log += '$tag[${err.response?.statusCode}] ${err.response?.realUri}\n';
49+
if (err.response?.headers != null
50+
&& err.response?.headers.isEmpty == false) {
51+
log += '$tag${err.response?.headers}\n';
52+
}
53+
if (err.response?.data != null) {
54+
log += '$tag${err.response?.data}\n';
55+
}
56+
log += '$tag<-------------------\n';
57+
print(log);
58+
}
3959
super.onError(err, handler);
4060
}
4161
}

lib/config/config.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
class WooAppConfig {
2+
static const String helpUrlCustomerSupport = 'https://woo.moroz.cc/support/';
3+
static const String helpUrlFaq = 'https://woo.moroz.cc/faq/';
4+
static const String helpUrlPrivacyPolicy = 'https://woo.moroz.cc/privacy-policy/';
5+
static const String helpUrlTermsOfUse = 'https://woo.moroz.cc/terms/';
6+
static const String helpUrlAbout = 'https://woo.moroz.cc/about/';
7+
8+
29
static const String currency = '\$';
310
static const int paginationLimit = 10;
411

lib/screens/help/help_screen.dart

Lines changed: 90 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'package:easy_localization/easy_localization.dart';
22
import 'package:flutter/material.dart';
33
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
4+
import 'package:lottie/lottie.dart';
5+
import 'package:url_launcher/url_launcher.dart';
6+
import 'package:wooapp/config/config.dart';
47
import 'package:wooapp/config/theme.dart';
58
import 'package:wooapp/widget/widget_woo_section.dart';
69

@@ -18,66 +21,96 @@ class HelpScreen extends StatelessWidget {
1821
),
1922
).tr(),
2023
backgroundColor: WooAppTheme.colorToolbarBackground,
24+
elevation: 0,
2125
),
22-
backgroundColor: WooAppTheme.colorCommonBackground,
23-
body: SafeArea(
24-
child: SingleChildScrollView(
25-
child: Column(
26-
children: [
27-
SizedBox(height: 16),
28-
WooSection(
29-
icon: FaIcon(
30-
FontAwesomeIcons.headset,
31-
color: WooAppTheme.colorCommonSectionForeground,
32-
),
33-
text: tr('support'),
34-
action: () {},
26+
backgroundColor: WooAppTheme.colorToolbarBackground,
27+
body: SafeArea(//help_anim.json
28+
child: Stack(
29+
children: [
30+
Lottie.asset(
31+
'assets/help_anim.json',
32+
width: MediaQuery.of(context).size.width * 1.0,
33+
height: MediaQuery.of(context).size.height * 0.4,
34+
),
35+
Container(
36+
child: Column(
37+
mainAxisAlignment: MainAxisAlignment.end,
38+
children: [
39+
Container(
40+
decoration: BoxDecoration(
41+
color: WooAppTheme.colorCommonBackground,
42+
borderRadius: BorderRadius.only(
43+
topLeft: const Radius.circular(20.0),
44+
topRight: const Radius.circular(20.0),
45+
),
46+
),
47+
child: _buildHelpSections(),
48+
),
49+
],
3550
),
36-
WooSection(
37-
icon: FaIcon(
38-
FontAwesomeIcons.question,
39-
color: WooAppTheme.colorCommonSectionForeground,
40-
),
41-
text: tr('faq'),
42-
action: () {},
43-
),
44-
SizedBox(height: 8),
45-
WooSection(
46-
icon: FaIcon(
47-
FontAwesomeIcons.book,
48-
color: WooAppTheme.colorCommonSectionForeground,
49-
),
50-
text: tr('privacy_policy'),
51-
action: () {},
52-
),
53-
WooSection(
54-
icon: FaIcon(
55-
FontAwesomeIcons.list,
56-
color: WooAppTheme.colorCommonSectionForeground,
57-
),
58-
text: tr('terms_of_use'),
59-
action: () {},
60-
),
61-
WooSection(
62-
icon: FaIcon(
63-
FontAwesomeIcons.circleInfo,
64-
color: WooAppTheme.colorCommonSectionForeground,
65-
),
66-
text: tr('about_us'),
67-
action: () {},
68-
),
69-
SizedBox(height: 8),
70-
WooSection(
71-
icon: FaIcon(
72-
FontAwesomeIcons.star,
73-
color: WooAppTheme.colorCommonSectionForeground,
74-
),
75-
text: tr('rate_app'),
76-
action: () {},
77-
),
78-
],
79-
),
51+
),
52+
],
8053
),
8154
),
8255
);
56+
57+
Widget _buildHelpSections() => Column(
58+
children: [
59+
SizedBox(height: 16),
60+
WooSection(
61+
icon: FaIcon(
62+
FontAwesomeIcons.headset,
63+
color: WooAppTheme.colorCommonSectionForeground,
64+
),
65+
text: tr('support'),
66+
action: () => _openUrl(WooAppConfig.helpUrlCustomerSupport),
67+
),
68+
WooSection(
69+
icon: FaIcon(
70+
FontAwesomeIcons.question,
71+
color: WooAppTheme.colorCommonSectionForeground,
72+
),
73+
text: tr('faq'),
74+
action: () => _openUrl(WooAppConfig.helpUrlFaq),
75+
),
76+
WooSection(
77+
icon: FaIcon(
78+
FontAwesomeIcons.book,
79+
color: WooAppTheme.colorCommonSectionForeground,
80+
),
81+
text: tr('privacy_policy'),
82+
action: () => _openUrl(WooAppConfig.helpUrlPrivacyPolicy),
83+
),
84+
WooSection(
85+
icon: FaIcon(
86+
FontAwesomeIcons.list,
87+
color: WooAppTheme.colorCommonSectionForeground,
88+
),
89+
text: tr('terms_of_use'),
90+
action: () => _openUrl(WooAppConfig.helpUrlTermsOfUse),
91+
),
92+
WooSection(
93+
icon: FaIcon(
94+
FontAwesomeIcons.circleInfo,
95+
color: WooAppTheme.colorCommonSectionForeground,
96+
),
97+
text: tr('about_us'),
98+
action: () => _openUrl(WooAppConfig.helpUrlAbout),
99+
),
100+
/*WooSection(
101+
icon: FaIcon(
102+
FontAwesomeIcons.star,
103+
color: WooAppTheme.colorCommonSectionForeground,
104+
),
105+
text: tr('rate_app'),
106+
action: () {},
107+
),*/
108+
SizedBox(height: 12),
109+
],
110+
);
111+
112+
void _openUrl(String url) => launchUrl(
113+
Uri.parse(url),
114+
mode: LaunchMode.externalApplication,
115+
);
83116
}

lib/screens/profile/profile_view.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class ProfileView extends StatelessWidget {
322322
color: WooAppTheme.colorCommonSectionForeground,
323323
),
324324
text: tr('help'),
325-
action: () => Navigator.of(context)
325+
action: () => Navigator
326+
.of(context)
326327
.push(MaterialPageRoute(builder: (_) => HelpScreen())),
327328
),
328329
SizedBox(height: 8),

lib/widget/widget_woo_version.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ class _WooVersionWidgetState extends State<WooVersionWidget> {
4141
_buildAppDetails(),
4242
SizedBox(height: 6),
4343
GestureDetector(
44-
onTap: () {
45-
launchUrl(
46-
Uri.parse(_copyrightWebSite),
47-
mode: LaunchMode.externalApplication,
48-
);
49-
},
44+
onTap: () => launchUrl(
45+
Uri.parse(_copyrightWebSite),
46+
mode: LaunchMode.externalApplication,
47+
),
5048
child: Text(
5149
_appCopyright,
5250
style: TextStyle(

0 commit comments

Comments
 (0)