Dev
This commit is contained in:
parent
b47badf3cf
commit
93bac3a349
|
|
@ -37,6 +37,14 @@ class UserProvider extends CoreProvier {
|
||||||
}
|
}
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
user = User.fromJson(service.result['user']);
|
user = User.fromJson(service.result['user']);
|
||||||
|
await StorageService.setValue(
|
||||||
|
key: 'notificationTimeRangeStart',
|
||||||
|
value: service.result['user']['start'],
|
||||||
|
);
|
||||||
|
await StorageService.setValue(
|
||||||
|
key: 'notificationTimeRangeEnd',
|
||||||
|
value: service.result['user']['end'],
|
||||||
|
);
|
||||||
AppInitializer.initializeFirebase().then((_) => _registerFirebaseToken());
|
AppInitializer.initializeFirebase().then((_) => _registerFirebaseToken());
|
||||||
_registerFirebaseToken();
|
_registerFirebaseToken();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import 'package:didvan/models/requests/radar.dart';
|
||||||
import 'package:didvan/models/requests/studio.dart';
|
import 'package:didvan/models/requests/studio.dart';
|
||||||
|
|
||||||
class RequestHelper {
|
class RequestHelper {
|
||||||
static const String baseUrl = 'https://api.didvan.app';
|
static const String baseUrl = 'https://test.api.didvan.app';
|
||||||
static const String _baseUserUrl = baseUrl + '/user';
|
static const String _baseUserUrl = baseUrl + '/user';
|
||||||
static const String _baseRadarUrl = baseUrl + '/radar';
|
static const String _baseRadarUrl = baseUrl + '/radar';
|
||||||
static const String _baseNewsUrl = baseUrl + '/news';
|
static const String _baseNewsUrl = baseUrl + '/news';
|
||||||
|
|
|
||||||
|
|
@ -38,48 +38,42 @@ class _NewsDetailsState extends State<NewsDetails> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Consumer<NewsDetailsState>(
|
body: Consumer<NewsDetailsState>(
|
||||||
builder: (context, state, child) => WillPopScope(
|
builder: (context, state, child) => StateHandler<NewsDetailsState>(
|
||||||
onWillPop: () async {
|
onRetry: () => state.getNewsDetails(state.currentNews.id),
|
||||||
state.handleTracking(sendRequest: true);
|
state: state,
|
||||||
return true;
|
builder: (context, state) => Stack(
|
||||||
},
|
children: [
|
||||||
child: StateHandler<NewsDetailsState>(
|
IgnorePointer(
|
||||||
onRetry: () => state.getNewsDetails(state.currentNews.id),
|
ignoring: state.isFetchingNewItem,
|
||||||
state: state,
|
child: DidvanPageView(
|
||||||
builder: (context, state) => Stack(
|
isRadar: false,
|
||||||
children: [
|
initialIndex: state.initialIndex,
|
||||||
IgnorePointer(
|
onPageChanged: _onPageChnaged,
|
||||||
ignoring: state.isFetchingNewItem,
|
scrollController: _scrollController,
|
||||||
child: DidvanPageView(
|
items: state.news,
|
||||||
isRadar: false,
|
currentIndex: state.currentIndex,
|
||||||
initialIndex: state.initialIndex,
|
onMarkChanged: (id, value) =>
|
||||||
onPageChanged: _onPageChnaged,
|
widget.pageData['onMarkChanged'](id, value),
|
||||||
scrollController: _scrollController,
|
|
||||||
items: state.news,
|
|
||||||
currentIndex: state.currentIndex,
|
|
||||||
onMarkChanged: (id, value) =>
|
|
||||||
widget.pageData['onMarkChanged'](id, value),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Positioned(
|
),
|
||||||
bottom: 0,
|
Positioned(
|
||||||
left: 0,
|
bottom: 0,
|
||||||
right: 0,
|
left: 0,
|
||||||
child: FloatingNavigationBar(
|
right: 0,
|
||||||
hasUnmarkConfirmation:
|
child: FloatingNavigationBar(
|
||||||
widget.pageData['hasUnmarkConfirmation'],
|
hasUnmarkConfirmation:
|
||||||
scrollController: _scrollController,
|
widget.pageData['hasUnmarkConfirmation'],
|
||||||
item: state.currentNews,
|
scrollController: _scrollController,
|
||||||
onCommentsChanged: state.onCommentsChanged,
|
item: state.currentNews,
|
||||||
onMarkChanged: (value) => widget.pageData['onMarkChanged'](
|
onCommentsChanged: state.onCommentsChanged,
|
||||||
state.currentNews.id,
|
onMarkChanged: (value) => widget.pageData['onMarkChanged'](
|
||||||
value,
|
state.currentNews.id,
|
||||||
),
|
value,
|
||||||
isRadar: false,
|
|
||||||
),
|
),
|
||||||
|
isRadar: false,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class NewsDetailsState extends CoreProvier {
|
||||||
}
|
}
|
||||||
final service = RequestService(RequestHelper.newsDetails(id, args));
|
final service = RequestService(RequestHelper.newsDetails(id, args));
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
handleTracking(sendRequest: isForward != null);
|
_handleTracking(sendRequest: isForward != null);
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
final result = service.result;
|
final result = service.result;
|
||||||
final newsItem = NewsDetailsData.fromJson(result['news']);
|
final newsItem = NewsDetailsData.fromJson(result['news']);
|
||||||
|
|
@ -88,7 +88,7 @@ class NewsDetailsState extends CoreProvier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleTracking({bool sendRequest = true}) async {
|
Future<void> _handleTracking({bool sendRequest = true}) async {
|
||||||
if (!sendRequest) {
|
if (!sendRequest) {
|
||||||
_trackingTimerCounter = 0;
|
_trackingTimerCounter = 0;
|
||||||
_trackingTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
_trackingTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
|
|
@ -103,6 +103,7 @@ class NewsDetailsState extends CoreProvier {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
service.put();
|
service.put();
|
||||||
|
_trackingTimerCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getRelatedContents() async {
|
Future<void> getRelatedContents() async {
|
||||||
|
|
@ -129,6 +130,7 @@ class NewsDetailsState extends CoreProvier {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_handleTracking(sendRequest: true);
|
||||||
_trackingTimer.cancel();
|
_trackingTimer.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,55 +38,49 @@ class _RadarDetailsState extends State<RadarDetails> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Consumer<RadarDetailsState>(
|
body: Consumer<RadarDetailsState>(
|
||||||
builder: (context, state, child) => WillPopScope(
|
builder: (context, state, child) => StateHandler<RadarDetailsState>(
|
||||||
onWillPop: () async {
|
onRetry: () => state.getRadarDetails(widget.pageData['id']),
|
||||||
state.handleTracking(sendRequest: true);
|
state: state,
|
||||||
return true;
|
builder: (context, state) => Stack(
|
||||||
},
|
children: [
|
||||||
child: StateHandler<RadarDetailsState>(
|
IgnorePointer(
|
||||||
onRetry: () => state.getRadarDetails(widget.pageData['id']),
|
ignoring: state.isFetchingNewItem,
|
||||||
state: state,
|
child: DidvanPageView(
|
||||||
builder: (context, state) => Stack(
|
isRadar: true,
|
||||||
children: [
|
initialIndex: state.initialIndex,
|
||||||
IgnorePointer(
|
onPageChanged: _onPageChanged,
|
||||||
ignoring: state.isFetchingNewItem,
|
scrollController: _scrollController,
|
||||||
child: DidvanPageView(
|
items: state.radars,
|
||||||
isRadar: true,
|
currentIndex: state.currentIndex,
|
||||||
initialIndex: state.initialIndex,
|
onMarkChanged: (id, value) =>
|
||||||
onPageChanged: _onPageChanged,
|
widget.pageData['onMarkChanged']?.call(id, value),
|
||||||
scrollController: _scrollController,
|
|
||||||
items: state.radars,
|
|
||||||
currentIndex: state.currentIndex,
|
|
||||||
onMarkChanged: (id, value) =>
|
|
||||||
widget.pageData['onMarkChanged']?.call(id, value),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Positioned(
|
),
|
||||||
bottom: 0,
|
Positioned(
|
||||||
left: 0,
|
bottom: 0,
|
||||||
right: 0,
|
left: 0,
|
||||||
child: FloatingNavigationBar(
|
right: 0,
|
||||||
hasUnmarkConfirmation:
|
child: FloatingNavigationBar(
|
||||||
widget.pageData['hasUnmarkConfirmation'],
|
hasUnmarkConfirmation:
|
||||||
isRadar: true,
|
widget.pageData['hasUnmarkConfirmation'],
|
||||||
scrollController: _scrollController,
|
isRadar: true,
|
||||||
onMarkChanged: (value) =>
|
scrollController: _scrollController,
|
||||||
widget.pageData['onMarkChanged']?.call(
|
onMarkChanged: (value) =>
|
||||||
|
widget.pageData['onMarkChanged']?.call(
|
||||||
|
state.currentRadar.id,
|
||||||
|
value,
|
||||||
|
),
|
||||||
|
item: state.currentRadar,
|
||||||
|
onCommentsChanged: (count) {
|
||||||
|
state.onCommentsChanged(count);
|
||||||
|
widget.pageData['onCommentsChanged']?.call(
|
||||||
state.currentRadar.id,
|
state.currentRadar.id,
|
||||||
value,
|
count,
|
||||||
),
|
);
|
||||||
item: state.currentRadar,
|
},
|
||||||
onCommentsChanged: (count) {
|
|
||||||
state.onCommentsChanged(count);
|
|
||||||
widget.pageData['onCommentsChanged']?.call(
|
|
||||||
state.currentRadar.id,
|
|
||||||
count,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class RadarDetailsState extends CoreProvier {
|
||||||
}
|
}
|
||||||
final service = RequestService(RequestHelper.radarDetails(id, args));
|
final service = RequestService(RequestHelper.radarDetails(id, args));
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
handleTracking(sendRequest: isForward != null);
|
_handleTracking(sendRequest: isForward != null);
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
final result = service.result;
|
final result = service.result;
|
||||||
final radar = RadarDetailsData.fromJson(result['radar']);
|
final radar = RadarDetailsData.fromJson(result['radar']);
|
||||||
|
|
@ -121,7 +121,7 @@ class RadarDetailsState extends CoreProvier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleTracking({bool sendRequest = true}) async {
|
Future<void> _handleTracking({bool sendRequest = true}) async {
|
||||||
if (!sendRequest) {
|
if (!sendRequest) {
|
||||||
_trackingTimerCounter = 0;
|
_trackingTimerCounter = 0;
|
||||||
_trackingTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
_trackingTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
|
|
@ -136,10 +136,12 @@ class RadarDetailsState extends CoreProvier {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
service.put();
|
service.put();
|
||||||
|
_trackingTimerCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_handleTracking(sendRequest: true);
|
||||||
_trackingTimer.cancel();
|
_trackingTimer.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,13 @@ class _GeneralSettingsState extends State<GeneralSettings> {
|
||||||
title: 'زمان دریافت اعلان',
|
title: 'زمان دریافت اعلان',
|
||||||
onTap: () => _pickTimeRange(context),
|
onTap: () => _pickTimeRange(context),
|
||||||
icon: DidvanIcons.notification_regular,
|
icon: DidvanIcons.notification_regular,
|
||||||
suffix: DateTimeUtils.normalizeTimeDuration(
|
suffix: 'از' +
|
||||||
Duration(minutes: state.notificationTimeRange[1]),
|
|
||||||
) +
|
|
||||||
' - ' +
|
|
||||||
DateTimeUtils.normalizeTimeDuration(
|
DateTimeUtils.normalizeTimeDuration(
|
||||||
Duration(minutes: state.notificationTimeRange[0]),
|
Duration(minutes: state.notificationTimeRange[0]),
|
||||||
|
) +
|
||||||
|
' تا ' +
|
||||||
|
DateTimeUtils.normalizeTimeDuration(
|
||||||
|
Duration(minutes: state.notificationTimeRange[1]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class _StudioState extends State<Studio> {
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: SearchField(
|
child: SearchField(
|
||||||
title: 'استودیو',
|
title: state.videosSelected ? 'ویدئو' : 'پادکست',
|
||||||
onChanged: _onChanged,
|
onChanged: _onChanged,
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ import 'package:carousel_slider/carousel_slider.dart';
|
||||||
import 'package:didvan/config/design_config.dart';
|
import 'package:didvan/config/design_config.dart';
|
||||||
import 'package:didvan/config/theme_data.dart';
|
import 'package:didvan/config/theme_data.dart';
|
||||||
import 'package:didvan/constants/app_icons.dart';
|
import 'package:didvan/constants/app_icons.dart';
|
||||||
|
import 'package:didvan/models/requests/news.dart';
|
||||||
|
import 'package:didvan/models/requests/radar.dart';
|
||||||
import 'package:didvan/routes/routes.dart';
|
import 'package:didvan/routes/routes.dart';
|
||||||
import 'package:didvan/utils/action_sheet.dart';
|
import 'package:didvan/utils/action_sheet.dart';
|
||||||
import 'package:didvan/utils/date_time.dart';
|
import 'package:didvan/utils/date_time.dart';
|
||||||
|
|
@ -195,24 +197,64 @@ class _DidvanPageViewState extends State<DidvanPageView> {
|
||||||
data: content.text,
|
data: content.text,
|
||||||
onAnchorTap: (href, context, map, element) {
|
onAnchorTap: (href, context, map, element) {
|
||||||
if (href!.contains('navigate-')) {
|
if (href!.contains('navigate-')) {
|
||||||
Navigator.of(ActionSheetUtils.context)
|
if (href.contains('statistic')) {
|
||||||
.pushNamed(Routes.statisticDetails, arguments: {
|
Navigator.of(ActionSheetUtils.context)
|
||||||
'onMarkChanged': (value) {},
|
.pushNamed(Routes.statisticDetails, arguments: {
|
||||||
'label': href.split('-')[1],
|
'onMarkChanged': (value) {},
|
||||||
'title': href.split('-').last,
|
'label': href.split('-')[2],
|
||||||
'marked': false,
|
'title': href.split('-').last,
|
||||||
});
|
'marked': false,
|
||||||
|
});
|
||||||
|
} else if (href.contains('radar')) {
|
||||||
|
Navigator.of(ActionSheetUtils.context).pushNamed(
|
||||||
|
Routes.radarDetails,
|
||||||
|
arguments: {
|
||||||
|
'onMarkChanged': (id, value) {},
|
||||||
|
'onCommentsChanged': (id, count) {},
|
||||||
|
'id': int.parse(href.split('-').last),
|
||||||
|
'args': const RadarRequestArgs(page: 0),
|
||||||
|
'hasUnmarkConfirmation': false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else if (href.contains('news')) {
|
||||||
|
Navigator.of(ActionSheetUtils.context).pushNamed(
|
||||||
|
Routes.newsDetails,
|
||||||
|
arguments: {
|
||||||
|
'onMarkChanged': (id, value) {},
|
||||||
|
'id': int.parse(href.split('-').last),
|
||||||
|
'args': const NewsRequestArgs(page: 0),
|
||||||
|
'hasUnmarkConfirmation': false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
} else if (href.contains('popup-')) {
|
} else if (href.contains('popup-')) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: ActionSheetUtils.context,
|
context: ActionSheetUtils.context,
|
||||||
builder: (context) => Dialog(
|
builder: (context) => Dialog(
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: DesignConfig.lowBorderRadius,
|
||||||
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: DidvanCard(
|
child: DidvanCard(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
DidvanIcons.info_circle_solid,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
DidvanText(
|
||||||
|
element!.text,
|
||||||
|
style: Theme.of(context).textTheme.subtitle2,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
DidvanText(href.split('-').last),
|
DidvanText(href.split('-').last),
|
||||||
const DidvanDivider(),
|
const SizedBox(height: 16),
|
||||||
const DidvanButton(
|
const DidvanButton(
|
||||||
title: 'بستن',
|
title: 'بستن',
|
||||||
onPressed: ActionSheetUtils.pop,
|
onPressed: ActionSheetUtils.pop,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue