1+ import 'package:cima_client/common/widgets/cima_loading.dart' ;
12import 'package:cima_client/l10n/l10n.dart' ;
23import 'package:cima_client/medication_detail/medication_detail.dart' ;
34import 'package:cima_model/cima_model.dart' ;
4- import 'package:cima_repository/cima_repository.dart' ;
55import 'package:flutter/material.dart' ;
66import 'package:flutter_bloc/flutter_bloc.dart' ;
77import 'package:share_plus/share_plus.dart' ;
@@ -20,29 +20,33 @@ class MedicationDetailPage extends StatelessWidget {
2020 @override
2121 Widget build (BuildContext context) {
2222 final l10n = context.l10n;
23- return BlocProvider (
24- create: (context) =>
25- MedicationDetailBloc (cimaRepository: context.read <CimaRepository >())
26- ..add (
27- FetchMedicamento (
28- nregistro: medication.registerNumber,
29- ),
23+ return Scaffold (
24+ appBar: AppBar (
25+ title: Text (l10n.medication_detail_page_title),
26+ actions: [
27+ IconButton (
28+ icon: const Icon (Icons .share),
29+ onPressed: () => Share .share (
30+ 'https://cima.aemps.es/cima/publico/detalle.html?'
31+ 'nregistro=${medication .registerNumber }' ,
32+ subject: medication.name,
3033 ),
31- child: Scaffold (
32- appBar: AppBar (
33- title: Text (l10n.medication_detail_page_title),
34- actions: [
35- IconButton (
36- icon: const Icon (Icons .share),
37- onPressed: () => Share .share (
38- 'https://cima.aemps.es/cima/publico/detalle.html?'
39- 'nregistro=${medication .registerNumber }' ,
40- subject: medication.name,
41- ),
42- ),
43- ],
44- ),
45- body: MedicationDetailWidget (medicamento: medication),
34+ ),
35+ ],
36+ ),
37+ body: BlocBuilder <MedicationDetailBloc , MedicationDetailState >(
38+ builder: (context, state) {
39+ switch (state) {
40+ case AvailableMedicationDetailState ():
41+ return MedicationDetailWidget (medicamento: medication);
42+ case Initial ():
43+ case Loading ():
44+ return const CimaLoading ();
45+ }
46+ return const SizedBox .shrink ();
47+ // AvailableMedicationDetailState:
48+ // return MedicationDetailWidget(medicamento: medication);
49+ },
4650 ),
4751 );
4852 }
0 commit comments