192 lines
7 KiB
Dart
192 lines
7 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:mnemo_cards/admin/add_plan.dart';
|
|
import 'package:mnemo_cards/admin/add_promocode_campaign.dart';
|
|
import 'package:mnemo_cards/domain/router/app_router.dart';
|
|
import 'package:mnemo_cards/domain/router/app_router.gr.dart';
|
|
import 'package:mnemo_cards/features/yandex_ads/yandex_ads.dart';
|
|
import 'package:mnemo_cards/flags.dart';
|
|
import 'package:mnemo_cards/main.dart';
|
|
import 'package:mnemo_cards_frontend_common/mnemo_cards_frontend_common.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../admin/all_cards.dart';
|
|
import '../admin/all_users.dart';
|
|
import '../di/locator.dart';
|
|
import '../domain/router/dialogs.dart';
|
|
import '../features/analytics/analytics.dart';
|
|
import '../theme/themes.dart';
|
|
import '../widgets/buy_subscription_widget.dart';
|
|
import '../widgets/enter_promo_code_widget.dart';
|
|
import '../widgets/shared_pref_button.dart';
|
|
|
|
@RoutePage()
|
|
class ProfilePage extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Analytics.profilePageOpened(locator.userManager.userStateHolder.user);
|
|
locator.userManager.updateUser();
|
|
final theme = Theme.of(context).textTheme;
|
|
int i = 0;
|
|
context.visitAncestorElements((visitor) {
|
|
if (visitor.widget.runtimeType == SizedBox) {
|
|
if ((visitor.widget as SizedBox).width == 200) {
|
|
print('found');
|
|
}
|
|
i++;
|
|
}
|
|
return true;
|
|
});
|
|
return Scaffold(
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Header(
|
|
'Профиль',
|
|
popText: 'назад',
|
|
hasPopButton: true,
|
|
trail: GestureDetector(
|
|
onTap: () async {
|
|
await locator.userManager.logout();
|
|
final showAdmin = SHOW_ADMIN;
|
|
final sp = await SharedPreferences.getInstance();
|
|
sp.clear();
|
|
if (showAdmin) {
|
|
globalSharedPreferences.setBool('show_admin', true);
|
|
}
|
|
AppRouter.openAuthOrProfile();
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Image.asset(
|
|
'icons/exit.png',
|
|
width: 25.w,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 8.h,
|
|
),
|
|
Expanded(
|
|
child: ListView(
|
|
physics: PageScrollPhysics(),
|
|
children: [
|
|
SizedBox(
|
|
height: 320.h,
|
|
child: StreamBuilder(
|
|
stream: locator.userManager.userStateHolder.asStream,
|
|
builder: (context, snapshot) {
|
|
final userData = snapshot.data?.userDataDto;
|
|
return Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 10.0,
|
|
right: 10.0,
|
|
bottom: 8.0,
|
|
),
|
|
child: UserStatistics(userData),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
child: Column(
|
|
children: [
|
|
Divider(
|
|
height: 5,
|
|
color: borderGray.withOpacity(0.2),
|
|
),
|
|
const MobileEnterPromoCodeWidget(),
|
|
Divider(
|
|
height: 5,
|
|
color: borderGray.withOpacity(0.2),
|
|
),
|
|
const MobileBuySubscriptionWidget(),
|
|
Divider(
|
|
height: 5,
|
|
color: borderGray.withOpacity(0.2),
|
|
),
|
|
if (SHOW_ADMIN) ...[
|
|
SimpleTile(
|
|
title: Text('Посмотреть рекламу'),
|
|
onTap: () {
|
|
YandexAds.showRewardedAd((r) {
|
|
showInfoDialog(
|
|
'Вы получили\n${r.amount} ${r.type}');
|
|
});
|
|
},
|
|
),
|
|
Divider(
|
|
height: 5,
|
|
color: borderGray.withOpacity(0.2),
|
|
),
|
|
],
|
|
SimpleTile.text(
|
|
text: 'Написать в телеграм',
|
|
onTap: () => launchUrl(
|
|
Uri.parse('https://t.me/mnemo_cards_bot'),
|
|
),
|
|
),
|
|
Divider(
|
|
height: 5,
|
|
color: borderGray.withOpacity(0.2),
|
|
),
|
|
SimpleTile(
|
|
onTap: () => appRouter.push(
|
|
PageRouteInfo(SettingsPage.name),
|
|
),
|
|
title: Row(
|
|
children: [
|
|
Image.asset(
|
|
'icons/settings.png',
|
|
width: 16.w,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
SizedBox(width: 8.w),
|
|
Expanded(child: Text('Настройки там')),
|
|
],
|
|
),
|
|
trail: Image.asset(
|
|
'icons/next.png',
|
|
width: 16.w,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
),
|
|
Divider(
|
|
height: 5,
|
|
color: borderGray.withOpacity(0.2),
|
|
),
|
|
SizedBox(
|
|
height: 10.0.h,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (MediaQuery.of(context).viewInsets.bottom < 30.0)
|
|
const BigBackButton(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> clearAndExit() async {
|
|
final sp = await SharedPreferences.getInstance();
|
|
sp.clear();
|
|
exit(0);
|
|
}
|
|
|
|
const ProfilePage();
|
|
}
|