Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-App
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Reason Pun
2022-01-27 17:23:49 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e39b713530d42ad6be3ecf8b34e2ede316713e34
e39b7135
1 parent
95e2ca89
增加了发布临境位置定位逻辑
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
192 additions
and
18 deletions
lib/poem/page/poem_publish.dart
lib/poem/page/select_address_page.dart
lib/poem/poem_router.dart
pubspec.lock
pubspec.yaml
lib/poem/page/poem_publish.dart
View file @
e39b713
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_2d_amap/flutter_2d_amap.dart'
;
import
'package:one_poem/poem/provider/lang_sort_provider.dart'
;
import
'package:one_poem/poem/widgets/lang_sort_bottom_sheet.dart'
;
import
'package:one_poem/res/resources.dart'
;
...
...
@@ -23,7 +24,8 @@ class PoemPublish extends StatefulWidget {
class
_PoemPublishState
extends
State
<
PoemPublish
>
{
bool
isPublishing
=
false
;
String
_langSortName
=
"普通话"
;
int
_langSortId
=
1
;
int
_langSortId
=
1
;
//TODO 传入服务器的口音ID
String
_address
=
'我在此地'
;
final
LangSortProvider
_provider
=
LangSortProvider
();
@override
...
...
@@ -82,23 +84,35 @@ class _PoemPublishState extends State<PoemPublish> {
),
),
),
Container
(
padding:
EdgeInsets
.
all
(
10
.
px
),
alignment:
Alignment
.
centerLeft
,
width:
double
.
infinity
,
height:
36
.
px
,
child:
Wrap
(
children:
[
Icon
(
Icons
.
room_outlined
,
size:
15
.
px
,
),
Gaps
.
hGap5
,
const
Text
(
"我在此地"
,
style:
TextStyle
(
color:
Colors
.
black45
),
),
],
InkWell
(
onTap:
()
{
NavigatorUtils
.
pushResult
(
context
,
PoemRouter
.
addressSelectPage
,
(
result
)
{
setState
(()
{
final
PoiSearch
model
=
result
as
PoiSearch
;
_address
=
'
${model.provinceName!}
${model.cityName!}
${model.adName!}
${model.title!}
'
;
});
});
},
child:
Container
(
padding:
EdgeInsets
.
all
(
10
.
px
),
alignment:
Alignment
.
centerLeft
,
width:
double
.
infinity
,
height:
36
.
px
,
child:
Wrap
(
children:
[
Icon
(
Icons
.
room_outlined
,
size:
15
.
px
,
),
Gaps
.
hGap5
,
Text
(
_address
,
style:
const
TextStyle
(
color:
Colors
.
black45
),
),
],
),
),
),
InkWell
(
...
...
lib/poem/page/select_address_page.dart
0 → 100644
View file @
e39b713
import
'package:flutter/material.dart'
;
import
'package:flutter_2d_amap/flutter_2d_amap.dart'
;
import
'package:one_poem/routers/fluro_navigator.dart'
;
import
'package:one_poem/util/toast_utils.dart'
;
import
'package:one_poem/widgets/my_button.dart'
;
import
'package:one_poem/widgets/search_bar.dart'
;
class
AddressSelectPage
extends
StatefulWidget
{
const
AddressSelectPage
({
Key
?
key
})
:
super
(
key:
key
);
@override
_AddressSelectPageState
createState
()
=>
_AddressSelectPageState
();
}
class
_AddressSelectPageState
extends
State
<
AddressSelectPage
>
{
List
<
PoiSearch
>
_list
=
[];
int
_index
=
0
;
final
ScrollController
_controller
=
ScrollController
();
AMap2DController
?
_aMap2DController
;
@override
void
dispose
()
{
_controller
.
dispose
();
super
.
dispose
();
}
@override
void
initState
()
{
super
.
initState
();
// TODO 需要根据项目单独设置keys
Flutter2dAMap
.
setApiKey
(
iOSKey:
'4327916279bf45a044bb53b947442387'
,
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
resizeToAvoidBottomInset:
false
,
appBar:
SearchBar
(
hintText:
'搜索地址'
,
onPressed:
(
text
)
{
_controller
.
animateTo
(
0.0
,
duration:
const
Duration
(
milliseconds:
10
),
curve:
Curves
.
ease
);
_index
=
0
;
_aMap2DController
?.
search
(
text
);
},
),
body:
SafeArea
(
child:
Column
(
children:
<
Widget
>[
Expanded
(
flex:
9
,
child:
AMap2DView
(
onPoiSearched:
(
result
)
{
_controller
.
animateTo
(
0.0
,
duration:
const
Duration
(
milliseconds:
10
),
curve:
Curves
.
ease
);
_index
=
0
;
_list
=
result
;
setState
(()
{});
},
onAMap2DViewCreated:
(
controller
)
{
_aMap2DController
=
controller
;
},
),
),
Expanded
(
flex:
11
,
child:
ListView
.
separated
(
controller:
_controller
,
itemCount:
_list
.
length
,
separatorBuilder:
(
_
,
index
)
=>
const
Divider
(),
itemBuilder:
(
_
,
index
)
{
return
_AddressItem
(
isSelected:
_index
==
index
,
date:
_list
[
index
],
onTap:
()
{
_index
=
index
;
_aMap2DController
?.
move
(
_list
[
index
].
latitude
!,
_list
[
index
].
longitude
!);
setState
(()
{});
},
);
},
),
),
MyButton
(
onPressed:
()
{
if
(
_list
.
isEmpty
)
{
Toast
.
show
(
'未选择地址!'
);
return
;
}
NavigatorUtils
.
goBackWithParams
(
context
,
_list
[
_index
]);
},
text:
'确认选择地址'
,
)
],
),
),
);
}
}
class
_AddressItem
extends
StatelessWidget
{
const
_AddressItem
({
Key
?
key
,
required
this
.
date
,
this
.
isSelected
=
false
,
this
.
onTap
,
})
:
super
(
key:
key
);
final
PoiSearch
date
;
final
bool
isSelected
;
final
GestureTapCallback
?
onTap
;
@override
Widget
build
(
BuildContext
context
)
{
return
InkWell
(
onTap:
onTap
,
child:
Container
(
alignment:
Alignment
.
centerLeft
,
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
),
height:
50.0
,
child:
Row
(
children:
<
Widget
>[
Expanded
(
child:
Text
(
'
${date.provinceName!}
${date.cityName!}
${date.adName!}
${date.title!}
'
,
),
),
Visibility
(
visible:
isSelected
,
child:
const
Icon
(
Icons
.
done
,
color:
Colors
.
blue
),
)
],
),
),
);
}
}
lib/poem/poem_router.dart
View file @
e39b713
...
...
@@ -8,6 +8,7 @@ import 'page/poem_page.dart';
import
'page/poem_publish.dart'
;
import
'page/poem_record_video.dart'
;
import
'page/poem_video_player.dart'
;
import
'page/select_address_page.dart'
;
class
PoemRouter
implements
IRouterProvider
{
static
String
poemPage
=
'/poem'
;
...
...
@@ -18,6 +19,7 @@ class PoemRouter implements IRouterProvider {
static
String
poemPublish
=
'/poem/publish'
;
static
String
poemCompletePage
=
'/poem/complete'
;
static
String
poemSearchPage
=
'/poem/search'
;
static
String
addressSelectPage
=
'/poem/address/select'
;
@override
void
initRouter
(
FluroRouter
router
)
{
...
...
@@ -28,6 +30,9 @@ class PoemRouter implements IRouterProvider {
),
);
router
.
define
(
addressSelectPage
,
handler:
Handler
(
handlerFunc:
(
_
,
__
)
=>
const
AddressSelectPage
()));
router
.
define
(
poemDetailPage
,
handler:
Handler
(
...
...
pubspec.lock
View file @
e39b713
...
...
@@ -356,6 +356,15 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_2d_amap:
dependency: "direct main"
description:
path: "."
ref: "597a0538"
resolved-ref: "597a05386700e1cf854ad9b56fe21b103c669f62"
url: "https://github.com/simplezhli/flutter_2d_amap.git"
source: git
version: "0.2.0+2"
flutter_blurhash:
dependency: transitive
description:
...
...
pubspec.yaml
View file @
e39b713
...
...
@@ -80,6 +80,11 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons
:
^1.0.2
# 高德2D地图插件(支持Web) https://github.com/simplezhli/flutter_2d_amap
flutter_2d_amap
:
git
:
ref
:
'
597a0538'
url
:
'
https://github.com/simplezhli/flutter_2d_amap.git'
# tiktok
video_player
:
^2.2.10
...
...
Please
register
or
login
to post a comment