hyzp_ybqx-Commit186:已经基本实现在“点位地图”中添加“导航”功能,能够保存用户选择的默认导航地图
parent
67896aef90
commit
99cce09b19
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:map_launcher/map_launcher.dart';
|
||||
|
||||
class MapsSheet {
|
||||
static show({
|
||||
@required BuildContext context,
|
||||
@required Function(AvailableMap map) onMapTap,
|
||||
}) async {
|
||||
final availableMaps = await MapLauncher.installedMaps;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Wrap(
|
||||
children: <Widget>[
|
||||
for (var map in availableMaps)
|
||||
ListTile(
|
||||
onTap: () {
|
||||
print('map.mapName = ${map.mapName}');
|
||||
// map.mapName = Amap
|
||||
Navigator.pop(context);
|
||||
onMapTap(map);
|
||||
},
|
||||
title: Text(map.mapName),
|
||||
leading: SvgPicture.asset(
|
||||
map.icon,
|
||||
height: 30.0,
|
||||
width: 30.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,284 @@
|
||||
import 'package:badges/badges.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:hyzp_ybqx/pages/Login/FaceReg.dart';
|
||||
import 'package:hyzp_ybqx/pages/Login/ModifyPassword.dart';
|
||||
import 'package:hyzp_ybqx/services/Storage.dart';
|
||||
|
||||
import '../../components/commonFun.dart';
|
||||
import '../../widget/JdButton.dart';
|
||||
|
||||
class page8_defaultMap extends StatefulWidget {
|
||||
page8_defaultMap({Key key}) : super(key: key);
|
||||
|
||||
_LoginPageState createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<page8_defaultMap> {
|
||||
bool bSaveDefaultMap = false;
|
||||
String defaultMapName = '';
|
||||
|
||||
dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
init();
|
||||
}
|
||||
|
||||
void init() async {
|
||||
// 从磁盘读取变量
|
||||
// 是否保存默认地图
|
||||
g_bSaveDefaultMap = await Storage.getBool('bSaveDefaultMap');
|
||||
g_bSaveDefaultMap = (null == g_bSaveDefaultMap) ? false : g_bSaveDefaultMap; // 默认不保存
|
||||
// 用户选择的默认地图名称
|
||||
g_defaultMapName = await Storage.getString('defaultMapName');
|
||||
g_defaultMapName = (null == g_defaultMapName) ? '' : g_defaultMapName; // 默认为空字符串
|
||||
|
||||
bSaveDefaultMap = g_bSaveDefaultMap;
|
||||
// bSaveDefaultMap = false;
|
||||
// defaultMapName = g_defaultMapName;
|
||||
// defaultMapName = '高德地图';
|
||||
// defaultMapName = getMapChsName('amap');
|
||||
defaultMapName = getMapChsName(g_defaultMapName);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
////////
|
||||
static onNullFun() {}
|
||||
|
||||
Widget _getListTile(
|
||||
title, {
|
||||
String leadPath = '',
|
||||
Color leadColor,
|
||||
Color textColor,
|
||||
onTapFun = onNullFun,
|
||||
onLongPressFun = onNullFun,
|
||||
size = 16.0,
|
||||
bool bBadge = false,
|
||||
Widget trailWidget = const Icon(Icons.arrow_forward_ios),
|
||||
}) {
|
||||
// print("_getListTile bSaveDefaultMap = $bSaveDefaultMap "); // _getListTile bSaveDefaultMap = false
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
leading: bBadge
|
||||
? Badge(
|
||||
position: BadgePosition.topEnd(top: -7, end: -12),
|
||||
badgeContent: null,
|
||||
child: Image.asset(
|
||||
leadPath,
|
||||
height: ScreenUtil().setHeight(78),
|
||||
fit: BoxFit.fitHeight,
|
||||
// color: leadColor, // 无效
|
||||
),
|
||||
)
|
||||
: Image.asset(
|
||||
leadPath,
|
||||
height: ScreenUtil().setHeight(78),
|
||||
fit: BoxFit.fitHeight,
|
||||
),
|
||||
title: Text(title, style: TextStyle(fontSize: size, color: textColor)),
|
||||
trailing: trailWidget,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 0),
|
||||
enabled: true,
|
||||
onTap: onTapFun,
|
||||
onLongPress: onLongPressFun,
|
||||
),
|
||||
Divider(
|
||||
height: 1.0,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _listViewUser = [];
|
||||
|
||||
Color _greenColor = Color.fromRGBO(36, 206, 192, 1); //绿色
|
||||
Color _deepBlueColor = Color.fromRGBO(79, 118, 230, 1); //深蓝
|
||||
Color _deepGreyColor = Color.fromRGBO(116, 139, 161, 1); //深灰
|
||||
Color _ligthBlueColor = Color.fromRGBO(80, 159, 245, 1); //亮蓝
|
||||
|
||||
OnTap_FaceReg() async {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => FaceReg()));
|
||||
}
|
||||
|
||||
OnTap_modify_password() {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => ModifyPassword()));
|
||||
}
|
||||
|
||||
OnTap_Remind() {
|
||||
setState(() {
|
||||
bSaveDefaultMap = !bSaveDefaultMap;
|
||||
print("bSaveDefaultMap = $bSaveDefaultMap");
|
||||
});
|
||||
}
|
||||
|
||||
Widget getTextField() {
|
||||
return Container(
|
||||
width: ScreenUtil().setWidth(400),
|
||||
child: TextField(
|
||||
readOnly: !bSaveDefaultMap,
|
||||
focusNode: FocusNode(),
|
||||
textAlignVertical: TextAlignVertical(y: 1.0),
|
||||
controller: TextEditingController.fromValue(TextEditingValue(
|
||||
text: defaultMapName.toString(),
|
||||
// 保持光标在最后
|
||||
selection: TextSelection.fromPosition(TextPosition(
|
||||
affinity: TextAffinity.downstream, offset: defaultMapName.toString().length)))),
|
||||
maxLines: 1,
|
||||
keyboardType: TextInputType.text,
|
||||
decoration: InputDecoration(
|
||||
//contentPadding: EdgeInsets.only(bottom: 16),
|
||||
// hintText: widget.text,
|
||||
// border: OutlineInputBorder(
|
||||
// borderRadius: BorderRadius.circular(30), borderSide: BorderSide.none),
|
||||
border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.lightBlue)),
|
||||
focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.lightBlue)),
|
||||
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.lightBlue)),
|
||||
),
|
||||
onChanged: (v) {
|
||||
defaultMapName = v;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getText(String text) {
|
||||
return Container(
|
||||
child: Text(text,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.blueAccent,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
////////
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(ScreenUtil().setHeight(173)), // 设置appBar高度
|
||||
// 设置appBar高度
|
||||
child: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
centerTitle: true,
|
||||
titleSpacing: 0.0,
|
||||
//设置title的左边距
|
||||
flexibleSpace: Container(
|
||||
//SizedBox(height: ScreenUtil().statusBarHeight), //显示顶部状态栏
|
||||
// SizedBox(height: ScreenUtil().setHeight(10)), //显示顶部状态栏
|
||||
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight), //留出顶部状态栏高度
|
||||
child: Container(
|
||||
//height: ScreenUtil().setHeight(173),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
Color.fromRGBO(12, 186, 156, 1),
|
||||
Color.fromRGBO(39, 127, 235, 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
// decoration: BoxDecoration(
|
||||
// gradient: LinearGradient(colors: [
|
||||
// Color(0xFF0018EB),
|
||||
// Color(0xFF01C1D9),
|
||||
// ], begin: Alignment.bottomCenter, end: Alignment.topCenter),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 0, right: 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
getIconAndTextButton(
|
||||
iconColor: Colors.white,
|
||||
iconData: Icons.chevron_left_outlined,
|
||||
onPress: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Text("默认导航设置",
|
||||
style: TextStyle(color: Colors.white, fontSize: 20),
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
SizedBox(width: 50),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
padding: EdgeInsets.only(top: 30, bottom: 20, left: 20, right: 20),
|
||||
child: ListView(
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 30),
|
||||
height: ScreenUtil().setWidth(160),
|
||||
width: ScreenUtil().setWidth(160),
|
||||
//child: Image.asset('assets/images/user.png', fit: BoxFit.cover),
|
||||
child: Image.asset('assets/images/ybsthbj.png', fit: BoxFit.fitHeight),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 50),
|
||||
_getListTile('保存默认导航地图',
|
||||
leadPath: 'assets/images/地图选中.png',
|
||||
leadColor: _deepGreyColor,
|
||||
// textColor: bSaveDefaultMap ? Colors.blue : null,
|
||||
onTapFun: OnTap_Remind,
|
||||
trailWidget: bSaveDefaultMap
|
||||
? Icon(Icons.check_box, color: Colors.blue)
|
||||
: Icon(Icons.check_box_outline_blank, color: Colors.blueAccent)),
|
||||
_getListTile('已选默认导航地图:',
|
||||
leadPath: 'assets/images/用户选择.png',
|
||||
leadColor: _deepBlueColor,
|
||||
trailWidget: getText(defaultMapName)),
|
||||
SizedBox(height: 60),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
JdButton(
|
||||
height: 128,
|
||||
width: 282,
|
||||
//height: 126,
|
||||
text: "确认",
|
||||
color: Colors.blueAccent,
|
||||
onTop: () async {
|
||||
g_bSaveDefaultMap = bSaveDefaultMap;
|
||||
await Storage.setBool('bSaveDefaultMap', g_bSaveDefaultMap);
|
||||
if (!g_bSaveDefaultMap) {
|
||||
await Storage.setString('defaultMapName', '');
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
JdButton(
|
||||
height: 128,
|
||||
width: 282,
|
||||
//height: 126,
|
||||
text: "取消",
|
||||
color: Colors.blueAccent,
|
||||
onTop: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue