|
@@ -20,8 +20,8 @@ class OverlayItem extends DemoItem {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class OverlayDemoAnchorDirection extends ChangeNotifier {
|
|
|
|
- OverlayDemoAnchorDirection(this._anchorDirection);
|
|
|
|
|
|
+class OverlayDemoConfiguration extends ChangeNotifier {
|
|
|
|
+ OverlayDemoConfiguration(this._anchorDirection, this._overlapBehaviour);
|
|
|
|
|
|
AnchorDirection _anchorDirection;
|
|
AnchorDirection _anchorDirection;
|
|
|
|
|
|
@@ -31,6 +31,15 @@ class OverlayDemoAnchorDirection extends ChangeNotifier {
|
|
_anchorDirection = value;
|
|
_anchorDirection = value;
|
|
notifyListeners();
|
|
notifyListeners();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ OverlapBehaviour _overlapBehaviour;
|
|
|
|
+
|
|
|
|
+ OverlapBehaviour get overlapBehaviour => _overlapBehaviour;
|
|
|
|
+
|
|
|
|
+ set overlapBehaviour(OverlapBehaviour value) {
|
|
|
|
+ _overlapBehaviour = value;
|
|
|
|
+ notifyListeners();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
class OverlayScreen extends StatelessWidget {
|
|
class OverlayScreen extends StatelessWidget {
|
|
@@ -43,7 +52,7 @@ class OverlayScreen extends StatelessWidget {
|
|
title: const Text('Overlay Demo'),
|
|
title: const Text('Overlay Demo'),
|
|
),
|
|
),
|
|
body: ChangeNotifierProvider(
|
|
body: ChangeNotifierProvider(
|
|
- create: (context) => OverlayDemoAnchorDirection(AnchorDirection.rightWithTopAligned),
|
|
|
|
|
|
+ create: (context) => OverlayDemoConfiguration(AnchorDirection.rightWithTopAligned, OverlapBehaviour.stretch),
|
|
child: Builder(builder: (providerContext) {
|
|
child: Builder(builder: (providerContext) {
|
|
return Center(
|
|
return Center(
|
|
child: ConstrainedBox(
|
|
child: ConstrainedBox(
|
|
@@ -80,10 +89,10 @@ class OverlayScreen extends StatelessWidget {
|
|
),
|
|
),
|
|
const SizedBox(height: 24.0),
|
|
const SizedBox(height: 24.0),
|
|
DropdownButton<AnchorDirection>(
|
|
DropdownButton<AnchorDirection>(
|
|
- value: providerContext.watch<OverlayDemoAnchorDirection>().anchorDirection,
|
|
|
|
|
|
+ value: providerContext.watch<OverlayDemoConfiguration>().anchorDirection,
|
|
onChanged: (AnchorDirection? newValue) {
|
|
onChanged: (AnchorDirection? newValue) {
|
|
if (newValue != null) {
|
|
if (newValue != null) {
|
|
- providerContext.read<OverlayDemoAnchorDirection>().anchorDirection = newValue;
|
|
|
|
|
|
+ providerContext.read<OverlayDemoConfiguration>().anchorDirection = newValue;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
items: AnchorDirection.values.map((AnchorDirection classType) {
|
|
items: AnchorDirection.values.map((AnchorDirection classType) {
|
|
@@ -91,6 +100,18 @@ class OverlayScreen extends StatelessWidget {
|
|
}).toList(),
|
|
}).toList(),
|
|
),
|
|
),
|
|
const SizedBox(height: 24.0),
|
|
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) {
|
|
Builder(builder: (buttonContext) {
|
|
return SizedBox(
|
|
return SizedBox(
|
|
height: 100,
|
|
height: 100,
|
|
@@ -98,7 +119,7 @@ class OverlayScreen extends StatelessWidget {
|
|
onPressed: () {
|
|
onPressed: () {
|
|
FlowyOverlay.of(context).insertWithAnchor(
|
|
FlowyOverlay.of(context).insertWithAnchor(
|
|
widget: SizedBox(
|
|
widget: SizedBox(
|
|
- width: 100,
|
|
|
|
|
|
+ width: 300,
|
|
height: 50,
|
|
height: 50,
|
|
child: Card(
|
|
child: Card(
|
|
color: Colors.grey[200],
|
|
color: Colors.grey[200],
|
|
@@ -112,7 +133,8 @@ class OverlayScreen extends StatelessWidget {
|
|
identifier: 'overlay_anchored_card',
|
|
identifier: 'overlay_anchored_card',
|
|
delegate: null,
|
|
delegate: null,
|
|
anchorContext: buttonContext,
|
|
anchorContext: buttonContext,
|
|
- anchorDirection: providerContext.read<OverlayDemoAnchorDirection>().anchorDirection,
|
|
|
|
|
|
+ anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
|
|
|
|
+ overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
|
);
|
|
);
|
|
},
|
|
},
|
|
child: const Text('Show Anchored Overlay'),
|
|
child: const Text('Show Anchored Overlay'),
|
|
@@ -140,7 +162,8 @@ class OverlayScreen extends StatelessWidget {
|
|
delegate: null,
|
|
delegate: null,
|
|
anchorPosition: Offset(0, windowSize.height - 200),
|
|
anchorPosition: Offset(0, windowSize.height - 200),
|
|
anchorSize: Size.zero,
|
|
anchorSize: Size.zero,
|
|
- anchorDirection: providerContext.read<OverlayDemoAnchorDirection>().anchorDirection,
|
|
|
|
|
|
+ anchorDirection: providerContext.read<OverlayDemoConfiguration>().anchorDirection,
|
|
|
|
+ overlapBehaviour: providerContext.read<OverlayDemoConfiguration>().overlapBehaviour,
|
|
);
|
|
);
|
|
},
|
|
},
|
|
child: const Text('Show Positioned Overlay'),
|
|
child: const Text('Show Positioned Overlay'),
|