showDisplayRule method
void
showDisplayRule(
- MPDisplayRule displayRule
Implementation
void showDisplayRule(MPDisplayRule displayRule) async {
String? iconUrl = await displayRule.getIconUrl();
if (iconUrl != null) {
textController.text = iconUrl;
}
num? zoomFrom = await displayRule.getZoomFrom();
if (zoomFrom != null) {
numberController.text = zoomFrom.toString();
}
persistentBottomSheetController =
scaffoldKey.currentState!.showBottomSheet((context) {
return Container(
color: Colors.white,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Column(
children: <Widget>[
Title(color: Colors.black, child: const Text("String values")),
Row(
children: [
DropdownButton(
items: const <DropdownMenuItem>[
DropdownMenuItem(value: "icon", child: Text("icon")),
DropdownMenuItem(value: "label", child: Text("label")),
DropdownMenuItem(
value: "polygonStrokeColor",
child: Text("polygonStrokeColor")),
DropdownMenuItem(
value: "polygonFillColor",
child: Text("polygonFillColor")),
],
onChanged: (dynamic value) async {
if (value != null && value is String) {
chosenStringDisplayRule = value;
textController.text =
await getDisplayRuleValue(value, displayRule);
persistentBottomSheetController?.setState!(() {});
}
},
value: chosenStringDisplayRule),
Expanded(
child: TextField(
controller: textController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
),
)),
],
),
ElevatedButton(
onPressed: () => saveDisplayRuleValue(
chosenStringDisplayRule, displayRule, textController.text),
child: const Text("Save string")),
Title(color: Colors.black, child: const Text("Boolean values")),
Row(
children: [
DropdownButton(
items: const <DropdownMenuItem>[
DropdownMenuItem(value: "visible", child: Text("visible")),
DropdownMenuItem(
value: "iconVisible", child: Text("iconVisible")),
DropdownMenuItem(
value: "labelVisible", child: Text("labelVisible")),
DropdownMenuItem(
value: "polygonVisible", child: Text("polygonVisible")),
DropdownMenuItem(
value: "wallVisible", child: Text("wallVisible")),
DropdownMenuItem(
value: "extrusionVisible",
child: Text("extrusionVisible")),
DropdownMenuItem(
value: "2DModelVisible", child: Text("2DModelVisible")),
],
onChanged: (dynamic value) async {
if (value != null && value is String) {
chosenBooleanDisplayRule = value;
currentBooleanRuleState =
await getBooleanDisplayRuleValue(value, displayRule);
persistentBottomSheetController?.setState!(() {});
}
},
value: chosenBooleanDisplayRule,
),
Expanded(
child: DropdownButton<dynamic>(
items: const <DropdownMenuItem>[
DropdownMenuItem(value: true, child: Text("true")),
DropdownMenuItem(value: false, child: Text("false"))
],
onChanged: (value) {
persistentBottomSheetController?.setState!(
() {
currentBooleanRuleState = value as bool;
},
);
},
value: currentBooleanRuleState,
),
),
],
),
ElevatedButton(
onPressed: () => saveBooleanDisplayRuleValue(
chosenBooleanDisplayRule,
displayRule,
currentBooleanRuleState),
child: const Text("Save bool")),
Title(color: Colors.black, child: const Text("Numerical values")),
Row(
children: [
DropdownButton(
items: const <DropdownMenuItem>[
DropdownMenuItem(
value: "zoomFrom", child: Text("zoomFrom")),
DropdownMenuItem(value: "zoomTo", child: Text("zoomTo")),
DropdownMenuItem(
value: "iconSize", child: Text("iconSize")),
DropdownMenuItem(
value: "labelZoomFrom", child: Text("labelZoomFrom")),
DropdownMenuItem(
value: "labelZoomTo", child: Text("labelZoomTo")),
DropdownMenuItem(
value: "labelMaxWidth", child: Text("labelMaxWidth")),
DropdownMenuItem(
value: "polygonZoomFrom",
child: Text("polygonZoomFrom")),
DropdownMenuItem(
value: "polygonZoomTo", child: Text("polygonZoomTo")),
DropdownMenuItem(
value: "polygonOpacity", child: Text("polygonOpacity")),
],
onChanged: (dynamic value) async {
if (value != null && value is String) {
numberController.text =
(await getNumericalDisplayRuleValue(
value, displayRule))
.toString();
chosenNumberDisplayRule = value;
persistentBottomSheetController?.setState!(() {});
}
},
value: chosenNumberDisplayRule,
),
Expanded(
child: TextField(
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.allow((RegExp("[.0-9]")))
],
controller: numberController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
),
)),
],
),
ElevatedButton(
onPressed: () => saveNumericalDisplayRuleValue(
chosenNumberDisplayRule,
displayRule,
double.parse(numberController.text)),
child: const Text("Save number")),
],
),
);
});
}