Skip to content

Commit cd660a9

Browse files
chrisbobbesm-sayedi
authored andcommitted
action_sheet: Implement BottomSheetEmptyContentPlaceholder, to use soon
1 parent 2dbd778 commit cd660a9

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
@@ -178,6 +178,52 @@ class BottomSheetHeader extends StatelessWidget {
178178
}
179179
}
180180

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