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
2022-07-21 21:43:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5de7928553e4783c358f9e21c61328ea1116eded
5de79285
1 parent
6b1af878
增加了收藏接口
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
259 additions
and
46 deletions
lib/account/models/collect_entity.dart
lib/account/page/account_page.dart
lib/generated/json/base/json_convert_content.dart
lib/generated/json/collect_entity.g.dart
lib/generated/json/poem_entity.g.dart
pubspec.yaml
lib/account/models/collect_entity.dart
0 → 100644
View file @
5de7928
import
'package:Parlando/generated/json/base/json_field.dart'
;
import
'package:Parlando/generated/json/collect_entity.g.dart'
;
import
'dart:convert'
;
@JsonSerializable
()
class
CollectEntity
{
String
?
status
;
int
?
code
;
String
?
message
;
List
<
CollectData
>?
data
;
CollectError
?
error
;
CollectEntity
();
factory
CollectEntity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
$CollectEntityFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
$CollectEntityToJson
(
this
);
@override
String
toString
()
{
return
jsonEncode
(
this
);
}
}
@JsonSerializable
()
class
CollectData
{
@JSONField
(
name:
"user_id"
)
int
?
userId
;
@JSONField
(
name:
"immerse_id"
)
int
?
immerseId
;
String
?
content
;
String
?
thumbnail
;
String
?
url
;
int
?
type
;
@JSONField
(
name:
"is_praise"
)
bool
?
isPraise
;
@JSONField
(
name:
"is_collect"
)
bool
?
isCollect
;
CollectData
();
factory
CollectData
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
$CollectDataFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
$CollectDataToJson
(
this
);
@override
String
toString
()
{
return
jsonEncode
(
this
);
}
}
@JsonSerializable
()
class
CollectError
{
CollectError
();
factory
CollectError
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
$CollectErrorFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
$CollectErrorToJson
(
this
);
@override
String
toString
()
{
return
jsonEncode
(
this
);
}
}
lib/account/page/account_page.dart
View file @
5de7928
import
'package:Parlando/account/models/collect_entity.dart'
;
import
'package:Parlando/account/models/my_videos_entity.dart'
;
import
'package:Parlando/account/models/user_entity.dart'
;
import
'package:Parlando/account/view_models/account_view_model.dart'
;
...
...
@@ -44,6 +45,7 @@ class AccountPage extends StatefulWidget {
class
AccountPageState
extends
State
<
AccountPage
>
{
bool
isLoadMyVideos
=
false
;
List
<
Widget
>
videos
=
<
Widget
>[];
int
cate
=
0
;
@override
void
initState
()
{
...
...
@@ -54,32 +56,60 @@ class AccountPageState extends State<AccountPage> {
.
setSelectedAccount
(
null
);
Provider
.
of
<
AccountViewProvider
>(
context
,
listen:
false
)
.
fetchAccountData
(
'0'
);
isLoadMyVideos
=
true
;
// 加载作品
DioUtils
.
instance
.
asyncRequestNetwork
<
MyVideosEntity
>(
Method
.
get
,
HttpApi
.
myVideos
,
params:
[],
onSuccess:
(
data
)
{
for
(
MyVideosData
each
in
data
!.
data
!)
{
videos
.
add
(
_SmallVideo
(
url:
each
.
thumbnail
!,
id:
each
.
id
!,
));
}
isLoadMyVideos
=
false
;
setState
(()
{});
},
onError:
(
code
,
msg
)
{
isLoadMyVideos
=
false
;
},
);
_fetchMyVideos
();
}
else
{
NavigatorUtils
.
push
(
context
,
LoginRouter
.
loginPage
,
replace:
true
);
}
}
void
_fetchCollect
()
{
videos
.
clear
();
isLoadMyVideos
=
true
;
// 加载作品
DioUtils
.
instance
.
asyncRequestNetwork
<
CollectEntity
>(
Method
.
get
,
HttpApi
.
collect
,
params:
[],
onSuccess:
(
data
)
{
for
(
CollectData
each
in
data
!.
data
!)
{
videos
.
add
(
_SmallVideo
(
url:
each
.
thumbnail
!,
id:
each
.
immerseId
!,
));
}
isLoadMyVideos
=
false
;
setState
(()
{});
},
onError:
(
code
,
msg
)
{
isLoadMyVideos
=
false
;
},
);
}
void
_fetchMyVideos
()
{
videos
.
clear
();
isLoadMyVideos
=
true
;
// 加载作品
DioUtils
.
instance
.
asyncRequestNetwork
<
MyVideosEntity
>(
Method
.
get
,
HttpApi
.
myVideos
,
params:
[],
onSuccess:
(
data
)
{
for
(
MyVideosData
each
in
data
!.
data
!)
{
videos
.
add
(
_SmallVideo
(
url:
each
.
thumbnail
!,
id:
each
.
id
!,
));
}
isLoadMyVideos
=
false
;
setState
(()
{});
},
onError:
(
code
,
msg
)
{
isLoadMyVideos
=
false
;
},
);
}
@override
Widget
build
(
BuildContext
context
)
{
ApiResponse
apiResponse
=
...
...
@@ -130,7 +160,7 @@ class AccountPageState extends State<AccountPage> {
child:
CachedNetworkImage
(
fit:
BoxFit
.
cover
,
placeholder:
(
context
,
url
)
=>
const
CircularProgressIndicator
(),
const
CircularProgressIndicator
(),
errorWidget:
(
context
,
url
,
error
)
=>
const
Icon
(
Icons
.
error
),
imageUrl:
user
.
avatar
!,
),
...
...
@@ -227,30 +257,28 @@ class AccountPageState extends State<AccountPage> {
Container
(
color:
ColorPlate
.
white
,
padding:
EdgeInsets
.
symmetric
(
horizontal:
8
.
px
,
horizontal:
2
.
px
,
vertical:
2
.
px
,
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
const
<
Widget
>[
TextGroup
(
'356'
,
'关注'
),
TextGroup
(
'145万'
,
'粉丝'
),
TextGroup
(
'1423万'
,
'获赞'
),
children:
<
Widget
>[
TextButton
(
onPressed:
()
{
_fetchMyVideos
();
setState
(()
{});
},
child:
const
Text
(
"作品"
)),
TextButton
(
onPressed:
()
{
_fetchCollect
();
setState
(()
{});
},
child:
const
Text
(
"收藏"
)),
],
),
),
Container
(
height:
10
.
px
,
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
12
),
decoration:
BoxDecoration
(
border:
Border
(
bottom:
BorderSide
(
color:
Colors
.
white
.
withOpacity
(
0.1
),
),
),
),
),
SizedBox
(
width:
double
.
infinity
,
height:
500
,
...
...
@@ -433,12 +461,11 @@ class TextGroup extends StatelessWidget {
final
String
title
,
tag
;
final
Color
?
color
;
const
TextGroup
(
this
.
title
,
this
.
tag
,
{
Key
?
key
,
this
.
color
,
})
:
super
(
key:
key
);
const
TextGroup
(
this
.
title
,
this
.
tag
,
{
Key
?
key
,
this
.
color
,
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
lib/generated/json/base/json_convert_content.dart
View file @
5de7928
...
...
@@ -4,6 +4,7 @@
// This file is automatically generated. DO NOT EDIT, all your changes would be lost.
import
'package:flutter/material.dart'
show
debugPrint
;
import
'package:Parlando/account/models/collect_entity.dart'
;
import
'package:Parlando/account/models/my_videos_entity.dart'
;
import
'package:Parlando/account/models/upload_avatar_entity.dart'
;
import
'package:Parlando/account/models/user_entity.dart'
;
...
...
@@ -27,6 +28,9 @@ typedef JsonConvertFunction<T> = T Function(Map<String, dynamic> json);
class
JsonConvert
{
static
final
Map
<
String
,
JsonConvertFunction
>
_convertFuncMap
=
{
(
CollectEntity
).
toString
():
CollectEntity
.
fromJson
,
(
CollectData
).
toString
():
CollectData
.
fromJson
,
(
CollectError
).
toString
():
CollectError
.
fromJson
,
(
MyVideosEntity
).
toString
():
MyVideosEntity
.
fromJson
,
(
MyVideosData
).
toString
():
MyVideosData
.
fromJson
,
(
MyVideosError
).
toString
():
MyVideosError
.
fromJson
,
...
...
@@ -161,6 +165,23 @@ class JsonConvert {
//list is returned by type
static
M
?
_getListChildType
<
M
>(
List
<
Map
<
String
,
dynamic
>>
data
)
{
if
(<
CollectEntity
>[]
is
M
)
{
return
data
.
map
<
CollectEntity
>(
(
Map
<
String
,
dynamic
>
e
)
=>
CollectEntity
.
fromJson
(
e
))
.
toList
()
as
M
;
}
if
(<
CollectData
>[]
is
M
)
{
return
data
.
map
<
CollectData
>((
Map
<
String
,
dynamic
>
e
)
=>
CollectData
.
fromJson
(
e
))
.
toList
()
as
M
;
}
if
(<
CollectError
>[]
is
M
)
{
return
data
.
map
<
CollectError
>(
(
Map
<
String
,
dynamic
>
e
)
=>
CollectError
.
fromJson
(
e
))
.
toList
()
as
M
;
}
if
(<
MyVideosEntity
>[]
is
M
)
{
return
data
.
map
<
MyVideosEntity
>(
...
...
lib/generated/json/collect_entity.g.dart
0 → 100644
View file @
5de7928
import
'package:Parlando/generated/json/base/json_convert_content.dart'
;
import
'package:Parlando/account/models/collect_entity.dart'
;
CollectEntity
$CollectEntityFromJson
(
Map
<
String
,
dynamic
>
json
)
{
final
CollectEntity
collectEntity
=
CollectEntity
();
final
String
?
status
=
jsonConvert
.
convert
<
String
>(
json
[
'status'
]);
if
(
status
!=
null
)
{
collectEntity
.
status
=
status
;
}
final
int
?
code
=
jsonConvert
.
convert
<
int
>(
json
[
'code'
]);
if
(
code
!=
null
)
{
collectEntity
.
code
=
code
;
}
final
String
?
message
=
jsonConvert
.
convert
<
String
>(
json
[
'message'
]);
if
(
message
!=
null
)
{
collectEntity
.
message
=
message
;
}
final
List
<
CollectData
>?
data
=
jsonConvert
.
convertListNotNull
<
CollectData
>(
json
[
'data'
]);
if
(
data
!=
null
)
{
collectEntity
.
data
=
data
;
}
final
CollectError
?
error
=
jsonConvert
.
convert
<
CollectError
>(
json
[
'error'
]);
if
(
error
!=
null
)
{
collectEntity
.
error
=
error
;
}
return
collectEntity
;
}
Map
<
String
,
dynamic
>
$CollectEntityToJson
(
CollectEntity
entity
)
{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{};
data
[
'status'
]
=
entity
.
status
;
data
[
'code'
]
=
entity
.
code
;
data
[
'message'
]
=
entity
.
message
;
data
[
'data'
]
=
entity
.
data
?.
map
((
v
)
=>
v
.
toJson
()).
toList
();
data
[
'error'
]
=
entity
.
error
?.
toJson
();
return
data
;
}
CollectData
$CollectDataFromJson
(
Map
<
String
,
dynamic
>
json
)
{
final
CollectData
collectData
=
CollectData
();
final
int
?
userId
=
jsonConvert
.
convert
<
int
>(
json
[
'user_id'
]);
if
(
userId
!=
null
)
{
collectData
.
userId
=
userId
;
}
final
int
?
immerseId
=
jsonConvert
.
convert
<
int
>(
json
[
'immerse_id'
]);
if
(
immerseId
!=
null
)
{
collectData
.
immerseId
=
immerseId
;
}
final
String
?
content
=
jsonConvert
.
convert
<
String
>(
json
[
'content'
]);
if
(
content
!=
null
)
{
collectData
.
content
=
content
;
}
final
String
?
thumbnail
=
jsonConvert
.
convert
<
String
>(
json
[
'thumbnail'
]);
if
(
thumbnail
!=
null
)
{
collectData
.
thumbnail
=
thumbnail
;
}
final
String
?
url
=
jsonConvert
.
convert
<
String
>(
json
[
'url'
]);
if
(
url
!=
null
)
{
collectData
.
url
=
url
;
}
final
int
?
type
=
jsonConvert
.
convert
<
int
>(
json
[
'type'
]);
if
(
type
!=
null
)
{
collectData
.
type
=
type
;
}
final
bool
?
isPraise
=
jsonConvert
.
convert
<
bool
>(
json
[
'is_praise'
]);
if
(
isPraise
!=
null
)
{
collectData
.
isPraise
=
isPraise
;
}
final
bool
?
isCollect
=
jsonConvert
.
convert
<
bool
>(
json
[
'is_collect'
]);
if
(
isCollect
!=
null
)
{
collectData
.
isCollect
=
isCollect
;
}
return
collectData
;
}
Map
<
String
,
dynamic
>
$CollectDataToJson
(
CollectData
entity
)
{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{};
data
[
'user_id'
]
=
entity
.
userId
;
data
[
'immerse_id'
]
=
entity
.
immerseId
;
data
[
'content'
]
=
entity
.
content
;
data
[
'thumbnail'
]
=
entity
.
thumbnail
;
data
[
'url'
]
=
entity
.
url
;
data
[
'type'
]
=
entity
.
type
;
data
[
'is_praise'
]
=
entity
.
isPraise
;
data
[
'is_collect'
]
=
entity
.
isCollect
;
return
data
;
}
CollectError
$CollectErrorFromJson
(
Map
<
String
,
dynamic
>
json
)
{
final
CollectError
collectError
=
CollectError
();
return
collectError
;
}
Map
<
String
,
dynamic
>
$CollectErrorToJson
(
CollectError
entity
)
{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{};
return
data
;
}
lib/generated/json/poem_entity.g.dart
View file @
5de7928
...
...
@@ -104,4 +104,4 @@ PoemError $PoemErrorFromJson(Map<String, dynamic> json) {
Map
<
String
,
dynamic
>
$PoemErrorToJson
(
PoemError
entity
)
{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{};
return
data
;
}
}
\ No newline at end of file
...
...
pubspec.yaml
View file @
5de7928
...
...
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version
:
1.0.0+
8
version
:
1.0.0+
10
environment
:
sdk
:
"
>=2.16.2
<3.0.0"
...
...
Please
register
or
login
to post a comment