Skip to content

Commit

Permalink
发布页面保存位置
Browse files Browse the repository at this point in the history
  • Loading branch information
ningyuwen committed May 6, 2019
1 parent de27407 commit b21ac89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 0 additions & 6 deletions lib/provider/fragment_friend_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ class FragmentFriendProvider {
bool _convertMap(map, refresh) {
print(map);
if (map is List) {
if (_data != null && _data.length > 0) {
// print("data 0 id is: ${_data[0].id}");
}
List<Posts> posts = new List();
for (var value in map) {
Posts post = Posts.fromJson(value);
posts.add(post);
}
if (refresh) {
// print("post id is: ${posts[0].id}");
if (posts[0].id == _data[0].id) {
// print("下拉刷新的数据一样");
ToastUtil.showToast("暂无更多数据");
return false;
}
Expand All @@ -68,7 +63,6 @@ class FragmentFriendProvider {
}
return true;
} else {
// print("出现错误");
if (_firstLoad) {
_fetcher.sink.addError(map);
} else {
Expand Down
9 changes: 9 additions & 0 deletions lib/provider/publish_post_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:amap_location/amap_location.dart';
import 'package:image_picker/image_picker.dart';
import 'package:mmkv_flutter/mmkv_flutter.dart';
import 'package:my_mini_app/been/consume_post_been.dart';
import 'package:my_mini_app/util/api_util.dart';
import 'package:permission_handler/permission_handler.dart';
Expand Down Expand Up @@ -82,6 +83,7 @@ class PublishPostProvider {
publishBeen.latitude = location.latitude;
publishBeen.position = position;
publishBeen.district = location.district;
_saveMyLocation(location);
setPosition(position);
}

Expand All @@ -104,6 +106,13 @@ class PublishPostProvider {
}
}
}

void _saveMyLocation(AMapLocation location) async {
MmkvFlutter mmkv = await MmkvFlutter.getInstance(); //初始化mmkv
await mmkv.setDouble("myNowPositionLongitude", location.longitude);
await mmkv.setDouble("myNowPositionLatitude", location.latitude);
await mmkv.setBool("loadMapPagePresent", true); //以前是否打开过map page
}
}

class PublishBeen {
Expand Down
2 changes: 1 addition & 1 deletion lib/search/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class _SearchSuggestState extends State<_SearchSuggestWidget>
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"为您推荐以下分类:",
"热门分类:",
style: Theme.of(context).textTheme.title,
),
Divider(),
Expand Down

0 comments on commit b21ac89

Please sign in to comment.