dev/fix-news #2

Merged
Mr.Jebelli merged 8 commits from dev/fix-news into master 2025-07-16 11:59:01 +00:00
2 changed files with 35 additions and 19 deletions
Showing only changes of commit 9902666c0c - Show all commits

View File

@ -24,6 +24,7 @@ class CustomizeCategoryState extends CoreProvier {
Future<void> getFavourites() async { Future<void> getFavourites() async {
appState = AppState.busy; appState = AppState.busy;
update();
final service = RequestService( final service = RequestService(
RequestHelper.favourites(), RequestHelper.favourites(),
@ -31,13 +32,19 @@ class CustomizeCategoryState extends CoreProvier {
await service.httpGet(); await service.httpGet();
if (service.isSuccess) { if (service.isSuccess) {
faves.clear(); faves.clear();
final favourites = service.data('types'); final favouritesData = service.data('types');
for (var i = 0; i < favourites.length; i++) { if (favouritesData is List) {
faves.add(FavoritesResponse.fromJson(favourites[i])); for (var i = 0; i < favouritesData.length; i++) {
faves.add(FavoritesResponse.fromJson(favouritesData[i]));
}
} }
// اضافه کردن مستقیم بخش فرصت و تهدید
faves.add(FavoritesResponse(id: 999, name: 'فرصت و تهدید', selected: false));
selectedFavIds.clear(); selectedFavIds.clear();
for (var element in faves) { for (var element in faves) {
if (element.selected!) { if (element.selected == true) {
selectedFavIds.add(element.id!); selectedFavIds.add(element.id!);
} }
} }

View File

@ -78,29 +78,38 @@ class _FavoritesStepState extends State<FavoritesStep> {
asset: Assets.emptyChat, asset: Assets.emptyChat,
title: 'اولین نظر را بنویسید...', title: 'اولین نظر را بنویسید...',
), ),
builder: (context, state, index) => Center( builder: (context, state, index) => Column(
child: Container( children: [
height: 48, Center(
decoration: BoxDecoration( child: Container(
height: 48,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
border: Border.all( border: Border.all(
width: 1, width: 1,
color: state.faves[index].selected! color: state.faves[index].selected!
? Theme.of(context) ? Theme.of(context).colorScheme.focusedBorder
.colorScheme : Theme.of(context).colorScheme.cardBorder
.focusedBorder ),
: Theme.of(context).colorScheme.cardBorder),
color: state.faves[index].selected! color: state.faves[index].selected!
? Theme.of(context).colorScheme.focused ? Theme.of(context).colorScheme.focused
: Theme.of(context).colorScheme.cardBorder), : Theme.of(context).colorScheme.cardBorder
child: CustomizeCategoryCheckbox( ),
child: CustomizeCategoryCheckbox(
title: state.faves[index].name!, title: state.faves[index].name!,
value: state.faves[index].selected, value: state.faves[index].selected,
checkColor: Theme.of(context).colorScheme.checkFav, checkColor: Theme.of(context).colorScheme.checkFav,
onChanged: (val) { onChanged: (val) {
state.changeSelected( state.changeSelected(
index, state.faves, state.selectedFavIds); index, state.faves, state.selectedFavIds);
})), }
)
),
),
// Add extra bottom padding for the last item
if (index == state.faves.length - 1)
const SizedBox(height: 80),
],
), ),
), ),
), ),