fixed news and radar web route
This commit is contained in:
parent
424226fe6f
commit
b2961ca7d8
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Chrome against localhost",
|
||||||
|
"url": "http://localhost:8080",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -38,6 +38,8 @@ import 'package:flutter_downloader/flutter_downloader.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
import 'package:app_links/app_links.dart';
|
import 'package:app_links/app_links.dart';
|
||||||
|
|
||||||
|
import 'services/network/request.dart';
|
||||||
|
|
||||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||||
Uri? initialURI;
|
Uri? initialURI;
|
||||||
|
|
||||||
|
|
@ -126,6 +128,16 @@ class _DidvanState extends State<Didvan> with WidgetsBindingObserver {
|
||||||
void _navigateTo(Uri uri) {
|
void _navigateTo(Uri uri) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
String path = uri.path;
|
String path = uri.path;
|
||||||
|
final Map<String, String> params = uri.queryParameters;
|
||||||
|
|
||||||
|
final String? token = params['token'];
|
||||||
|
|
||||||
|
if (token != null) {
|
||||||
|
//todo: this didnt work
|
||||||
|
print("DEBUG: received token in url, token: $token, path: $path");
|
||||||
|
RequestService.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
if (path.startsWith('/news/')) {
|
if (path.startsWith('/news/')) {
|
||||||
final id = path.split('/news/').last;
|
final id = path.split('/news/').last;
|
||||||
if (id.isNotEmpty) {
|
if (id.isNotEmpty) {
|
||||||
|
|
@ -134,13 +146,7 @@ class _DidvanState extends State<Didvan> with WidgetsBindingObserver {
|
||||||
arguments: {'id': int.parse(id), 'args': const NewsRequestArgs(page: 0)},
|
arguments: {'id': int.parse(id), 'args': const NewsRequestArgs(page: 0)},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (path.startsWith('/radar/')) {
|
||||||
navigatorKey.currentState?.pushNamed(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
String path = uri.path;
|
|
||||||
if (path.startsWith('/radar/')) {
|
|
||||||
final id = path.split('/radar/').last;
|
final id = path.split('/radar/').last;
|
||||||
if (id.isNotEmpty) {
|
if (id.isNotEmpty) {
|
||||||
navigatorKey.currentState?.pushNamed(
|
navigatorKey.currentState?.pushNamed(
|
||||||
|
|
@ -148,8 +154,6 @@ class _DidvanState extends State<Didvan> with WidgetsBindingObserver {
|
||||||
arguments: {'id': int.parse(id), 'args': const RadarRequestArgs(page: 0)},
|
arguments: {'id': int.parse(id), 'args': const RadarRequestArgs(page: 0)},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
navigatorKey.currentState?.pushNamed(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ class HomeState extends CoreProvier {
|
||||||
);
|
);
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
|
print("DEBUG : Homestate is succes");
|
||||||
lastPage = service.result['lastPage'];
|
lastPage = service.result['lastPage'];
|
||||||
results.addAll(
|
results.addAll(
|
||||||
List<OverviewData>.from(
|
List<OverviewData>.from(
|
||||||
|
|
@ -94,12 +95,14 @@ class HomeState extends CoreProvier {
|
||||||
appState = AppState.idle;
|
appState = AppState.idle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print("DEBUG : Homestate is NOT succes");
|
||||||
appState = AppState.failed;
|
appState = AppState.failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> searchAll({required int page}) async {
|
Future<void> searchAll({required int page}) async {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
if (page == 1) {
|
if (page == 1) {
|
||||||
|
print("DEBUG : serach is busy");
|
||||||
results.clear();
|
results.clear();
|
||||||
appState = AppState.busy;
|
appState = AppState.busy;
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +118,7 @@ class HomeState extends CoreProvier {
|
||||||
);
|
);
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
|
print("DEBUG : HTTPget Home is succes");
|
||||||
lastPage = service.result['lastPage'];
|
lastPage = service.result['lastPage'];
|
||||||
unreadCount = service.result['unread'] ?? unreadCount;
|
unreadCount = service.result['unread'] ?? unreadCount;
|
||||||
results.addAll(
|
results.addAll(
|
||||||
|
|
@ -128,6 +132,7 @@ class HomeState extends CoreProvier {
|
||||||
appState = AppState.idle;
|
appState = AppState.idle;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print("DEBUG : Homestate is faild");
|
||||||
appState = AppState.failed;
|
appState = AppState.failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,30 +33,44 @@ class MainPage extends StatefulWidget {
|
||||||
class _MainPageState extends State<MainPage> {
|
class _MainPageState extends State<MainPage> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
context.read<MainPageState>().init();
|
super.initState();
|
||||||
|
print("DEBUG: _MainPageState initstate called");
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
print("DEBUG: addPostFrameCallback called");
|
||||||
|
context.read<MainPageState>().init();
|
||||||
|
});
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
print("DEBUG: _MainPageState build called");
|
||||||
return StateHandler<MainPageState>(
|
return StateHandler<MainPageState>(
|
||||||
onRetry: context.read<MainPageState>().init,
|
onRetry: () => {
|
||||||
|
print("DEBUG: _MainPageState onRetry called"),
|
||||||
|
context.read<MainPageState>().init
|
||||||
|
},
|
||||||
state: context.watch<MainPageState>(),
|
state: context.watch<MainPageState>(),
|
||||||
builder: (context, state) => ListView(
|
builder: (context, state) {
|
||||||
|
print("DEBUG: FutureBuilder waiting");
|
||||||
|
print("DEBUG: FutureBuilder state.stories.isNotEmpty: ${state.stories.isNotEmpty}");
|
||||||
|
print("DEBUG: FutureBuilder state.content: ${state.content!.lists}");
|
||||||
|
print("DEBUG: FutureBuilder state.content != null: ${state.content != null}");
|
||||||
|
print("DEBUG: FutureBuilder state.content!.lists.isNotEmpty: ${state.content!.lists.isNotEmpty}");
|
||||||
|
return ListView(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
children: [
|
children: [
|
||||||
if (state.stories.isNotEmpty) StorySection(stories: state.stories),
|
if (state.stories.isNotEmpty) StorySection(stories: state.stories),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
const MainPageMainContent(),
|
const MainPageMainContent(),
|
||||||
|
|
||||||
Builder(builder: (context) {
|
Builder(builder: (context) {
|
||||||
final List<Widget> pageContent = [];
|
final List<Widget> pageContent = [];
|
||||||
if (state.content != null && state.content!.lists.isNotEmpty) {
|
if (state.content != null && state.content!.lists.isNotEmpty) {
|
||||||
final lists = state.content!.lists;
|
final lists = state.content!.lists;
|
||||||
|
|
||||||
for (int i = 0; i < lists.length; i++) {
|
for (int i = 0; i < lists.length; i++) {
|
||||||
final currentList = lists[i];
|
final currentList = lists[i];
|
||||||
|
|
||||||
if (i == 4) {
|
if (i == 4) {
|
||||||
pageContent.add(
|
pageContent.add(
|
||||||
Padding(
|
Padding(
|
||||||
|
|
@ -107,21 +121,23 @@ class _MainPageState extends State<MainPage> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pageContent.add(_MainPageSection(
|
pageContent.add(_MainPageSection(
|
||||||
list: currentList,
|
list: currentList,
|
||||||
isLast: i == lists.length - 1,
|
isLast: i == lists.length - 1,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (currentList.type == 'startup') {
|
if (currentList.type == 'startup') {
|
||||||
pageContent.add(_SwotSection(swotItems: state.swotItems));
|
pageContent.add(_SwotSection(swotItems: state.swotItems));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print("DEBUG: FutureBuilder error");
|
||||||
return Column(children: pageContent);
|
return Column(children: pageContent);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +151,7 @@ class _SwotSection extends StatelessWidget {
|
||||||
if (swotItems.isEmpty) {
|
if (swotItems.isEmpty) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(0.0),
|
padding: const EdgeInsets.all(0.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
@ -288,8 +304,7 @@ class _MainPageSection extends StatelessWidget {
|
||||||
if (list.contents.isEmpty) {
|
if (list.contents.isEmpty) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This condition handles the "Soha" module, which should not display the Opportunity/Threat module.
|
|
||||||
if (list.type == 'delphi') {
|
if (list.type == 'delphi') {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -298,8 +313,7 @@ class _MainPageSection extends StatelessWidget {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For all other modules, display as before.
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
_buildSectionHeader(context, icon),
|
_buildSectionHeader(context, icon),
|
||||||
|
|
@ -386,4 +400,4 @@ class _MainPageSection extends StatelessWidget {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,19 @@ class MainPageState extends CoreProvier {
|
||||||
List<SwotItem> swotItems = [];
|
List<SwotItem> swotItems = [];
|
||||||
|
|
||||||
Future<void> _getMainPageContent() async {
|
Future<void> _getMainPageContent() async {
|
||||||
|
print("DEBUG: _getMainPageContent started");
|
||||||
final service = RequestService(RequestHelper.mainPageContent);
|
final service = RequestService(RequestHelper.mainPageContent);
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
|
print("DEBUG: _getMainPageContent success");
|
||||||
content = MainPageContent.fromJson(service.result);
|
content = MainPageContent.fromJson(service.result);
|
||||||
|
print("DEBUG: _getMainPageContent service.result: ${service.result}");
|
||||||
unread = service.result['unread'];
|
unread = service.result['unread'];
|
||||||
|
print("DEBUG: __getMainPageContent unread: $unread, content: $content");
|
||||||
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
|
print("DEBUG: _getMainPageContent failed state");
|
||||||
|
notifyListeners();
|
||||||
throw Exception('Failed to load main page content');
|
throw Exception('Failed to load main page content');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,14 +50,14 @@ class MainPageState extends CoreProvier {
|
||||||
try {
|
try {
|
||||||
swotItems = await SwotService.fetchSwotItems();
|
swotItems = await SwotService.fetchSwotItems();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _fetchStories() async {
|
Future<void> _fetchStories() async {
|
||||||
try {
|
try {
|
||||||
stories = await StoryService.getStories();
|
stories = await StoryService.getStories();
|
||||||
print("Fetched ${stories.length} stories.");
|
// print("Fetched ${stories.length} stories.");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
stories = [];
|
stories = [];
|
||||||
debugPrint("Could not fetch stories: $e");
|
debugPrint("Could not fetch stories: $e");
|
||||||
|
|
@ -58,6 +65,7 @@ class MainPageState extends CoreProvier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
|
print("DEBUG: MainPageState init called");
|
||||||
Future.delayed(Duration.zero, () async {
|
Future.delayed(Duration.zero, () async {
|
||||||
appState = AppState.busy;
|
appState = AppState.busy;
|
||||||
try {
|
try {
|
||||||
|
|
@ -71,6 +79,7 @@ class MainPageState extends CoreProvier {
|
||||||
appState = AppState.failed;
|
appState = AppState.failed;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_getMainPageContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void markChangeHandler(String type, int id, bool value) {
|
void markChangeHandler(String type, int id, bool value) {
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ class _SplashState extends State<Splash> {
|
||||||
await ServerDataProvider.getData();
|
await ServerDataProvider.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
print("token route is $token");
|
print("token route is $token, initalURI.path: ${initialURI?.path}, intitlPath: ${initialURI?.path}");
|
||||||
String extractedPath = initialURI?.path.toString() == '/' ? Routes.home : initialURI?.path.toString() ?? Routes.home;
|
String extractedPath = initialURI?.path.toString() == '/' ? Routes.home : initialURI?.path.toString() ?? Routes.home;
|
||||||
final String destinationRoute = token == null ? Routes.authenticaion : extractedPath;
|
final String destinationRoute = token == null ? Routes.authenticaion : extractedPath;
|
||||||
dynamic routeArguments = token == null ? {'isResetPassword': false} : {'showDialogs': true};
|
dynamic routeArguments = token == null ? {'isResetPassword': false} : {'showDialogs': true};
|
||||||
|
|
@ -143,7 +143,7 @@ class _SplashState extends State<Splash> {
|
||||||
|
|
||||||
if (destinationRoute == Routes.home) {
|
if (destinationRoute == Routes.home) {
|
||||||
print("destination route was home and init uri is $initialURI");
|
print("destination route was home and init uri is $initialURI");
|
||||||
(routeArguments as Map)['deepLinkUri'] = initialURI;
|
// (routeArguments as Map)['deepLinkUri'] = initialURI;
|
||||||
initialURI = null;
|
initialURI = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ class _SplashState extends State<Splash> {
|
||||||
print("destination route: $destinationRoute, route args: $routeArguments");
|
print("destination route: $destinationRoute, route args: $routeArguments");
|
||||||
await navigatorKey.currentState!.pushReplacementNamed(
|
await navigatorKey.currentState!.pushReplacementNamed(
|
||||||
destinationRoute,
|
destinationRoute,
|
||||||
arguments: routeArguments,
|
arguments: token == null ? false : null,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue