[infra_ui][overlay] Update overlay example project for list_overlay and option_overlay

This commit is contained in:
Jaylen Bian 2021-08-09 10:49:37 +08:00
parent 82e6856f75
commit 0edd8b86c0

View File

@ -1,3 +1,4 @@
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/flowy_infra_ui_web.dart'; import 'package:flowy_infra_ui/flowy_infra_ui_web.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -168,11 +169,56 @@ class OverlayScreen extends StatelessWidget {
}, },
child: const Text('Show Positioned Overlay'), child: const Text('Show Positioned Overlay'),
), ),
const SizedBox(height: 24.0),
Builder(builder: (buttonContext) {
return ElevatedButton(
onPressed: () {
ListOverlay.showWithAnchor(
context,
itemBuilder: (_, index) => Card(
margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
elevation: 0,
child: Text(
'Option $index',
style: const TextStyle(fontSize: 20.0, color: Colors.black),
),
),
itemCount: 10,
identifier: 'overlay_list_menu',
anchorContext: buttonContext,
anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
maxWidth: 200.0,
maxHeight: 200.0,
);
},
child: const Text('Show List Overlay'),
);
}),
const SizedBox(height: 24.0),
Builder(builder: (buttonContext) {
return ElevatedButton(
onPressed: () {
OptionOverlay.showWithAnchor(
context,
items: <String>['Alpha', 'Beta', 'Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf', 'Hotel'],
onHover: (value, index) => print('Did hover option $index, value $value'),
onTap: (value, index) => print('Did tap option $index, value $value'),
identifier: 'overlay_options',
anchorContext: buttonContext,
anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
);
},
child: const Text('Show Options Overlay'),
);
}),
], ],
), ),
), ),
); );
}), }),
)); ),
);
} }
} }