mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[infra_ui][overlay] Update overlay example project for list_overlay and option_overlay
This commit is contained in:
parent
82e6856f75
commit
0edd8b86c0
@ -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';
|
||||||
@ -48,109 +49,31 @@ class OverlayScreen extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Overlay Demo'),
|
title: const Text('Overlay Demo'),
|
||||||
),
|
),
|
||||||
body: ChangeNotifierProvider(
|
body: ChangeNotifierProvider(
|
||||||
create: (context) => OverlayDemoConfiguration(AnchorDirection.rightWithTopAligned, OverlapBehaviour.stretch),
|
create: (context) => OverlayDemoConfiguration(AnchorDirection.rightWithTopAligned, OverlapBehaviour.stretch),
|
||||||
child: Builder(builder: (providerContext) {
|
child: Builder(builder: (providerContext) {
|
||||||
return Center(
|
return Center(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints.tightFor(width: 500),
|
constraints: const BoxConstraints.tightFor(width: 500),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 48.0),
|
const SizedBox(height: 48.0),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final windowSize = MediaQuery.of(context).size;
|
final windowSize = MediaQuery.of(context).size;
|
||||||
FlowyOverlay.of(context).insertCustom(
|
FlowyOverlay.of(context).insertCustom(
|
||||||
widget: Positioned(
|
widget: Positioned(
|
||||||
left: windowSize.width / 2.0 - 100,
|
left: windowSize.width / 2.0 - 100,
|
||||||
top: 200,
|
top: 200,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 200,
|
|
||||||
height: 100,
|
|
||||||
child: Card(
|
|
||||||
color: Colors.green[200],
|
|
||||||
child: GestureDetector(
|
|
||||||
// ignore: avoid_print
|
|
||||||
onTapDown: (_) => print('Hello Flutter'),
|
|
||||||
child: const Center(child: FlutterLogo(size: 100)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
identifier: 'overlay_flutter_logo',
|
|
||||||
delegate: null,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Show Overlay'),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24.0),
|
|
||||||
DropdownButton<AnchorDirection>(
|
|
||||||
value: providerContext.watch<OverlayDemoConfiguration>().anchorDirection,
|
|
||||||
onChanged: (AnchorDirection? newValue) {
|
|
||||||
if (newValue != null) {
|
|
||||||
providerContext.read<OverlayDemoConfiguration>().anchorDirection = newValue;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
items: AnchorDirection.values.map((AnchorDirection classType) {
|
|
||||||
return DropdownMenuItem<AnchorDirection>(value: classType, child: Text(classType.toString()));
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24.0),
|
|
||||||
DropdownButton<OverlapBehaviour>(
|
|
||||||
value: providerContext.watch<OverlayDemoConfiguration>().overlapBehaviour,
|
|
||||||
onChanged: (OverlapBehaviour? newValue) {
|
|
||||||
if (newValue != null) {
|
|
||||||
providerContext.read<OverlayDemoConfiguration>().overlapBehaviour = newValue;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
items: OverlapBehaviour.values.map((OverlapBehaviour classType) {
|
|
||||||
return DropdownMenuItem<OverlapBehaviour>(value: classType, child: Text(classType.toString()));
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24.0),
|
|
||||||
Builder(builder: (buttonContext) {
|
|
||||||
return SizedBox(
|
|
||||||
height: 100,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
FlowyOverlay.of(context).insertWithAnchor(
|
|
||||||
widget: SizedBox(
|
|
||||||
width: 300,
|
|
||||||
height: 50,
|
|
||||||
child: Card(
|
|
||||||
color: Colors.grey[200],
|
|
||||||
child: GestureDetector(
|
|
||||||
// ignore: avoid_print
|
|
||||||
onTapDown: (_) => print('Hello Flutter'),
|
|
||||||
child: const Center(child: FlutterLogo(size: 50)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
identifier: 'overlay_anchored_card',
|
|
||||||
delegate: null,
|
|
||||||
anchorContext: buttonContext,
|
|
||||||
anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
|
|
||||||
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Show Anchored Overlay'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 24.0),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
final windowSize = MediaQuery.of(context).size;
|
|
||||||
FlowyOverlay.of(context).insertWithRect(
|
|
||||||
widget: SizedBox(
|
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 100,
|
height: 100,
|
||||||
child: Card(
|
child: Card(
|
||||||
color: Colors.orange[200],
|
color: Colors.green[200],
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
// ignore: avoid_print
|
// ignore: avoid_print
|
||||||
onTapDown: (_) => print('Hello Flutter'),
|
onTapDown: (_) => print('Hello Flutter'),
|
||||||
@ -158,21 +81,144 @@ class OverlayScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
identifier: 'overlay_positioned_card',
|
),
|
||||||
delegate: null,
|
identifier: 'overlay_flutter_logo',
|
||||||
anchorPosition: Offset(0, windowSize.height - 200),
|
delegate: null,
|
||||||
anchorSize: Size.zero,
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Show Overlay'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24.0),
|
||||||
|
DropdownButton<AnchorDirection>(
|
||||||
|
value: providerContext.watch<OverlayDemoConfiguration>().anchorDirection,
|
||||||
|
onChanged: (AnchorDirection? newValue) {
|
||||||
|
if (newValue != null) {
|
||||||
|
providerContext.read<OverlayDemoConfiguration>().anchorDirection = newValue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
items: AnchorDirection.values.map((AnchorDirection classType) {
|
||||||
|
return DropdownMenuItem<AnchorDirection>(value: classType, child: Text(classType.toString()));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24.0),
|
||||||
|
DropdownButton<OverlapBehaviour>(
|
||||||
|
value: providerContext.watch<OverlayDemoConfiguration>().overlapBehaviour,
|
||||||
|
onChanged: (OverlapBehaviour? newValue) {
|
||||||
|
if (newValue != null) {
|
||||||
|
providerContext.read<OverlayDemoConfiguration>().overlapBehaviour = newValue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
items: OverlapBehaviour.values.map((OverlapBehaviour classType) {
|
||||||
|
return DropdownMenuItem<OverlapBehaviour>(value: classType, child: Text(classType.toString()));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24.0),
|
||||||
|
Builder(builder: (buttonContext) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 100,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
FlowyOverlay.of(context).insertWithAnchor(
|
||||||
|
widget: SizedBox(
|
||||||
|
width: 300,
|
||||||
|
height: 50,
|
||||||
|
child: Card(
|
||||||
|
color: Colors.grey[200],
|
||||||
|
child: GestureDetector(
|
||||||
|
// ignore: avoid_print
|
||||||
|
onTapDown: (_) => print('Hello Flutter'),
|
||||||
|
child: const Center(child: FlutterLogo(size: 50)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
identifier: 'overlay_anchored_card',
|
||||||
|
delegate: null,
|
||||||
|
anchorContext: buttonContext,
|
||||||
|
anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
|
||||||
|
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Show Anchored Overlay'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
const SizedBox(height: 24.0),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
final windowSize = MediaQuery.of(context).size;
|
||||||
|
FlowyOverlay.of(context).insertWithRect(
|
||||||
|
widget: SizedBox(
|
||||||
|
width: 200,
|
||||||
|
height: 100,
|
||||||
|
child: Card(
|
||||||
|
color: Colors.orange[200],
|
||||||
|
child: GestureDetector(
|
||||||
|
// ignore: avoid_print
|
||||||
|
onTapDown: (_) => print('Hello Flutter'),
|
||||||
|
child: const Center(child: FlutterLogo(size: 100)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
identifier: 'overlay_positioned_card',
|
||||||
|
delegate: null,
|
||||||
|
anchorPosition: Offset(0, windowSize.height - 200),
|
||||||
|
anchorSize: Size.zero,
|
||||||
|
anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
|
||||||
|
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
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,
|
anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
|
||||||
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('Show Positioned Overlay'),
|
child: const Text('Show Options Overlay'),
|
||||||
),
|
);
|
||||||
],
|
}),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}),
|
);
|
||||||
));
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user