resiolve warnings

This commit is contained in:
MohammadTaha Basiri 2023-03-18 18:57:22 +03:30
parent 350c55aad6
commit 4dc5470fdb
65 changed files with 179 additions and 166 deletions

View File

@ -8,9 +8,7 @@ class LightThemeConfig {
static const Color _background = Color(0xFFF8F8FA);
static ThemeData get themeData => ThemeData(
backgroundColor: _background,
scaffoldBackgroundColor: _background,
colorScheme: _colorScheme,
textTheme: _TextThemeData.data,
cardColor: _colorScheme.surface,
checkboxTheme: CheckboxThemeData(
@ -21,7 +19,7 @@ class LightThemeConfig {
),
iconTheme: IconThemeData(
color: _colorScheme.text,
),
), colorScheme: _colorScheme.copyWith(background: _background),
);
static const ColorScheme _colorScheme = ColorScheme(
@ -47,9 +45,7 @@ class DarkThemeConfig {
static const Color _background = Color(0xFF202224);
static ThemeData get themeData => ThemeData(
backgroundColor: _background,
scaffoldBackgroundColor: _background,
colorScheme: _colorScheme,
textTheme: _TextThemeData.data,
iconTheme: IconThemeData(
color: _colorScheme.text,
@ -61,7 +57,7 @@ class DarkThemeConfig {
borderRadius: BorderRadius.circular(4),
),
),
cardColor: _colorScheme.surface,
cardColor: _colorScheme.surface, colorScheme: _colorScheme.copyWith(background: _background),
);
static const ColorScheme _colorScheme = ColorScheme(
@ -98,13 +94,13 @@ class _TextThemeData {
static TextTheme get data => DesignConfig.context == null
? const TextTheme()
: TextTheme(
bodyText1: _body1Text,
bodyText2: _body2Text,
caption: _captionText,
subtitle2: _subtitle2Text,
subtitle1: _subtitle1Text,
headline3: _headline3Text,
overline: _overlineText,
bodyLarge: _body1Text,
bodyMedium: _body2Text,
bodySmall: _captionText,
titleSmall: _subtitle2Text,
titleMedium: _subtitle1Text,
displaySmall: _headline3Text,
labelSmall: _overlineText,
);
static TextStyle get _headline3Text => TextStyle(

View File

@ -1,4 +1,5 @@
import 'package:didvan/models/category.dart';
// ignore: depend_on_referenced_packages
import 'package:html/parser.dart';
class OverviewData {

View File

@ -1,5 +1,6 @@
import 'package:didvan/services/network/request.dart';
import 'package:didvan/services/network/request_helper.dart';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
class ServerDataProvider {

View File

@ -1,3 +1,4 @@
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:didvan/models/enums.dart';
import 'package:didvan/models/user.dart';

View File

@ -25,6 +25,7 @@ class AppInitializer {
(await getApplicationDocumentsDirectory()).path;
StorageService.appTempsDir = (await getTemporaryDirectory()).path;
}
// ignore: use_build_context_synchronously
final studioState = context.read<StudioDetailsState>();
MediaService.audioPlayer.isPlaying.listen((event) {
if (event &&

View File

@ -1,7 +1,9 @@
import 'dart:convert';
import 'dart:developer';
import 'package:didvan/services/storage/storage.dart';
// ignore: depend_on_referenced_packages
import 'package:http/http.dart' as http;
// ignore: depend_on_referenced_packages
import 'package:http_parser/http_parser.dart' as parser;
import 'package:permission_handler/permission_handler.dart';
@ -125,7 +127,7 @@ class RequestService {
fieldName,
file.readAsBytes().asStream(),
length,
filename: fileName + '.' + mediaExtension,
filename: '$fileName.$mediaExtension',
contentType: parser.MediaType(mediaFormat, mediaExtension),
),
);

View File

@ -11,7 +11,6 @@ import 'package:didvan/views/widgets/didvan/button.dart';
import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class ActionSheetUtils {
static late BuildContext context;
@ -131,7 +130,7 @@ class ActionSheetUtils {
if (data.titleIcon != null) const SizedBox(width: 8),
DidvanText(
data.title!,
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).textTheme.titleMedium,
color: data.titleColor ??
Theme.of(context).colorScheme.title,
)
@ -209,7 +208,7 @@ class ActionSheetUtils {
Expanded(
child: DidvanText(
data.title!,
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
color: data.titleColor,
fontWeight: FontWeight.bold,
),

View File

@ -51,7 +51,7 @@ class DateTimeUtils {
data: Theme.of(context).copyWith(
textTheme: Theme.of(context)
.textTheme
.copyWith(headline4: Theme.of(context).textTheme.headline3)),
.copyWith(headlineMedium: Theme.of(context).textTheme.displaySmall)),
child: child!,
),
);

View File

@ -51,7 +51,7 @@ class _PasswordInputState extends State<PasswordInput> {
onTap: () => state.currentPageIndex++,
child: DidvanText(
'فراموشی رمز عبور',
style: Theme.of(context).textTheme.subtitle2,
style: Theme.of(context).textTheme.titleSmall,
color: Theme.of(context).colorScheme.primary,
),
),
@ -79,7 +79,9 @@ class _PasswordInputState extends State<PasswordInput> {
ActionSheetUtils.showLogoLoadingIndicator();
await ServerDataProvider.getData();
ActionSheetUtils.pop();
Navigator.of(context).pushReplacementNamed(Routes.home);
if (mounted) {
Navigator.of(context).pushReplacementNamed(Routes.home);
}
_showResetPasswordDialog();
}
}

View File

@ -53,6 +53,7 @@ class _ResetPasswordState extends State<ResetPassword> {
final result = await context
.read<AuthenticationState>()
.resetPassword(_password);
if (!mounted) return;
if (result && context.read<UserProvider>().isAuthenticated) {
Navigator.of(context).pop();
Navigator.of(context).pop();

View File

@ -63,14 +63,14 @@ class _UsernameInputState extends State<UsernameInput> {
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
children: [
const TextSpan(text: 'با ورود به دیدوان،'),
TextSpan(
text: ' شرایط ',
style: Theme.of(context)
.textTheme
.caption!
.bodySmall!
.copyWith(color: Theme.of(context).colorScheme.primary),
recognizer: TapGestureRecognizer()
..onTap = () => launchUrl(
@ -84,7 +84,7 @@ class _UsernameInputState extends State<UsernameInput> {
text: ' قوانین حریم خصوصی ',
style: Theme.of(context)
.textTheme
.caption!
.bodySmall!
.copyWith(color: Theme.of(context).colorScheme.primary),
recognizer: TapGestureRecognizer()
..onTap = () => launchUrl(

View File

@ -52,7 +52,7 @@ class _VerificationState extends State<Verification> {
children: [
DidvanText(
'کد 6 رقمی ارسال شده به موبایل',
style: Theme.of(context).textTheme.subtitle2,
style: Theme.of(context).textTheme.titleSmall,
fontWeight: FontWeight.normal,
),
const SizedBox(
@ -60,14 +60,14 @@ class _VerificationState extends State<Verification> {
),
DidvanText(
state.username,
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(
height: 8,
),
DidvanText(
'را وارد کنید:',
style: Theme.of(context).textTheme.subtitle2,
style: Theme.of(context).textTheme.titleSmall,
fontWeight: FontWeight.normal,
),
const SizedBox(

View File

@ -30,7 +30,7 @@ class AuthenticationAppBar extends StatelessWidget {
if (title != null)
DidvanText(
title!,
style: Theme.of(context).textTheme.subtitle2,
style: Theme.of(context).textTheme.titleSmall,
color: Theme.of(context).colorScheme.title,
)
],

View File

@ -1,5 +1,4 @@
import 'package:didvan/views/authentication/widgets/authentication_app_bar.dart';
import 'package:didvan/views/widgets/logos/didvan_horizontal_logo.dart';
import 'package:didvan/views/widgets/logos/didvan_vertical_logo.dart';
import 'package:flutter/material.dart';

View File

@ -144,7 +144,7 @@ class _MessageBoxState extends State<_MessageBox> {
DidvanText(
'پاسخ به ${state.replyingTo!.fullName}:',
color: Theme.of(context).colorScheme.caption,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
const Spacer(),
DidvanIconButton(
@ -185,13 +185,13 @@ class _MessageBoxState extends State<_MessageBox> {
controller: _controller,
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.send,
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
onEditingComplete: () {},
onSubmitted: (value) => _onSend(state),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'پیام خود را ارسال کنید',
hintStyle: Theme.of(context).textTheme.caption!.copyWith(
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Theme.of(context).colorScheme.disabledText),
),
onChanged: (value) => state.text = value,

View File

@ -92,12 +92,12 @@ class CommentState extends State<Comment> {
children: [
DidvanText(
comment.user.fullName,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
const Spacer(),
DidvanText(
DateTimeUtils.momentGenerator(comment.createdAt),
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.caption,
),
const SizedBox(width: 4),
@ -113,7 +113,7 @@ class CommentState extends State<Comment> {
if (isReply)
DidvanText(
'پاسخ به ${comment.toUser.fullName}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.caption,
),
const SizedBox(height: 8),
@ -153,7 +153,7 @@ class CommentState extends State<Comment> {
},
child: DidvanText(
'پاسخ',
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
color: Theme.of(context).colorScheme.primary,
),
),
@ -167,7 +167,7 @@ class CommentState extends State<Comment> {
children: [
DidvanText(
'پاسخ‌ها(${comment.replies.length})',
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
color: Theme.of(context).colorScheme.primary,
),
AnimatedRotation(
@ -284,7 +284,7 @@ class _FeedbackButtonsState extends State<_FeedbackButtons> {
children: [
DidvanText(
_likeCount.toString(),
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.caption,
),
const SizedBox(width: 4),
@ -312,7 +312,7 @@ class _FeedbackButtonsState extends State<_FeedbackButtons> {
const SizedBox(width: 16),
DidvanText(
_dislikeCount.toString(),
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.caption,
),
const SizedBox(width: 4),

View File

@ -131,7 +131,7 @@ class _DirectState extends State<Direct> {
),
DidvanText(
'${state.deletionQueue.length} مورد انتخاب شد',
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).textTheme.titleMedium,
color: Theme.of(context).colorScheme.secondary,
),
const Spacer(),

View File

@ -60,7 +60,7 @@ class Message extends StatelessWidget {
),
child: DidvanText(
DateTime.parse(message.createdAt).toPersianDateStr(),
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: DesignConfig.isDark
? Theme.of(context).colorScheme.white
: Theme.of(context).colorScheme.black,
@ -103,7 +103,7 @@ class Message extends StatelessWidget {
children: [
DidvanText(
DateTimeUtils.timeWithAmPm(message.createdAt),
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
if (!message.writedByAdmin)
@ -150,7 +150,7 @@ class _ReplyRadarOverview extends StatelessWidget {
children: [
DidvanText(
message.radar!.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
maxLines: 1,
overflow: TextOverflow.ellipsis,
color: Theme.of(context).colorScheme.focusedBorder,
@ -158,18 +158,15 @@ class _ReplyRadarOverview extends StatelessWidget {
Row(
children: [
DidvanText(
'رادار ' + message.radar!.categories.first.label,
style: Theme.of(context).textTheme.overline,
'رادار ${message.radar!.categories.first.label}',
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.focusedBorder,
),
const Spacer(),
DidvanText(
DateTimeUtils.momentGenerator(message.radar!.createdAt) +
' | خواندن در ' +
message.radar!.timeToRead.toString() +
' دقیقه',
'${DateTimeUtils.momentGenerator(message.radar!.createdAt)} | خواندن در ${message.radar!.timeToRead} دقیقه',
color: Theme.of(context).colorScheme.focusedBorder,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
),
// DidvanText('text'),
],

View File

@ -144,11 +144,11 @@ class _TypingState extends State<_Typing> {
key: _formKey,
child: TextFormField(
textInputAction: TextInputAction.send,
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'بنویسید یا پیام صوتی بگذارید...',
hintStyle: Theme.of(context).textTheme.caption!.copyWith(
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Theme.of(context).colorScheme.disabledText),
),
onChanged: (value) {
@ -181,7 +181,7 @@ class _Recording extends StatelessWidget {
Expanded(
child: DidvanText(
'در حال ضبط صدا ...',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
),
DidvanIconButton(

View File

@ -18,7 +18,7 @@ class Hashtag extends StatefulWidget {
const Hashtag({Key? key, required this.pageData}) : super(key: key);
@override
_HashtagState createState() => _HashtagState();
State<Hashtag> createState() => _HashtagState();
}
class _HashtagState extends State<Hashtag> {
@ -35,7 +35,7 @@ class _HashtagState extends State<Hashtag> {
@override
Widget build(BuildContext context) {
return DidvanScaffold(
appBarData: AppBarData(title: '#' + _tag.label, hasBack: true),
appBarData: AppBarData(title: '#${_tag.label}', hasBack: true),
slivers: [
Consumer<HashtagState>(
builder: (context, state, child) => SliverStateHandler<HashtagState>(

View File

@ -117,7 +117,7 @@ class _NewsState extends State<News> {
children: [
ItemTitle(
title: 'تاریخ خبر',
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
icon: DidvanIcons.calendar_range_regular,
),
const SizedBox(height: 8),

View File

@ -104,7 +104,7 @@ class _RadarState extends State<Radar> {
duration: DesignConfig.lowAnimationDuration,
child: DidvanText(
'آخرین رصد',
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).textTheme.titleMedium,
color: Theme.of(context).colorScheme.title,
),
),
@ -260,7 +260,7 @@ class _RadarState extends State<Radar> {
children: [
ItemTitle(
title: 'تاریخ رادار',
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
icon: DidvanIcons.calendar_range_regular,
),
const SizedBox(height: 8),
@ -287,7 +287,7 @@ class _RadarState extends State<Radar> {
ItemTitle(
title: 'دسته بندی',
icon: DidvanIcons.radar_regular,
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
),
const SizedBox(height: 12),
Wrap(

View File

@ -46,6 +46,33 @@ class _BookmarksState extends State<Bookmarks> {
title: 'نشان شده‌ها',
hasBack: true,
),
slivers: [
SliverStateHandler<BookmarksState>(
state: state,
centerEmptyState: state.searching,
builder: (context, state, index) {
index++;
if (index % 15 == 0 && state.lastPage != state.page) {
state.getBookmarks(page: state.page + 1);
}
index--;
return MultitypeOverview(
item: state.bookmarks[index],
onMarkChanged: state.onMarkChanged,
hasUnmarkConfirmation: true,
);
},
placeholder: MultitypeOverview.placeholder,
itemPadding: const EdgeInsets.only(bottom: 8),
emptyState: state.searching
? EmptyResult(onNewSearch: _focuseNode.requestFocus)
: const EmptyList(),
enableEmptyState: state.bookmarks.isEmpty,
childCount:
state.bookmarks.length + (state.page != state.lastPage ? 1 : 0),
onRetry: () => state.getBookmarks(page: state.page),
),
],
children: [
SearchField(
title: 'نشان شده‌ها',
@ -99,33 +126,6 @@ class _BookmarksState extends State<Bookmarks> {
),
),
],
slivers: [
SliverStateHandler<BookmarksState>(
state: state,
centerEmptyState: state.searching,
builder: (context, state, index) {
index++;
if (index % 15 == 0 && state.lastPage != state.page) {
state.getBookmarks(page: state.page + 1);
}
index--;
return MultitypeOverview(
item: state.bookmarks[index],
onMarkChanged: state.onMarkChanged,
hasUnmarkConfirmation: true,
);
},
placeholder: MultitypeOverview.placeholder,
itemPadding: const EdgeInsets.only(bottom: 8),
emptyState: state.searching
? EmptyResult(onNewSearch: _focuseNode.requestFocus)
: const EmptyList(),
enableEmptyState: state.bookmarks.isEmpty,
childCount:
state.bookmarks.length + (state.page != state.lastPage ? 1 : 0),
onRetry: () => state.getBookmarks(page: state.page),
),
],
);
}

View File

@ -16,7 +16,7 @@ class FilteredBookmarks extends StatefulWidget {
const FilteredBookmarks({Key? key, this.onDeleted}) : super(key: key);
@override
_FilteredBookmarksState createState() => _FilteredBookmarksState();
State<FilteredBookmarks> createState() => _FilteredBookmarksState();
}
class _FilteredBookmarksState extends State<FilteredBookmarks> {

View File

@ -20,7 +20,7 @@ class FilteredBookmarksState extends CoreProvier {
} else if (type == 'news') {
typeString = type;
} else {
typeString = type + 's';
typeString = '${type}s';
}
final service = RequestService(
RequestHelper.bookmarks(

View File

@ -19,9 +19,9 @@ class DirectListState extends CoreProvier {
await service.httpGet();
if (service.isSuccess) {
_unreadCount = service.result['unread'] ?? 0;
final List _chatRooms = service.result['chatRooms'] ?? [];
for (var i = 0; i < _chatRooms.length; i++) {
chatRooms.add(ChatRoom.fromJson(_chatRooms[i]));
final List chatRooms = service.result['chatRooms'] ?? [];
for (var i = 0; i < chatRooms.length; i++) {
chatRooms.add(ChatRoom.fromJson(chatRooms[i]));
}
appState = AppState.idle;
return;

View File

@ -43,7 +43,7 @@ class ChatRoomItem extends StatelessWidget {
Expanded(
child: DidvanText(
chatRoom.type,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
),
if (chatRoom.unread != 0)
@ -83,7 +83,7 @@ class ChatRoomItem extends StatelessWidget {
),
DidvanText(
DateTimeUtils.momentGenerator(chatRoom.updatedAt),
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.caption,
)
],

View File

@ -54,14 +54,11 @@ class _GeneralSettingsState extends State<GeneralSettings> {
title: 'زمان دریافت اعلان',
onTap: () => _pickTimeRange(context),
icon: DidvanIcons.notification_regular,
suffix: 'از' +
DateTimeUtils.normalizeTimeDuration(
suffix: 'از${DateTimeUtils.normalizeTimeDuration(
Duration(minutes: state.notificationTimeRange[0]),
) +
' تا ' +
DateTimeUtils.normalizeTimeDuration(
)} تا ${DateTimeUtils.normalizeTimeDuration(
Duration(minutes: state.notificationTimeRange[1]),
),
)}',
),
),
const ItemTitle(
@ -254,8 +251,8 @@ class _GeneralSettingsState extends State<GeneralSettings> {
okText: 'تایید',
cancelText: 'بازگشت',
accentColor: Theme.of(context).colorScheme.primary,
okStyle: Theme.of(context).textTheme.bodyText2!,
cancelStyle: Theme.of(context).textTheme.bodyText2!,
okStyle: Theme.of(context).textTheme.bodyMedium!,
cancelStyle: Theme.of(context).textTheme.bodyMedium!,
unselectedColor: Theme.of(context).colorScheme.text,
blurredBackground: true,
disableMinute: true,

View File

@ -87,7 +87,7 @@ class _ProfileState extends State<Profile> {
isVisible: !_usernameIsAvailible,
child: DidvanText(
'نام کاربری در دسترس نمی‌باشد',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.error,
),
),

View File

@ -1,4 +1,3 @@
import 'dart:io';
import 'package:didvan/config/theme_data.dart';
import 'package:didvan/constants/app_icons.dart';

View File

@ -131,7 +131,7 @@ class Settings extends StatelessWidget {
const SizedBox(height: 16),
DidvanText(
'نسخه نرم‌افزار: 2.2.5',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
],
),

View File

@ -74,7 +74,7 @@ class _StatisticState extends State<Statistic> {
duration: DesignConfig.lowAnimationDuration,
child: DidvanText(
'شاخص‌های منتخب',
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).textTheme.titleMedium,
color: Theme.of(context).colorScheme.title,
),
),

View File

@ -16,6 +16,7 @@ import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:provider/provider.dart';
// ignore: depend_on_referenced_packages
import 'package:intl/intl.dart' as intl;
class StatisticDetails extends StatefulWidget {
@ -95,7 +96,7 @@ class _StatisticDetailsState extends State<StatisticDetails> {
)}',
Theme.of(context)
.textTheme
.caption!
.bodySmall!
.copyWith(
color: Colors.white,
),
@ -284,8 +285,8 @@ class _StatisticDetailsState extends State<StatisticDetails> {
DidvanText(
title,
style: isBold
? Theme.of(context).textTheme.bodyText1
: Theme.of(context).textTheme.bodyText2,
? Theme.of(context).textTheme.bodyLarge
: Theme.of(context).textTheme.bodyMedium,
),
const Spacer(),
if (icon != null) Icon(icon, color: color),

View File

@ -6,6 +6,7 @@ import 'package:didvan/models/tag.dart';
import 'package:didvan/providers/core.dart';
import 'package:didvan/services/network/request.dart';
import 'package:didvan/services/network/request_helper.dart';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
class StatisticDetailsState extends CoreProvier {

View File

@ -1,4 +1,5 @@
import 'package:didvan/constants/assets.dart';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:didvan/models/category.dart';
import 'package:didvan/models/enums.dart';

View File

@ -46,7 +46,7 @@ class StatisticOverview extends StatelessWidget {
),
DidvanText(
statistic.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
const Spacer(),
if (_hasDiff)
@ -57,7 +57,7 @@ class StatisticOverview extends StatelessWidget {
if (_hasDiff) const SizedBox(width: 8),
DidvanText(
statistic.data.p,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
)
],
),
@ -71,7 +71,7 @@ class StatisticOverview extends StatelessWidget {
),
DidvanText(
statistic.data.l,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.hint,
),
const SizedBox(width: 8),
@ -82,7 +82,7 @@ class StatisticOverview extends StatelessWidget {
),
DidvanText(
statistic.data.h,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.hint,
),
const Spacer(),
@ -98,7 +98,7 @@ class StatisticOverview extends StatelessWidget {
if (_hasDiff)
DidvanText(
'${statistic.data.dp}%',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: _diffColor(context),
),
],

View File

@ -245,7 +245,7 @@ class _StudioState extends State<Studio> {
children: [
ItemTitle(
title: 'تاریخ رادار',
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
icon: DidvanIcons.calendar_range_regular,
),
const SizedBox(height: 8),

View File

@ -1,3 +1,5 @@
// ignore_for_file: use_build_context_synchronously
import 'package:better_player/better_player.dart';
import 'package:didvan/models/view/app_bar_data.dart';
import 'package:didvan/services/media/media.dart';

View File

@ -115,7 +115,7 @@ class _TabItem extends StatelessWidget {
DidvanText(
title,
color: _color(context),
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
)
],
),

View File

@ -243,7 +243,7 @@ class _StudioPreview extends StatelessWidget {
const SizedBox(height: 8),
DidvanText(
_previewTitle,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
@ -252,7 +252,7 @@ class _StudioPreview extends StatelessWidget {
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
],

View File

@ -93,7 +93,7 @@ class _StudioSliderState extends State<StudioSlider> {
child: DidvanText(
state.sliders[i].title,
color: Theme.of(context).colorScheme.title,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
),
),

View File

@ -97,7 +97,7 @@ class _StudioTypeButton extends StatelessWidget {
),
DidvanText(
title,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: _color(context),
)
],

View File

@ -54,7 +54,7 @@ class AudioPlayerWidget extends StatelessWidget {
const SizedBox(height: 16),
DidvanText(
podcast.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(height: 16),
Padding(
@ -89,7 +89,7 @@ class AudioPlayerWidget extends StatelessWidget {
? 'پایان پادکست'
: '\'${state.timerValue}',
isEnglishFont: true,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.title,
),
],
@ -223,7 +223,7 @@ class AudioPlayerWidget extends StatelessWidget {
const SizedBox(height: 24),
DidvanText(
'$timerValue دقیقه',
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
),
const SizedBox(height: 12),
const Icon(DidvanIcons.caret_down_solid),

View File

@ -78,7 +78,7 @@ class CategoryItem extends StatelessWidget {
),
DidvanText(
category.label,
style: Theme.of(context).textTheme.subtitle2,
style: Theme.of(context).textTheme.titleSmall,
color: Theme.of(context).colorScheme.title,
),
],

View File

@ -31,7 +31,7 @@ class DurationWidget extends StatelessWidget {
Duration(seconds: duration),
),
isEnglishFont: true,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.focusedBorder,
),
const SizedBox(width: 4),

View File

@ -55,7 +55,7 @@ class MenuOption extends StatelessWidget {
suffix!,
style: Theme.of(context)
.textTheme
.subtitle2!
.titleSmall!
.copyWith(fontWeight: FontWeight.w400),
color: Theme.of(context).colorScheme.primary,
),

View File

@ -113,7 +113,7 @@ class MultitypeOverview extends StatelessWidget {
children: [
DidvanText(
item.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
@ -126,7 +126,7 @@ class MultitypeOverview extends StatelessWidget {
const SizedBox(width: 4),
DidvanText(
DateTime.parse(item.createdAt).toPersianDateStr(),
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
),
const Spacer(),
if ((item.timeToRead ?? item.duration) != null) ...[
@ -141,7 +141,7 @@ class MultitypeOverview extends StatelessWidget {
: DateTimeUtils.normalizeTimeDuration(
Duration(seconds: item.duration!),
),
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
),
]
],

View File

@ -51,7 +51,7 @@ class NewsOverview extends StatelessWidget {
height: 64,
child: DidvanText(
news.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
),
),
@ -70,11 +70,11 @@ class NewsOverview extends StatelessWidget {
children: [
DidvanText(
news.reference!,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
DidvanText(
' - ${DateTimeUtils.momentGenerator(news.createdAt)}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
],
),

View File

@ -56,12 +56,12 @@ class PodcastOverview extends StatelessWidget {
children: [
DidvanText(
podcast.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(height: 4),
DidvanText(
DateTimeUtils.momentGenerator(podcast.createdAt),
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
],

View File

@ -70,7 +70,7 @@ class RadarOverview extends StatelessWidget {
),
child: DidvanText(
'برای مدیران',
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.white,
),
),
@ -82,13 +82,13 @@ class RadarOverview extends StatelessWidget {
children: [
DidvanText(
radar.categories!.first.label,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
const Spacer(),
DidvanText(
'${DateTimeUtils.momentGenerator(radar.createdAt)} | خواندن در ${radar.timeToRead} دقیقه',
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
],

View File

@ -71,7 +71,7 @@ class VideoOverview extends StatelessWidget {
children: [
DidvanText(
video.title,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(height: 4),
Row(
@ -83,7 +83,7 @@ class VideoOverview extends StatelessWidget {
const SizedBox(width: 4),
DidvanText(
DateTimeUtils.momentGenerator(video.createdAt),
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
],

View File

@ -45,7 +45,7 @@ class _SearchFieldState extends State<SearchField> {
),
child: TextFormField(
focusNode: widget.focusNode,
style: Theme.of(context).textTheme.bodyText2,
style: Theme.of(context).textTheme.bodyMedium,
textAlignVertical: TextAlignVertical.center,
onChanged: widget.onChanged,
keyboardType: TextInputType.text,

View File

@ -50,7 +50,7 @@ class TagItem extends StatelessWidget {
DidvanText(
tag.label,
color: Theme.of(context).colorScheme.focusedBorder,
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).textTheme.bodyLarge,
),
],
),

View File

@ -99,6 +99,9 @@ class _SplashState extends State<Splash> {
});
}
final settingsData = await AppInitializer.initilizeSettings();
if (!mounted) {
return;
}
final themeProvider = context.read<ThemeProvider>();
themeProvider.themeMode = settingsData.themeMode;
themeProvider.fontFamily = settingsData.fontFamily;
@ -109,18 +112,24 @@ class _SplashState extends State<Splash> {
_isGettingThemeData = false;
}),
);
if (!mounted) {
return;
}
await AppInitializer.setupServices(context);
if (!mounted) {
return;
}
final userProvider = context.read<UserProvider>();
final String? token = await userProvider.setAndGetToken();
if (token != null) {
log(token);
if (!kIsWeb) {
if (!kIsWeb && mounted) {
context.read<MediaProvider>().getDownloadsList();
}
RequestService.token = token;
final result = await userProvider.getUserInfo();
await userProvider.getUnreadMessageCount();
if (!result) {
if (!result && mounted) {
StorageService.delete(key: 'token');
Navigator.of(context).pushNamedAndRemoveUntil(
Routes.splash,
@ -130,10 +139,12 @@ class _SplashState extends State<Splash> {
}
await ServerDataProvider.getData();
}
Navigator.of(context).pushReplacementNamed(
token == null ? Routes.authenticaion : Routes.home,
arguments: token == null ? false : null,
);
if (mounted) {
Navigator.of(context).pushReplacementNamed(
token == null ? Routes.authenticaion : Routes.home,
arguments: token == null ? false : null,
);
}
} catch (e) {
setState(() {
_errorOccured = true;

View File

@ -51,7 +51,7 @@ class DidvanAppBar extends StatelessWidget {
if (appBarData.title != null)
DidvanText(
appBarData.title!,
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
color: Theme.of(context).colorScheme.title,
overflow: TextOverflow.ellipsis,
),
@ -60,7 +60,7 @@ class DidvanAppBar extends StatelessWidget {
appBarData.subtitle!,
maxLines: 1,
overflow: TextOverflow.clip,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.caption,
),
],

View File

@ -26,7 +26,7 @@ class DidvanBadge extends StatelessWidget {
text,
isEnglishFont: true,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.overline,
style: Theme.of(context).textTheme.labelSmall,
color: Theme.of(context).colorScheme.white,
),
),

View File

@ -440,7 +440,7 @@ class _NavBarItem extends StatelessWidget {
),
DidvanText(
title,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.title,
),
const Spacer(),

View File

@ -26,7 +26,7 @@ class DidvanChip extends StatelessWidget {
),
child: DidvanText(
label,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.white,
),
),

View File

@ -101,7 +101,7 @@ class _DidvanPageViewState extends State<DidvanPageView> {
const EdgeInsets.symmetric(horizontal: 16),
child: DidvanText(
item.title,
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).textTheme.titleMedium,
),
),
const SizedBox(height: 8),
@ -120,7 +120,7 @@ class _DidvanPageViewState extends State<DidvanPageView> {
color: Theme.of(context).colorScheme.hint,
),
borderRadius: DesignConfig.lowBorderRadius,
color: Theme.of(context).backgroundColor,
color: Theme.of(context).colorScheme.background,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -287,7 +287,7 @@ class _DidvanPageViewState extends State<DidvanPageView> {
const SizedBox(width: 8),
DidvanText(
element!.text,
style: Theme.of(context).textTheme.subtitle2,
style: Theme.of(context).textTheme.titleSmall,
),
],
),
@ -361,7 +361,7 @@ class _DidvanPageViewState extends State<DidvanPageView> {
child: DidvanText(
content.caption,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
),
],
@ -377,17 +377,17 @@ class _DidvanPageViewState extends State<DidvanPageView> {
children: [
DidvanText(
'رادار ',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
for (var i = 0; i < item.categories.length; i++)
DidvanText(
item.categories[i].label +
'${i != item.categories.length - 1 ? '،' : ''} ',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
DidvanText(
' - ${DateTimeUtils.momentGenerator(item.createdAt)}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
],
);
@ -396,11 +396,11 @@ class _DidvanPageViewState extends State<DidvanPageView> {
children: [
DidvanText(
item.reference,
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
DidvanText(
' - ${DateTimeUtils.momentGenerator(item.createdAt)}',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
],
);

View File

@ -51,7 +51,7 @@ class DidvanRadialButton extends StatelessWidget {
const SizedBox(width: 8),
DidvanText(
title,
style: Theme.of(context).textTheme.bodyText2!.copyWith(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontFamily: fontFamily,
),
fontSize: fontSize,

View File

@ -29,7 +29,7 @@ class DidvanText extends StatelessWidget {
Widget build(BuildContext context) {
return Text(
text,
style: ((style ?? Theme.of(context).textTheme.bodyText2)!.copyWith(
style: ((style ?? Theme.of(context).textTheme.bodyMedium)!.copyWith(
color: color,
fontWeight: fontWeight,
fontSize: fontSize,

View File

@ -98,7 +98,7 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
obscuringCharacter: '*',
style: Theme.of(context)
.textTheme
.bodyText2!
.bodyMedium!
.copyWith(fontFamily: DesignConfig.fontFamily.padRight(3)),
decoration: InputDecoration(
suffixIcon: _suffixBuilder(),
@ -108,7 +108,7 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
errorStyle: const TextStyle(height: 0.01),
hintStyle: Theme.of(context)
.textTheme
.bodyText2!
.bodyMedium!
.copyWith(color: Theme.of(context).colorScheme.hint),
),
),
@ -126,7 +126,7 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
),
DidvanText(
_error ?? '',
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
color: Theme.of(context).colorScheme.error,
),
],

View File

@ -28,7 +28,7 @@ class ItemTitle extends StatelessWidget {
if (icon != null) const SizedBox(width: 4),
DidvanText(
title,
style: style ?? Theme.of(context).textTheme.subtitle1,
style: style ?? Theme.of(context).textTheme.titleMedium,
color: color ?? Theme.of(context).colorScheme.title,
)
],

View File

@ -4,6 +4,7 @@ import 'package:didvan/services/network/request.dart';
import 'package:didvan/services/network/request_helper.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.dart';
import 'package:flutter/material.dart';
// ignore: depend_on_referenced_packages
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
class SkeletonImage extends StatelessWidget {

View File

@ -31,7 +31,7 @@ class EmptyState extends StatelessWidget {
const SizedBox(height: 16),
DidvanText(
title,
style: Theme.of(context).textTheme.headline3,
style: Theme.of(context).textTheme.displaySmall,
color: titleColor ?? Theme.of(context).colorScheme.caption,
),
if (subtitle != null) const SizedBox(height: 8),