@@ -116,41 +116,51 @@ void showIngredientDetails(BuildContext context, int id, {String? image}) {
116
116
goals = ingredient! .nutritionalValues.toGoals ();
117
117
source = ingredient.sourceName ?? 'unknown' ;
118
118
}
119
+ var radius = 100.0 ;
120
+ final height = MediaQuery .sizeOf (context).height;
121
+ final width = MediaQuery .sizeOf (context).width;
122
+ final smallest = height < width ? height : width;
123
+ if (smallest < 400 ) {
124
+ radius = smallest / 4 ;
125
+ }
119
126
return AlertDialog (
120
127
title: (snapshot.hasData) ? Text (ingredient! .name) : null ,
121
- content: Padding (
122
- padding: const EdgeInsets .all (8.0 ),
123
- child: Column (
124
- mainAxisSize: MainAxisSize .min,
125
- children: [
126
- if (image != null ) CircleAvatar (backgroundImage: NetworkImage (image), radius: 128 ),
127
- if (image != null ) const SizedBox (height: 12 ),
128
- if (snapshot.hasError)
129
- Text (
130
- 'Ingredient lookup error: ${snapshot .error ?? 'unknown error' }' ,
131
- style: const TextStyle (color: Colors .red),
132
- ),
133
- if (! snapshot.hasData && ! snapshot.hasError) const CircularProgressIndicator (),
134
- if (snapshot.hasData)
135
- ConstrainedBox (
136
- constraints: const BoxConstraints (minWidth: 400 ),
137
- child: MacronutrientsTable (
138
- nutritionalGoals: goals! ,
139
- plannedValuesPercentage: goals.energyPercentage (),
140
- showGperKg: false ,
128
+ content: SingleChildScrollView (
129
+ child: Padding (
130
+ padding: const EdgeInsets .all (8.0 ),
131
+ child: Column (
132
+ mainAxisSize: MainAxisSize .min,
133
+ children: [
134
+ if (image != null )
135
+ CircleAvatar (backgroundImage: NetworkImage (image), radius: radius),
136
+ if (image != null ) const SizedBox (height: 12 ),
137
+ if (snapshot.hasError)
138
+ Text (
139
+ 'Ingredient lookup error: ${snapshot .error ?? 'unknown error' }' ,
140
+ style: const TextStyle (color: Colors .red),
141
+ ),
142
+ if (! snapshot.hasData && ! snapshot.hasError) const CircularProgressIndicator (),
143
+ if (snapshot.hasData)
144
+ ConstrainedBox (
145
+ constraints: const BoxConstraints (minWidth: 400 ),
146
+ child: MacronutrientsTable (
147
+ nutritionalGoals: goals! ,
148
+ plannedValuesPercentage: goals.energyPercentage (),
149
+ showGperKg: false ,
150
+ ),
141
151
),
142
- ),
143
- if (snapshot.hasData && ingredient ! .licenseObjectURl == null )
144
- Text ( 'Source: ${ source !}' ),
145
- if (snapshot.hasData && ingredient ! .licenseObjectURl != null )
146
- Padding (
147
- padding : const EdgeInsets . only (top : 12 ),
148
- child: InkWell (
149
- child : Text ( 'Source: ${ source !}' ),
150
- onTap : () => launchURL (ingredient ! .licenseObjectURl ! , context ),
152
+ if (snapshot.hasData && ingredient ! .licenseObjectURl == null )
153
+ Text ( 'Source: ${ source !}' ),
154
+ if (snapshot.hasData && ingredient ! .licenseObjectURl != null )
155
+ Padding (
156
+ padding : const EdgeInsets . only (top : 12 ),
157
+ child : InkWell (
158
+ child: Text ( 'Source: ${ source !}' ),
159
+ onTap : () => launchURL (ingredient ! .licenseObjectURl ! , context ),
160
+ ),
151
161
),
152
- ) ,
153
- ] ,
162
+ ] ,
163
+ ) ,
154
164
),
155
165
),
156
166
);
0 commit comments