Skip to content

Commit

Permalink
Add items to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
yerzhant committed Jul 16, 2021
1 parent 1c42e43 commit d2d33c0
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 17 deletions.
4 changes: 4 additions & 0 deletions assets/icons/evaluate-app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/icons/proposals.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/app_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AppWidget extends StatelessWidget {
),
),
appBarTheme: AppBarTheme(color: theme.appBarBackground),
popupMenuTheme: PopupMenuThemeData(color: theme.background),
popupMenuTheme: PopupMenuThemeData(color: theme.appMenuBackground),
tabBarTheme: const TabBarTheme(
labelStyle: TextStyle(
fontSize: 16,
Expand Down
10 changes: 10 additions & 0 deletions lib/common/global_functions.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:share/share.dart';
import 'package:url_launcher/url_launcher.dart';

Future<void> shareApp() async {
var text = 'Тафсир Корана\n\n';
Expand All @@ -11,3 +12,12 @@ Future<void> shareApp() async {

await Share.share(text, subject: 'Тафсир Корана');
}

Future<void> evaluateApp() async => launch(
Platform.isIOS
? 'https://apps.apple.com/us/app/id1542515717'
: 'https://play.google.com/store/apps/details?id=ru.azan.tafsir',
);

Future<void> writeToAdmin() async =>
launch('https://azan.ru/site/write-to-admin');
16 changes: 4 additions & 12 deletions lib/home/ui/about_us_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,16 @@ class AboutUsPage extends StatelessWidget {
action: shareApp,
),
const SizedBox(height: 8),
_Action(
const _Action(
title: 'Оценить приложение',
icon: 'evaluate',
action: () {
launch(
Platform.isIOS
? 'https://apps.apple.com/us/app/id1542515717'
: 'https://play.google.com/store/apps/details?id=ru.azan.tafsir',
);
},
action: evaluateApp,
),
const SizedBox(height: 8),
_Action(
const _Action(
title: 'Предложения и замечания',
icon: 'proposals',
action: () {
launch('https://azan.ru/site/write-to-admin');
},
action: writeToAdmin,
),
const SizedBox(height: 8),
_Action(
Expand Down
60 changes: 56 additions & 4 deletions lib/home/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class HomePage extends StatelessWidget {
itemBuilder: (_) => [
_offlineMenuItem(state, context),
_shareMenuItem(state, context),
_evaluateMenuItem(state, context),
_proposalsMenuItem(state, context),
_aboutUsMenuItem(state, context),
],
onSelected: (action) {
Expand All @@ -91,6 +93,14 @@ class HomePage extends StatelessWidget {
shareApp();
break;

case _Actions.evaluate:
evaluateApp();
break;

case _Actions.proposals:
writeToAdmin();
break;

case _Actions.aboutUs:
Modular.to.pushNamed('about-us');
break;
Expand All @@ -107,12 +117,13 @@ class HomePage extends StatelessWidget {
value: _Actions.aboutUs,
child: Row(
children: [
const SizedBox(width: 3),
Image.asset(
'assets/icons/logo.png',
height: 20,
color: state.appMenuIcon,
),
const SizedBox(width: 16),
const SizedBox(width: 17.33),
Text(
'О нас',
style: Theme.of(context).textTheme.subtitle2,
Expand All @@ -132,9 +143,50 @@ class HomePage extends StatelessWidget {
'assets/icons/share.svg',
color: state.appMenuIcon,
),
const SizedBox(width: 17.5),
Text(
'Поделиться приложением',
style: Theme.of(context).textTheme.subtitle2,
),
],
),
);
}

PopupMenuItem<_Actions> _evaluateMenuItem(
ThemeState state, BuildContext context) {
return PopupMenuItem(
value: _Actions.evaluate,
child: Row(
children: [
SvgPicture.asset(
'assets/icons/evaluate-app.svg',
color: state.appMenuIcon,
),
const SizedBox(width: 15.67),
Text(
'Оценить приложение',
style: Theme.of(context).textTheme.subtitle2,
),
],
),
);
}

PopupMenuItem<_Actions> _proposalsMenuItem(
ThemeState state, BuildContext context) {
return PopupMenuItem(
value: _Actions.proposals,
child: Row(
children: [
const SizedBox(width: 2),
SvgPicture.asset(
'assets/icons/proposals.svg',
color: state.appMenuIcon,
),
const SizedBox(width: 16),
Text(
'Поделиться',
'Предложения и замечания',
style: Theme.of(context).textTheme.subtitle2,
),
],
Expand All @@ -152,7 +204,7 @@ class HomePage extends StatelessWidget {
'assets/icons/offline.svg',
color: state.appMenuIcon,
),
const SizedBox(width: 16),
const SizedBox(width: 15.59),
Text(
'Offline режим',
style: Theme.of(context).textTheme.subtitle2,
Expand All @@ -163,4 +215,4 @@ class HomePage extends StatelessWidget {
}
}

enum _Actions { offline, share, aboutUs }
enum _Actions { offline, share, evaluate, proposals, aboutUs }
4 changes: 4 additions & 0 deletions lib/theme/cubit/theme_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ThemeState {
final Color lightThemeButtonText;
final Color dartThemeButtonText;
final Color appMenuIcon;
final Color appMenuBackground;
final Color appBarBackground;
final Color toolsBackground;
final Color toolControlsBackground;
Expand All @@ -34,6 +35,7 @@ class ThemeState {
required this.lightThemeButtonText,
required this.dartThemeButtonText,
required this.appMenuIcon,
required this.appMenuBackground,
required this.appBarBackground,
required this.toolsBackground,
required this.toolControlsBackground,
Expand All @@ -56,6 +58,7 @@ class ThemeState {
lightThemeButtonText: const Color(0xff060d1b),
dartThemeButtonText: const Color(0x80ffffff),
appMenuIcon: const Color(0xffbdbdc2),
appMenuBackground: Colors.white,
appBarBackground: const Color(0xff0088c7),
toolsBackground: const Color(0xffffffff),
toolControlsBackground: const Color(0x7fe5e5e5),
Expand All @@ -78,6 +81,7 @@ class ThemeState {
lightThemeButtonText: const Color(0xffbdbdc2),
dartThemeButtonText: const Color(0xffffffff),
appMenuIcon: const Color(0xffffffff),
appMenuBackground: const Color(0xff1a232a),
appBarBackground: const Color(0xff25303a),
toolsBackground: const Color(0xff25303a),
toolControlsBackground: const Color(0xff1a232a),
Expand Down

0 comments on commit d2d33c0

Please sign in to comment.