123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- typedef ExampleActionsBuilder = Widget Function(
- BuildContext context, bool isLayoutHorizontal);
- class ExampleActionsWidget extends StatelessWidget {
- const ExampleActionsWidget({
- Key? key,
- required this.displayContentBuilder,
- this.actionsBuilder,
- }) : super(key: key);
- final ExampleActionsBuilder displayContentBuilder;
- final ExampleActionsBuilder? actionsBuilder;
- @override
- Widget build(BuildContext context) {
- final mediaData = MediaQuery.of(context);
- final bool isLayoutHorizontal = mediaData.size.aspectRatio >= 1.5 ||
- (kIsWeb ||
- !(defaultTargetPlatform == TargetPlatform.android ||
- defaultTargetPlatform == TargetPlatform.iOS));
- if (actionsBuilder == null) {
- return displayContentBuilder(context, isLayoutHorizontal);
- }
- const actionsTitle = Text(
- 'Actions',
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
- );
- if (isLayoutHorizontal) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.max,
- children: [
- Expanded(
- flex: 1,
- child: SingleChildScrollView(
- child: Container(
- padding: const EdgeInsets.fromLTRB(16, 24, 16, 24),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- mainAxisSize: MainAxisSize.max,
- children: [
- actionsTitle,
- actionsBuilder!(context, isLayoutHorizontal),
- ],
- ),
- ),
- ),
- ),
- Container(
- color: Colors.grey.shade100,
- width: 20,
- ),
- Expanded(
- flex: 2,
- child: displayContentBuilder(context, isLayoutHorizontal),
- ),
- ],
- );
- }
- return Stack(
- children: [
- SizedBox.expand(
- child: Container(
- padding: const EdgeInsets.only(bottom: 150),
- child: displayContentBuilder(context, isLayoutHorizontal),
- ),
- ),
- DraggableScrollableSheet(
- initialChildSize: 0.25,
- snap: true,
- maxChildSize: 0.7,
- builder: (BuildContext context, ScrollController scrollController) {
- return Container(
- decoration: const BoxDecoration(
- color: Color.fromARGB(255, 253, 253, 253),
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(24.0),
- topRight: Radius.circular(24.0),
- ),
- boxShadow: [
- BoxShadow(
- blurRadius: 20.0,
- color: Colors.grey,
- ),
- ]),
- padding: const EdgeInsets.fromLTRB(16, 24, 16, 0),
- child: SingleChildScrollView(
- controller: scrollController,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- mainAxisSize: MainAxisSize.max,
- children: [
- actionsTitle,
- actionsBuilder!(context, isLayoutHorizontal),
- ],
- ),
- ),
- );
- },
- )
- ],
- );
- }
- }
|