Skip to content

Commit

Permalink
fix/pri_vyhledani_lekare_uvedena_spatna_specializace (#365)
Browse files Browse the repository at this point in the history
opraveno po kliknutí na "Nemám lékaře" při objednávání se na prohlídku se otevře mapa s lékaři se specializací na prohlídku.
(Loono-cz/loono-tasks#79)
  • Loading branch information
Brambora0 committed Sep 26, 2022
1 parent 1e02a0b commit 7b2a90c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/router/app_router.gr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ class AppRouter extends _i15.RootStackRouter {
return _i15.MaterialPageX<void>(
routeData: routeData,
child: _i11.FindDoctorScreen(
key: args.key, onCancelTap: args.onCancelTap));
key: args.key,
firstSelectedSpecializationName: args.targetSpecialization,
onCancelTap: args.onCancelTap,
));
},
DoctorSearchDetailRoute.name: (routeData) {
return _i15.CustomPage<_i58.SearchResult>(
Expand Down Expand Up @@ -967,21 +970,32 @@ class LoginRouteArgs {
/// generated route for
/// [_i11.FindDoctorScreen]
class FindDoctorRoute extends _i15.PageRouteInfo<FindDoctorRouteArgs> {
FindDoctorRoute({_i56.Key? key, void Function()? onCancelTap})
: super(FindDoctorRoute.name,
path: 'find-doctor',
args: FindDoctorRouteArgs(key: key, onCancelTap: onCancelTap));
FindDoctorRoute({
_i56.Key? key,
String? targetSpecialization,
void Function()? onCancelTap,
}) : super(
FindDoctorRoute.name,
path: 'find-doctor',
args: FindDoctorRouteArgs(
key: key,
targetSpecialization: targetSpecialization,
onCancelTap: onCancelTap,
),
);

static const String name = 'FindDoctorRoute';
}

class FindDoctorRouteArgs {
const FindDoctorRouteArgs({this.key, this.onCancelTap});
const FindDoctorRouteArgs({this.key,this.targetSpecialization, this.onCancelTap,});

final _i56.Key? key;

final void Function()? onCancelTap;

final String? targetSpecialization;

@override
String toString() {
return 'FindDoctorRouteArgs{key: $key, onCancelTap: $onCancelTap}';
Expand Down
34 changes: 34 additions & 0 deletions lib/ui/screens/find_doctor/find_doctor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class FindDoctorScreen extends StatefulWidget {
const FindDoctorScreen({
Key? key,
this.onCancelTap,
this.firstSelectedSpecializationName,
}) : super(key: key);

final VoidCallback? onCancelTap;
final String? firstSelectedSpecializationName;

@override
State<FindDoctorScreen> createState() => FindDoctorScreenState();
Expand All @@ -41,6 +43,9 @@ class FindDoctorScreenState extends State<FindDoctorScreen> {

late final MapStateService _mapState;

bool _isFirstSelectedSpecializationSet = false;
bool _canFirstSelectedSpecializationSet = false;

bool _isHealthCareProvidersInMapService = false;
double _mapOpacity = 1;

Expand Down Expand Up @@ -76,8 +81,37 @@ class FindDoctorScreenState extends State<FindDoctorScreen> {
_mapState = context.read<MapStateService>();
}


@override
void dispose() {
_isFirstSelectedSpecializationSet = false;
super.dispose();
}

void _setFirstSelectedSpecialization() {
if (!_isFirstSelectedSpecializationSet) {
_isFirstSelectedSpecializationSet = true;

final specializationName = widget.firstSelectedSpecializationName;
if (specializationName != null) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
final specResult =
_mapState.getSpecSearchResultByName(specializationName);
_mapState.setSpecialization(specResult);
});
}
}
}

@override
Widget build(BuildContext context) {
if(_canFirstSelectedSpecializationSet){
_setFirstSelectedSpecialization();
_canFirstSelectedSpecializationSet = false;
}
else {
_canFirstSelectedSpecializationSet = true;
}
final currDoctorDetail =
context.select<MapStateService, SimpleHealthcareProvider?>((value) => value.doctorDetail);
final currSpec =
Expand Down
18 changes: 18 additions & 0 deletions lib/ui/widgets/find_doctor/specialization_chips_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:loono/constants.dart';
import 'package:loono/services/map_state_sevice.dart';
import 'package:loono/ui/widgets/find_doctor/specializations_list_sheet.dart';
import 'package:loono_api/loono_api.dart';
import 'package:provider/provider.dart';

// key - spec name in chip in UI
Expand All @@ -16,6 +17,23 @@ const _defaultSpecs = <String, String>{
'Další odbornosti': '',
};

String getSpecializationByExaminationType(ExaminationType examinationType){
switch (examinationType) {
case ExaminationType.GENERAL_PRACTITIONER:
return _defaultSpecs['Praktický lékař'] ?? '';
case ExaminationType.DENTIST:
return _defaultSpecs['Zubař'] ?? '';
case ExaminationType.GYNECOLOGIST:
return _defaultSpecs['Gynekolog'] ?? '';
case ExaminationType.DERMATOLOGIST:
return _defaultSpecs['Dermatolog'] ?? '';
case ExaminationType.OPHTHALMOLOGIST:
return _defaultSpecs['Oční'] ?? '';
default:
return _defaultSpecs['Další odbornosti'] ?? '';
}
}

class SpecializationChipsList extends StatelessWidget {
SpecializationChipsList({
Key? key,
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/widgets/prevention/examination_new_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:loono/l10n/ext.dart';
import 'package:loono/models/categorized_examination.dart';
import 'package:loono/router/app_router.gr.dart';
import 'package:loono/ui/widgets/button.dart';
import 'package:loono/ui/widgets/find_doctor/specialization_chips_list.dart';
import 'package:loono/ui/widgets/how/loon_botton_sheet.dart';
import 'package:loono/ui/widgets/prevention/datepicker_sheet.dart';
import 'package:loono/utils/registry.dart';
Expand Down Expand Up @@ -64,6 +65,7 @@ void showNewCheckupSheetStep1(
).toLowerCase()}',
onTap: () => appRouter.push(
FindDoctorRoute(
targetSpecialization: getSpecializationByExaminationType(examinationType),
onCancelTap: () async {
final autoRouter = AutoRouter.of(context);
await appRouter.pop();
Expand Down

0 comments on commit 7b2a90c

Please sign in to comment.