Skip to content

Commit

Permalink
added namaz time
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldar2021 committed Oct 8, 2024
1 parent bac56a7 commit c86f7dc
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 151 deletions.
2 changes: 1 addition & 1 deletion app/lib/modules/home/presentation/view/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _HomeViewState extends State<HomeView> {
Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) => const NamazTimeView(),
builder: (BuildContext context) => const ChooseContinentView(),
),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class _PrayTimeWidgetState extends State<PrayTimeWidget> {
onTap: () => Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) => const NamazTimeView(),
builder: (BuildContext context) => const ChooseContinentView(),
),
),
child: SizedBox(
Expand Down
2 changes: 1 addition & 1 deletion app/lib/modules/namaz_time/data/data.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export 'source/namaz_times_local_data_source.dart';
export 'source/namaz_times_remote_data_source.dart';
export 'source/remote/namaz_time_remote_data_source_impl.dart';
export 'model/namaz_times_response.dart';
export 'model/namaz_times_model_response.dart';
export 'model/continent_model_response.dart';
export 'model/region_model_response.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';

part 'namaz_times_model_response.g.dart';

@JsonSerializable()
@immutable
class NamazTimesResponse {
const NamazTimesResponse({
required this.id,
this.title,
this.titleRu,
this.titleEn,
this.lat,
this.lon,
this.bagymdatOffset,
this.sunriseOffset,
this.zuhrOffset,
this.asrOffset,
this.magribOffset,
this.ishaOffset,
this.useFormula,
this.validUntil,
this.startDateTz,
this.startDateSecondTz,
this.timezone,
this.secondTimezone,
this.times,
});

factory NamazTimesResponse.fromJson(Map<String, dynamic> json) => _$NamazTimesResponseFromJson(json);

Map<String, dynamic> toJson() => _$NamazTimesResponseToJson(this);

final int id;
final String? title;
final String? titleRu;
final String? titleEn;
final double? lat;
final double? lon;
final int? bagymdatOffset;
final int? sunriseOffset;
final int? zuhrOffset;
final int? asrOffset;
final int? magribOffset;
final int? ishaOffset;
final int? useFormula;
final String? validUntil;
final String? startDateTz;
final String? startDateSecondTz;
final int? timezone;
final int? secondTimezone;
final Map<String, List<String>>? times;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 0 additions & 95 deletions app/lib/modules/namaz_time/data/model/namaz_times_response.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ final class NamazTimesRepositoryImpl implements NamazTimesRepository {
asrOffset: 1,
magribOffset: 1,
ishaOffset: 1,
timezone: ' 1',
id: 1,
subLocations: [],
useFormula: 1,
validUntil: '',
startDateTz: '',
startDateSecondTz: '',
timezone: 1,
secondTimezone: 1,
times: {},
);
}
}
Expand All @@ -52,7 +57,12 @@ final class NamazTimesRepositoryImpl implements NamazTimesRepository {
ishaOffset: response.ishaOffset,
timezone: response.timezone,
id: response.id,
subLocations: response.subLocations ?? [],
useFormula: response.useFormula,
validUntil: response.validUntil,
startDateTz: response.startDateTz,
startDateSecondTz: response.startDateSecondTz,
secondTimezone: response.secondTimezone,
times: response.times,
);
}

Expand Down
27 changes: 17 additions & 10 deletions app/lib/modules/namaz_time/domain/entity/namaz_time_entity.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import 'package:my_quran/modules/namaz_time/data/model/namaz_times_response.dart';

@immutable
final class NamazTimesEntity {
const NamazTimesEntity({
required this.id,
required this.title,
required this.subLocations,
this.title,
this.titleRu,
this.titleEn,
this.lat,
Expand All @@ -18,14 +17,16 @@ final class NamazTimesEntity {
this.magribOffset,
this.ishaOffset,
this.useFormula,
this.validUntil,
this.startDateTz,
this.startDateSecondTz,
this.timezone,
this.secondTimezone,
this.times,
});

final int id;
final String title;
final String? title;
final String? titleRu;
final String? titleEn;
final double? lat;
Expand All @@ -36,10 +37,16 @@ final class NamazTimesEntity {
final int? asrOffset;
final int? magribOffset;
final int? ishaOffset;
final bool? useFormula;
final DateTime? startDateTz;
final DateTime? startDateSecondTz;
final String? timezone;
final String? secondTimezone;
final List<SubLocation> subLocations;
final int? useFormula;
final String? validUntil;
final String? startDateTz;
final String? startDateSecondTz;
final int? timezone;
final int? secondTimezone;
final Map<String, List<String>>? times;

List<String>? getTodaysTimes() {
final today = DateFormat('dd.MM').format(DateTime.now());
return times![today];
}
}
4 changes: 3 additions & 1 deletion app/lib/modules/namaz_time/presentation/presentation.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export 'cubit/namaz_time_cubit.dart';
export 'view/choose_continent_view.dart';
export 'view/choose_regions_view.dart';
export 'view/choose_city_view.dart';
export 'view/namaz_time_view.dart';
export 'view/regions_view.dart';
53 changes: 53 additions & 0 deletions app/lib/modules/namaz_time/presentation/view/choose_city_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:my_quran/core/core.dart';
import 'package:my_quran/modules/modules.dart';

class CityView extends StatelessWidget {
const CityView({required this.regionId, super.key});

final int regionId;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('City'),
),
body: BlocProvider(
create: (context) => context.read<NamazTimeCubit>()..getRegions(regionId),
child: BlocBuilder<NamazTimeCubit, NamazTimeState>(
builder: (context, state) {
if (state.status == FetchStatus.loading) {
return const Center(child: CircularProgressIndicator());
} else if (state.status == FetchStatus.error) {
return const Center(child: Text('Error fetching regions.'));
} else if (state.status == FetchStatus.success) {
final regions = state.regionsEntity?.list ?? [];

return ListView.builder(
itemCount: regions.length,
itemBuilder: (context, index) {
final region = regions[index];
return ListTile(
title: Text(region.title ?? ''),
onTap: () {
Navigator.push<ChooseContinentView>(
context,
MaterialPageRoute<ChooseContinentView>(
builder: (context) => NamazTimeView(cityId: region.id),
),
);
// context.read<NamazTimeCubit>().getRegions(region.id);
},
);
},
);
}
return const Center(child: Text('No regions found.'));
},
),
),
);
}
}
Loading

0 comments on commit c86f7dc

Please sign in to comment.