Skip to content

Commit 925da63

Browse files
chrisbobbesm-sayedi
authored andcommitted
action_sheet: Implement BottomSheetEmptyContentPlaceholder, to use soon
1 parent 614fda1 commit 925da63

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

lib/widgets/action_sheet.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,52 @@ class BottomSheetHeader extends StatelessWidget {
181181
}
182182
}
183183

184+
/// A placeholder for when a bottom sheet has no content to show.
185+
///
186+
/// Pass [message] for a "no-content-here" message,
187+
/// or pass true for [loading] if the content hasn't finished loading yet,
188+
/// but don't pass both.
189+
///
190+
/// Show this below a [BottomSheetHeader] if present.
191+
///
192+
/// See also:
193+
/// * [PageBodyEmptyContentPlaceholder], for a similar element to use in
194+
/// pages on the home screen.
195+
// TODO(design) we don't yet have a design for this;
196+
// it was ad-hoc and modeled on [PageBodyEmptyContentPlaceholder].
197+
class BottomSheetEmptyContentPlaceholder extends StatelessWidget {
198+
const BottomSheetEmptyContentPlaceholder({
199+
super.key,
200+
this.message,
201+
this.loading = false,
202+
}) : assert(message == null || !loading);
203+
204+
final String? message;
205+
final bool loading;
206+
207+
@override
208+
Widget build(BuildContext context) {
209+
final designVariables = DesignVariables.of(context);
210+
211+
final child = loading
212+
? CircularProgressIndicator()
213+
: Text(
214+
textAlign: TextAlign.center,
215+
style: TextStyle(
216+
color: designVariables.labelSearchPrompt,
217+
fontSize: 17,
218+
height: 23 / 17,
219+
).merge(weightVariableTextStyle(context, wght: 500)),
220+
message!);
221+
222+
return Padding(
223+
padding: EdgeInsets.fromLTRB(24, 48, 24, 16),
224+
child: Align(
225+
alignment: Alignment.topCenter,
226+
child: child));
227+
}
228+
}
229+
184230
/// A button in an action sheet.
185231
///
186232
/// When built from server data, the action sheet ignores changes in that data;

lib/widgets/page.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ class LoadingPlaceholderPage extends StatelessWidget {
220220
/// This handles the horizontal device insets
221221
/// and the bottom inset when needed (in a message list with no compose box).
222222
/// The top inset is handled externally by the app bar.
223+
///
224+
/// See also:
225+
/// * [BottomSheetEmptyContentPlaceholder], for a similar element to use in
226+
/// a bottom sheet.
223227
// TODO(#311) If the message list gets a bottom nav, the bottom inset will
224228
// always be handled externally too; simplify implementation and dartdoc.
225229
class PageBodyEmptyContentPlaceholder extends StatelessWidget {

0 commit comments

Comments
 (0)