83 lines
2.2 KiB
Dart
83 lines
2.2 KiB
Dart
import 'package:didvan/constants/assets.dart';
|
|
import 'package:didvan/models/category.dart';
|
|
import 'package:didvan/models/enums.dart';
|
|
import 'package:didvan/models/home_page_content/home_page_content.dart';
|
|
import 'package:didvan/providers/core.dart';
|
|
import 'package:didvan/services/network/request.dart';
|
|
import 'package:didvan/services/network/request_helper.dart';
|
|
|
|
class MainPageState extends CoreProvier {
|
|
late MainPageContent content;
|
|
List<CategoryData> categories = [];
|
|
Future<void> _getMainPageContent() async {
|
|
final service = RequestService(RequestHelper.mainPageContent);
|
|
await service.httpGet();
|
|
if (service.isSuccess) {
|
|
content = MainPageContent.fromJson(service.result);
|
|
appState = AppState.idle;
|
|
return;
|
|
}
|
|
appState = AppState.failed;
|
|
}
|
|
|
|
void init() {
|
|
if (categories.isEmpty) {
|
|
categories = [
|
|
CategoryData(
|
|
id: 1,
|
|
label: 'اقتصادی',
|
|
asset: Assets.economicCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 2,
|
|
label: 'سیاسی',
|
|
asset: Assets.politicalCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 3,
|
|
label: 'فناوری',
|
|
asset: Assets.techCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 4,
|
|
label: 'کسب و کار',
|
|
asset: Assets.businessCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 5,
|
|
label: 'زیست محیطی',
|
|
asset: Assets.enviromentalCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 6,
|
|
label: 'اجتماعی',
|
|
asset: Assets.socialCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 1,
|
|
label: 'اقتصادی',
|
|
asset: Assets.economicCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 2,
|
|
label: 'سیاسی',
|
|
asset: Assets.politicalCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 3,
|
|
label: 'فناوری',
|
|
asset: Assets.techCategoryIcon,
|
|
),
|
|
CategoryData(
|
|
id: 4,
|
|
label: 'کسب و کار',
|
|
asset: Assets.businessCategoryIcon,
|
|
),
|
|
];
|
|
}
|
|
Future.delayed(Duration.zero, () {
|
|
_getMainPageContent();
|
|
});
|
|
}
|
|
}
|