release 1.0.7, Close Issue #10 , 添加Logo位置设置

This commit is contained in:
Kuloud
2024-07-29 00:28:45 +08:00
parent 7e3759b638
commit 064bb77cf1
14 changed files with 274 additions and 33 deletions

View File

@ -1,7 +1,10 @@
import 'package:amap_map/amap_map.dart';
import 'package:amap_map_example/widgets/amap_gridview.dart';
import 'package:amap_map_example/widgets/amap_radio_group.dart';
import 'package:amap_map_example/widgets/amap_switch_button.dart';
import 'package:flutter/material.dart';
import 'package:x_amap_base/x_amap_base.dart';
import 'package:x_common/utils/logger.dart';
class MapUIDemoPage extends StatefulWidget {
MapUIDemoPage({Key? key}) : super(key: key);
@ -26,6 +29,16 @@ class _BodyState extends State<MapUIDemoPage> {
///是否显示比例尺
bool _scaleEnabled = true;
LogoPosition _logoPosition = LogoPosition.BOTTOM_LEFT;
int _logoBottomMargin = 0;
int _logoLeftMargin = 0;
final Map<String, LogoPosition?> _radioValueMap = {
'底部居左': LogoPosition.BOTTOM_LEFT,
'底部居中': LogoPosition.BOTTOM_CENTER,
'底部居右': LogoPosition.BOTTOM_RIGHT,
};
@override
Widget build(BuildContext context) {
final AMapWidget map = AMapWidget(
@ -34,6 +47,9 @@ class _BodyState extends State<MapUIDemoPage> {
compassEnabled: _compassEnabled,
labelsEnabled: _labelsEnabled,
scaleEnabled: _scaleEnabled,
logoPosition: _logoPosition,
logoBottomMargin: _logoBottomMargin,
logoLeftMargin: _logoLeftMargin,
);
//ui控制
@ -97,6 +113,43 @@ class _BodyState extends State<MapUIDemoPage> {
padding: EdgeInsets.only(left: 10),
child: AMapGradView(childrenWidgets: _uiOptions),
),
AMapRadioGroup<LogoPosition?>(
groupLabel: 'Logo位置',
groupValue: _logoPosition,
radioValueMap: _radioValueMap,
onChanged: (value) => {
//改变当前地图样式为选中的样式
setState(() {
_logoPosition = value!;
})
},
),
Text('Logo底部边距: $_logoBottomMargin'),
Slider(
value: _logoBottomMargin.toDouble(),
min: 0,
max: 100,
divisions: 100,
label: _logoBottomMargin.round().toString(),
onChanged: (double value) {
setState(() {
_logoBottomMargin = value.round();
});
},
),
Text('Logo左侧边距: $_logoLeftMargin'),
Slider(
value: _logoLeftMargin.toDouble(),
min: 0,
max: 100,
divisions: 100,
label: _logoLeftMargin.round().toString(),
onChanged: (double value) {
setState(() {
_logoLeftMargin = value.round();
});
},
),
],
),
);
@ -110,7 +163,7 @@ class _BodyState extends State<MapUIDemoPage> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.7,
height: MediaQuery.of(context).size.height * 0.5,
width: MediaQuery.of(context).size.width,
child: map,
),

View File

@ -5,7 +5,7 @@ class AMapRadioGroup<T> extends StatefulWidget {
final String? groupLabel;
final T? groupValue;
final Map<String, T>? radioValueMap;
final ValueChanged<T>? onChanged;
final ValueChanged<T?>? onChanged;
AMapRadioGroup(
{Key? key,
this.groupLabel,
@ -15,37 +15,35 @@ class AMapRadioGroup<T> extends StatefulWidget {
: super(key: key);
@override
_AMapRadioGroupState createState() => _AMapRadioGroupState();
_AMapRadioGroupState<T> createState() => _AMapRadioGroupState<T>();
}
class _AMapRadioGroupState extends State<AMapRadioGroup> {
dynamic _groupValue;
class _AMapRadioGroupState<T> extends State<AMapRadioGroup<T>> {
T? _groupValue;
@override
void initState() {
super.initState();
_groupValue = widget.groupValue ?? null;
_groupValue = (widget.groupValue ?? null) as T?;
}
@override
Widget build(BuildContext context) {
List<Widget> radioList = <Widget>[];
_groupValue = widget.groupValue ?? null;
_groupValue = (widget.groupValue ?? null) as T?;
Widget _myRadio(String label, dynamic radioValue) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(label),
Radio<dynamic>(
Radio<T>(
value: radioValue,
groupValue: _groupValue,
onChanged: (_value) {
onChanged: (T? _value) {
setState(() {
_groupValue = _value;
});
if (null != widget.onChanged) {
widget.onChanged!(_value);
}
widget.onChanged!(_value);
},
),
],

View File

@ -22,6 +22,7 @@ dependencies:
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
x_common: ^1.0.4
# amap_map_extensions: ^0.0.1
# amap_map_extensions: