-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #594 from hpi-dhc/issue/567-show-affected-medicati…
…ons-for-gene Show affected medications for gene
- Loading branch information
Showing
11 changed files
with
244 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import '../../module.dart'; | ||
|
||
List<Widget> buildDrugList( | ||
BuildContext context, | ||
DrugListState state, { | ||
String? noDrugsMessage, | ||
}) => | ||
state.when( | ||
initial: () => [Container()], | ||
error: () => [errorIndicator(context.l10n.err_generic)], | ||
loaded: (drugs, filter) => _buildDrugCards( | ||
context, | ||
drugs, | ||
filter, | ||
noDrugsMessage: noDrugsMessage, | ||
), | ||
loading: () => [loadingIndicator()], | ||
); | ||
|
||
List<Widget> _buildDrugCards( | ||
BuildContext context, | ||
List<Drug> drugs, | ||
FilterState filter, { | ||
String? noDrugsMessage, | ||
}) { | ||
final filteredDrugs = filter.filter(drugs); | ||
if (filteredDrugs.isEmpty && noDrugsMessage != null) { | ||
return [errorIndicator(noDrugsMessage)]; | ||
} | ||
return [ | ||
SizedBox(height: 8), | ||
...filteredDrugs.map((drug) => Column(children: [ | ||
Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 8), | ||
child: DrugCard( | ||
onTap: () => context.router | ||
.push(DrugRoute(drug: drug)) | ||
.then((_) => context.read<DrugListCubit>().search()), | ||
drug: drug)), | ||
SizedBox(height: 12) | ||
])) | ||
]; | ||
} | ||
|
||
class DrugCard extends StatelessWidget { | ||
const DrugCard({ | ||
required this.onTap, | ||
required this.drug, | ||
}); | ||
|
||
final VoidCallback onTap; | ||
final Drug drug; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final warningLevel = drug.userGuideline()?.annotations.warningLevel; | ||
|
||
return RoundedCard( | ||
onTap: onTap, | ||
padding: EdgeInsets.all(8), | ||
radius: 16, | ||
color: warningLevel?.color ?? PharMeTheme.onSurfaceColor, | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Row(children: [ | ||
Icon(warningLevel?.icon ?? Icons.help_outline_rounded), | ||
SizedBox(width: 4), | ||
Text( | ||
drug.name.capitalize(), | ||
style: PharMeTheme.textTheme.titleMedium! | ||
.copyWith(fontWeight: FontWeight.bold), | ||
), | ||
]), | ||
SizedBox(height: 4), | ||
if (drug.annotations.brandNames.isNotEmpty) ...[ | ||
SizedBox(width: 4), | ||
Text( | ||
'(${drug.annotations.brandNames.join(', ')})', | ||
style: PharMeTheme.textTheme.titleMedium, | ||
), | ||
], | ||
SizedBox(height: 8), | ||
Text( | ||
drug.annotations.drugclass, | ||
style: PharMeTheme.textTheme.titleSmall, | ||
), | ||
], | ||
), | ||
), | ||
Icon(Icons.chevron_right_rounded), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.