Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ChatGPT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
关振斌
ChatGPT
Commits
67118e06
Commit
67118e06
authored
Jul 14, 2023
by
netyouli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加广场图片接口,我的收藏,我的作品,收藏列表,作品列表,发布广场等接口集成
parent
8bd02cb4
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
534 additions
and
161 deletions
+534
-161
lib/common/apis/news.dart
lib/common/apis/news.dart
+18
-0
lib/common/apis/user.dart
lib/common/apis/user.dart
+22
-0
lib/common/values/server.dart
lib/common/values/server.dart
+3
-2
lib/pages/ai-draw-image-result/controller.dart
lib/pages/ai-draw-image-result/controller.dart
+85
-17
lib/pages/ai-draw-image-result/model.dart
lib/pages/ai-draw-image-result/model.dart
+28
-0
lib/pages/ai-draw-image-result/view.dart
lib/pages/ai-draw-image-result/view.dart
+41
-11
lib/pages/ai-draw-image/controller.dart
lib/pages/ai-draw-image/controller.dart
+40
-2
lib/pages/ai-draw-image/image_square_list_view.dart
lib/pages/ai-draw-image/image_square_list_view.dart
+38
-44
lib/pages/ai-draw-image/image_square_view.dart
lib/pages/ai-draw-image/image_square_view.dart
+1
-0
lib/pages/ai-draw-image/view.dart
lib/pages/ai-draw-image/view.dart
+5
-0
lib/pages/my-work/controller.dart
lib/pages/my-work/controller.dart
+97
-2
lib/pages/my-work/models.dart
lib/pages/my-work/models.dart
+78
-0
lib/pages/my-work/view.dart
lib/pages/my-work/view.dart
+51
-57
lib/pages/my/controller.dart
lib/pages/my/controller.dart
+1
-12
lib/pages/my/models.dart
lib/pages/my/models.dart
+9
-1
lib/pages/my/view.dart
lib/pages/my/view.dart
+17
-13
No files found.
lib/common/apis/news.dart
View file @
67118e06
...
...
@@ -12,6 +12,7 @@ import 'package:dio/dio.dart';
import
'../../entity/plan_entity.dart'
;
import
'../../entity/square_entity.dart'
;
import
'../../pages/ai-draw-image-result/model.dart'
;
import
'../store/user.dart'
;
/// 新闻
class
NewsAPI
{
...
...
@@ -88,6 +89,23 @@ class NewsAPI {
);
return
TranslateModel
.
fromJson
(
response
.
data
);
}
static
Future
<
CommonResponse
>
shareImageSquare
(
String
imgId
)
async
{
var
response
=
await
HttpUtil
().
get
(
'/imgInfo/shareSquare/
$imgId
'
,
);
return
CommonResponse
.
fromJson
(
response
);
}
// 收藏图片
static
Future
<
CommonResponse
>
updateCollectImg
(
String
imgUrl
,
int
isCancel
)
async
{
var
response
=
await
HttpUtil
().
post
(
'/midJourney/createImageByBlend'
,
data:
{
"imgUrl"
:
imgUrl
,
"isCancel"
:
isCancel
,
"userId"
:
"
${UserStore.to.profile.id}
"
});
return
CommonResponse
.
fromJson
(
response
);
}
// 融合图片
static
Future
<
MidJourneyModel
>
blendImageByMidJourney
(
List
<
String
>
urls
)
async
{
...
...
lib/common/apis/user.dart
View file @
67118e06
...
...
@@ -6,6 +6,7 @@ import 'package:chart/common/utils/utils.dart';
import
'../../entity/login_entity.dart'
;
import
'../../entity/user_entity.dart'
;
import
'../../pages/my-work/models.dart'
;
import
'../../pages/my/models.dart'
;
import
'../entities/applePayList.dart'
;
...
...
@@ -239,6 +240,27 @@ class UserAPI {
// UserLoginResponseEntity.fromJson(response);
}
static
Future
<
MyWorkResponse
>
getMyWorkImages
()
async
{
var
response
=
await
HttpUtil
().
get
(
'/imgInfo/getImgInfoList'
,
);
return
MyWorkResponse
.
fromJson
(
response
);
}
static
Future
<
MyWorkResponse
>
getMyCollectImages
()
async
{
var
response
=
await
HttpUtil
().
get
(
'/imgInfo/getCollectImg'
,
);
return
MyWorkResponse
.
fromJson
(
response
);
}
static
Future
<
MyWorkResponse
>
getSquareImages
()
async
{
var
response
=
await
HttpUtil
().
get
(
'/imgInfo/squareImgList'
,
);
return
MyWorkResponse
.
fromJson
(
response
);
}
// /api/user/info
static
Future
<
MsmEntity
>
sendSms
(
Map
<
String
,
dynamic
>?
params
,
...
...
lib/common/values/server.dart
View file @
67118e06
// baidu yapi
// const SERVER_API_URL = 'https://yapi.baidu.com/mock/41008';
const
SERVER_API_URL
=
'http://101.34.153.228:8083/api'
;
//线上
// const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
// const SERVER_API_URL = 'http://192.168.110.116:8083/api';//内
// const SERVER_API_URL = 'http://192.168.110.12:8083/api';//线上
//http://192.168.110.12:8083/api/doc.html
...
...
@@ -11,7 +12,7 @@ const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
// http://192.168.110.66:8083/api/doc.html
// const SERVER_API_URL = 'http://192.168.110.23:8083/api'; // 大黄蜂
// const SERVER_API_URL = 'http://192.168.110.116
:8083/api'; // 清
const
SERVER_API_URL
=
'http://192.168.110.159
:8083/api'
;
// 清
// http://192.168.110.25:8083/
// const SERVER_API_URL = 'http://192.168.2.178:8083/api';
...
...
lib/pages/ai-draw-image-result/controller.dart
View file @
67118e06
...
...
@@ -21,6 +21,12 @@ import '../../common/store/user.dart';
import
'../../common/utils/http.dart'
;
import
'model.dart'
;
enum
OpearterType
{
textToImage
,
imageBlend
,
imageResult
}
class
AIDrawImageResultController
extends
GetxController
{
late
var
sseClient
;
...
...
@@ -30,10 +36,11 @@ class AIDrawImageResultController extends GetxController {
var
styleName
=
""
.
obs
;
var
text
=
""
.
obs
;
var
enText
=
""
;
var
resultImageUrl
=
""
.
obs
;
var
resultImageUrl
=
""
;
var
progress
=
0
.
obs
;
var
showProgressView
=
false
.
obs
;
var
loseTime
=
"0.0s"
.
obs
;
var
messageId
=
""
;
Rx
<
Uint8List
?>
imageData
=
Rx
<
Uint8List
?>(
null
);
Uint8List
?
placehoderImageData
;
...
...
@@ -41,7 +48,7 @@ class AIDrawImageResultController extends GetxController {
var
_buttonMessageId
=
""
;
Rx
<
List
<
String
>>
bottomButtonTitles
=
Rx
<
List
<
String
>>([]);
var
opearter
=
""
;
var
opearter
=
OpearterType
.
textToImage
;
var
imageUrls
=
List
.
generate
(
0
,
(
index
)
=>
""
);
Timer
?
_timer
;
...
...
@@ -58,6 +65,7 @@ class AIDrawImageResultController extends GetxController {
s
=
arguments
[
"s"
];
styleName
.
value
=
arguments
[
"styleName"
];
imageUrls
=
arguments
[
"imageUrls"
]
??
[];
messageId
=
arguments
[
"messageId"
]
??
""
;
}
@override
...
...
@@ -85,6 +93,38 @@ class AIDrawImageResultController extends GetxController {
}
}
void
shareToSquare
()
async
{
EasyLoading
.
show
(
status:
"分享到广场中..."
);
final
res
=
await
NewsAPI
.
shareImageSquare
(
messageId
);
EasyLoading
.
dismiss
();
if
(
res
.
status
==
401
)
{
EasyLoading
.
showInfo
(
'您还未登录,请登录后体验功能。'
);
Get
.
toNamed
(
AppRoutes
.
SIGN_IN
);
}
else
{
if
(
res
.
status
==
200
)
{
EasyLoading
.
showSuccess
(
"分享到广场成功"
);
}
else
{
EasyLoading
.
showError
(
res
.
message
??
""
);
}
}
}
void
doCollect
()
async
{
EasyLoading
.
show
(
status:
"收藏中..."
);
final
res
=
await
NewsAPI
.
updateCollectImg
(
resultImageUrl
,
1
);
EasyLoading
.
dismiss
();
if
(
res
.
status
==
401
)
{
EasyLoading
.
showInfo
(
'您还未登录,请登录后体验功能。'
);
Get
.
toNamed
(
AppRoutes
.
SIGN_IN
);
}
else
{
if
(
res
.
status
==
200
)
{
EasyLoading
.
showSuccess
(
"收藏成功"
);
}
else
{
EasyLoading
.
showError
(
res
.
message
??
""
);
}
}
}
void
startTimer
()
{
_timer
?.
cancel
();
const
oneSec
=
Duration
(
milliseconds:
10
);
...
...
@@ -95,7 +135,7 @@ class AIDrawImageResultController extends GetxController {
});
}
void
loadImage
(
String
imageUrl
,
int
progress
)
async
{
Future
<
void
>
loadImage
(
String
imageUrl
,
int
progress
)
async
{
final
imageData
=
await
HttpUtil
().
getData
(
imageUrl
);
if
(
imageData
!=
null
)
{
placehoderImageData
=
this
.
imageData
.
value
??
imageData
;
...
...
@@ -103,8 +143,10 @@ class AIDrawImageResultController extends GetxController {
if
(
progress
==
100
)
{
showProgressView
.
value
=
false
;
_timer
?.
cancel
();
EasyLoading
.
dismiss
();
}
}
return
;
}
// 点击v和u
...
...
@@ -131,11 +173,33 @@ class AIDrawImageResultController extends GetxController {
}
}
makeImage
()
{
if
(
opearter
==
"textToImage"
)
{
makeDrawImage
();
}
else
{
makeBlendImage
();
onClickMakeSame
()
{
switch
(
opearter
)
{
case
OpearterType
.
textToImage
:
case
OpearterType
.
imageResult
:
makeDrawImage
();
break
;
case
OpearterType
.
imageBlend
:
makeBlendImage
();
break
;
}
}
makeImage
()
async
{
switch
(
opearter
)
{
case
OpearterType
.
textToImage
:
makeDrawImage
();
break
;
case
OpearterType
.
imageBlend
:
makeBlendImage
();
break
;
case
OpearterType
.
imageResult
:
{
EasyLoading
.
show
(
status:
"正在加载中"
);
resultImageUrl
=
imageUrls
.
isNotEmpty
?
imageUrls
.
first
:
""
;
await
loadImage
(
resultImageUrl
,
100
);
}
break
;
default
:
}
}
...
...
@@ -171,12 +235,16 @@ class AIDrawImageResultController extends GetxController {
makeDrawImage
()
async
{
progress
.
value
=
0
;
final
imageUrl
=
imageUrls
.
first
;
var
question
=
""
;
if
(
imageUrl
.
isNotEmpty
)
{
question
=
'
$imageUrl
$enText
--iw 2 --ar
$ratio$s
'
;
if
(
opearter
==
OpearterType
.
imageResult
)
{
question
=
enText
;
}
else
{
question
=
'
$enText
--ar
$ratio$s
'
;
final
imageUrl
=
imageUrls
.
isNotEmpty
?
imageUrls
.
first
:
""
;
if
(
imageUrl
.
isNotEmpty
)
{
question
=
'
$imageUrl
$enText
--iw 2 --ar
$ratio$s
'
;
}
else
{
question
=
'
$enText
--ar
$ratio$s
'
;
}
}
Logger
.
debugPrint
(
"question =
$question
"
);
EasyLoading
.
show
(
status:
"AI正在生成中..."
);
...
...
@@ -236,21 +304,21 @@ class AIDrawImageResultController extends GetxController {
}
final
progressBase64
=
model
.
progressBase64
?.
replaceAll
(
"data:image/png;base64,"
,
""
)
??
""
;
if
(
model
.
response
?.
imageUrl
!=
null
)
{
resultImageUrl
.
value
=
model
.
response
?.
imageUrl
??
""
;
resultImageUrl
=
model
.
response
?.
imageUrl
??
""
;
}
else
if
(
model
.
progressImageUrl
!=
null
)
{
resultImageUrl
.
value
=
model
.
progressImageUrl
??
""
;
resultImageUrl
=
model
.
progressImageUrl
??
""
;
}
if
(
progressBase64
.
isNotEmpty
)
{
final
decode
=
base64Decode
(
progressBase64
.
replaceAll
(
'
\n
'
,
''
));
placehoderImageData
=
imageData
.
value
??
decode
;
imageData
.
value
=
decode
;
}
else
{
if
(
resultImageUrl
.
value
.
isNotEmpty
)
{
loadImage
(
resultImageUrl
.
value
,
model
.
progress
??
0
);
if
(
resultImageUrl
.
isNotEmpty
)
{
loadImage
(
resultImageUrl
,
model
.
progress
??
0
);
}
}
// final first = model.response?.buttons?.first ?? "";
bottomButtonTitles
.
value
=
model
.
response
?.
buttons
??
[];
messageId
=
model
.
response
?.
buttonMessageId
??
""
;
/*
if (first == "V1" || first == "U1") {
...
...
lib/pages/ai-draw-image-result/model.dart
View file @
67118e06
...
...
@@ -141,4 +141,32 @@ class TransResult {
data
[
'dst'
]
=
this
.
dst
;
return
data
;
}
}
class
CommonResponse
{
int
?
status
;
String
?
message
;
dynamic
data
;
int
?
timestamp
;
CommonResponse
({
this
.
status
,
this
.
message
,
this
.
data
,
this
.
timestamp
});
CommonResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
status
=
json
[
'status'
];
message
=
json
[
'message'
];
data
=
json
[
'data'
];
timestamp
=
json
[
'timestamp'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'status'
]
=
this
.
status
;
data
[
'message'
]
=
this
.
message
;
data
[
'data'
]
=
this
.
data
;
data
[
'timestamp'
]
=
this
.
timestamp
;
return
data
;
}
}
\ No newline at end of file
lib/pages/ai-draw-image-result/view.dart
View file @
67118e06
...
...
@@ -113,7 +113,45 @@ class AIDrawImageResultPage extends GetView<AIDrawImageResultController> {
elevation:
0
,
actions:
[
Container
(
padding:
EdgeInsets
.
fromLTRB
(
0
,
8
,
0
,
8
),
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
8
,
0
,
8
),
child:
InkWell
(
onTap:
()
{
controller
.
shareToSquare
();
},
child:
Container
(
width:
100
,
height:
40
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColor
.
primary
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
Text
(
"分享到广场"
)
),
),
),
SizedBox
(
width:
10
,),
Container
(
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
8
,
0
,
8
),
child:
InkWell
(
onTap:
()
{
controller
.
doCollect
();
},
child:
Container
(
width:
40
,
height:
40
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
color:
AppColor
.
primary
,
borderRadius:
BorderRadius
.
circular
(
20
),
),
child:
Text
(
"收藏"
)
),
),
),
SizedBox
(
width:
10
,),
Container
(
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
8
,
0
,
8
),
child:
InkWell
(
onTap:
()
{
controller
.
share
();
...
...
@@ -136,14 +174,6 @@ class AIDrawImageResultPage extends GetView<AIDrawImageResultController> {
),
body:
Obx
(()
{
return
Container
(
/*
decoration: BoxDecoration(
color: Colors.black,
image: DecorationImage(
image: NetworkImage(controller.imageUrl.value),
fit: BoxFit.cover,
),
),*/
child:
Stack
(
children:
[
makeImageView
(),
...
...
@@ -192,7 +222,7 @@ class AIDrawImageResultPage extends GetView<AIDrawImageResultController> {
children:
[
InkWell
(
onTap:
()
{
controller
.
saveNetworkImage
(
controller
.
resultImageUrl
.
value
);
controller
.
saveNetworkImage
(
controller
.
resultImageUrl
);
},
child:
Container
(
width:
150
,
...
...
@@ -208,7 +238,7 @@ class AIDrawImageResultPage extends GetView<AIDrawImageResultController> {
InkWell
(
onTap:
()
{
controller
.
makeImag
e
();
controller
.
onClickMakeSam
e
();
},
child:
Container
(
width:
150
,
...
...
lib/pages/ai-draw-image/controller.dart
View file @
67118e06
...
...
@@ -12,14 +12,18 @@ import 'package:get/get.dart';
import
'package:loading_animation_widget/loading_animation_widget.dart'
;
import
'package:pinput/pinput.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
import
'../../common/apis/user.dart'
;
import
'../../common/routers/names.dart'
;
import
'../ai-draw-image-result/controller.dart'
;
import
'../my-work/models.dart'
;
import
'model.dart'
;
class
AIDrawImageController
extends
GetxController
{
late
TabController
tabController
;
late
TabController
categoryController
;
ScrollController
textToImageController
=
ScrollController
(
initialScrollOffset:
0
);
var
model
=
AIDrawTextToImageModel
();
var
ratio
=
"9:16"
.
obs
;
...
...
@@ -61,6 +65,8 @@ class AIDrawImageController extends GetxController {
"热门"
,
"人物"
,
"动漫"
,
"设计"
,
"未来"
,
"风景"
,
"插画"
,
"场景"
,
"脑洞"
,
"其他"
];
var
squareImgaes
=
Rx
<
List
<
MyWorkData
>>([]);
var
textCount
=
0
.
obs
;
var
uploadBlendImageUrls
=
List
<
String
>.
generate
(
0
,
(
index
)
=>
""
);
var
uploadTextImageUrls
=
List
<
String
>.
generate
(
0
,
(
index
)
=>
""
);
...
...
@@ -89,6 +95,8 @@ class AIDrawImageController extends GetxController {
});
}
@override
void
onClose
()
{
// TODO: implement onClose
...
...
@@ -96,6 +104,18 @@ class AIDrawImageController extends GetxController {
}
onPullRefresh
(
RefreshController
refreshController
)
{
Future
.
delayed
(
Duration
(
seconds:
3
),
()
{
refreshController
.
refreshCompleted
();
});
}
onLoadMore
(
RefreshController
refreshController
)
{
Future
.
delayed
(
Duration
(
seconds:
3
),
()
{
refreshController
.
loadComplete
();
});
}
replaceIt
()
{
model
.
descriptives
.
shuffle
();
randomDescriptionItems
.
value
=
[];
...
...
@@ -119,6 +139,24 @@ class AIDrawImageController extends GetxController {
uploadTextImageUrls
.
clear
();
}
requestSquareImages
()
async
{
EasyLoading
.
show
(
status:
"正在加载广场图片"
,
dismissOnTap:
false
,
maskType:
EasyLoadingMaskType
.
none
,
indicator:
LoadingAnimationWidget
.
staggeredDotsWave
(
color:
Colors
.
white
,
size:
30
,
));
final
res
=
await
UserAPI
.
getSquareImages
();
EasyLoading
.
dismiss
();
if
(
res
.
status
==
200
)
{
squareImgaes
.
value
=
res
.
data
??
[];
}
else
{
EasyLoading
.
showError
(
res
.
message
??
"请求广场图片异常"
);
}
}
selectBlendImageUpload
(
ImageSource
source
)
async
{
List
<
XFile
>?
images
;
if
(
source
==
ImageSource
.
camera
)
{
...
...
@@ -219,7 +257,7 @@ class AIDrawImageController extends GetxController {
}
else
{
Get
.
toNamed
(
AppRoutes
.
AI_DRAW_IMAGE_RESULT_PAGE
,
arguments:
{
"opearter"
:
"imageToImage"
,
"opearter"
:
OpearterType
.
imageBlend
,
"conversionId"
:
conversionId
,
"imageUrls"
:
List
<
String
>.
from
(
uploadBlendImageUrls
),
"ratio"
:
ratio
.
value
,
...
...
@@ -253,7 +291,7 @@ class AIDrawImageController extends GetxController {
}
else
{
Get
.
toNamed
(
AppRoutes
.
AI_DRAW_IMAGE_RESULT_PAGE
,
arguments:
{
"opearter"
:
"textToImage"
,
"opearter"
:
OpearterType
.
textToImage
,
"conversionId"
:
conversionId
,
"imageUrls"
:
List
<
String
>.
from
(
uploadTextImageUrls
),
"enText"
:
transformModel
.
transResult
?.
first
.
dst
??
textController
.
text
,
...
...
lib/pages/ai-draw-image/image_square_list_view.dart
View file @
67118e06
import
'package:cached_network_image/cached_network_image.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:flutter_easyrefresh/easy_refresh.dart'
;
import
'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
import
'controller.dart'
;
class
ImageSquareListView
extends
StatelessWidget
{
late
ScrollController
loadingMoreController
=
ScrollController
(
initialScrollOffset:
0
);
late
EasyRefreshController
refreshController
=
EasyRefreshController
();
late
var
refreshController
=
RefreshController
();
@override
Widget
build
(
BuildContext
context
)
{
// TODO: implement build
final
controller
=
Get
.
find
<
AIDrawImageController
>();
return
Contain
er
(
child:
EasyRefresh
(
return
SmartRefresh
er
(
enablePullUp:
true
,
controller:
refreshController
,
header:
ClassicalHeader
(
bgColor:
Colors
.
white
,
textColor:
Colors
.
pink
,
infoColor:
Colors
.
pink
,
refreshReadyText:
'下拉刷新'
,
refreshingText:
'正在努力刷新'
,
refreshedText:
'加载完成'
,
showInfo:
true
,
infoText:
'正在加载中'
,
onRefresh:
()
=>
controller
.
onPullRefresh
(
refreshController
),
onLoading:
()
=>
controller
.
onLoadMore
(
refreshController
),
header:
const
ClassicHeader
(
releaseText:
"松开刷新"
,
refreshingText:
"刷新数据中"
,
completeText:
"刷新数据成功"
,
idleText:
"下拉刷新"
),
footer:
ClassicalFooter
(
bgColor:
Colors
.
white
,
textColor:
Colors
.
pink
,
infoColor:
Colors
.
pink
,
showInfo:
true
,
noMoreText:
'暂时没有更多了'
,
loadReadyText:
'上拉加载'
,
loadedText:
'加载完毕'
,
loadText:
'上拉加载更多'
,
loadingText:
'正在努力加载更多'
,
infoText:
'正在加载中'
,
footer:
const
ClassicFooter
(
loadingText:
"正在加载中..."
,
noDataText:
'没有更多数据啦'
),
child:
MasonryGridView
.
count
(
controller:
loadingMoreController
,
itemCount:
controller
.
randomDescriptionItems
.
length
,
child:
Obx
(()
=>
MasonryGridView
.
count
(
itemCount:
controller
.
squareImgaes
.
value
.
length
,
crossAxisCount:
2
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
10
),
child:
Image
(
image:
AssetImage
(
controller
.
randomDescriptionItems
[
index
].
imageUrl
),
fit:
BoxFit
.
fill
,
height:
index
%
2
==
0
?
260
:
200
,
),
);
borderRadius:
BorderRadius
.
circular
(
10
),
child:
CachedNetworkImage
(
fit:
BoxFit
.
cover
,
height:
index
%
2
==
0
?
260
:
200
,
imageUrl:
controller
.
squareImgaes
.
value
[
index
].
minioUrl
??
""
,
placeholder:
(
context
,
url
)
=>
Container
(
alignment:
Alignment
.
center
,
child:
const
SizedBox
(
width:
30
,
height:
30
,
child:
CircularProgressIndicator
(),
),
),
errorWidget:
(
context
,
url
,
error
)
=>
Container
(
alignment:
Alignment
.
center
,
child:
Text
(
error
.
toString
()),
),
)
);
},
mainAxisSpacing:
10.0
,
crossAxisSpacing:
10.0
,
),
onLoad:
()
async
{
print
(
'没有更多了.......'
);
},
onRefresh:
()
async
{
print
(
'下拉刷新~~~~'
);
},
),
);
))
);
}
}
\ No newline at end of file
lib/pages/ai-draw-image/image_square_view.dart
View file @
67118e06
...
...
@@ -80,6 +80,7 @@ Widget makeTabContentView() {
Widget
makeImageSquareView
(
)
{
final
controller
=
Get
.
find
<
AIDrawImageController
>();
return
ImageSquareListView
();
return
SwitchPageView
(
length:
controller
.
imageSquareTitles
.
length
,
buildCallback:
(
categoryController
)
{
...
...
lib/pages/ai-draw-image/view.dart
View file @
67118e06
...
...
@@ -109,6 +109,11 @@ class AIDrawImagePage extends GetView<AIDrawImageController> {
Get
.
focusScope
?.
unfocus
();
});
controller
.
tabController
=
tabController
;
tabController
.
addListener
(()
{
if
(
tabController
.
index
==
2
)
{
controller
.
requestSquareImages
();
}
});
return
Column
(
children:
[
makeTopTabView
(),
...
...
lib/pages/my-work/controller.dart
View file @
67118e06
...
...
@@ -4,18 +4,113 @@ import 'dart:io';
import
'package:chart/common/apis/apis.dart'
;
import
'package:chart/common/store/user.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_easyloading/flutter_easyloading.dart'
;
import
'package:flutter_easyrefresh/easy_refresh.dart'
;
import
'package:get/get.dart'
;
import
'package:highlight/languages/awk.dart'
;
import
'package:intl/intl.dart'
;
import
'package:loading_animation_widget/loading_animation_widget.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
import
'package:share_plus/share_plus.dart'
;
import
'package:in_app_review/in_app_review.dart'
;
import
'../../common/routers/names.dart'
;
import
'../ai-draw-image-result/controller.dart'
;
import
'../ai-draw-image/model.dart'
;
import
'models.dart'
;
class
MyWorkController
extends
GetxController
{
late
ScrollController
loadingMoreController
=
ScrollController
(
initialScrollOffset:
0
);
late
EasyRefreshController
refreshController
=
EasyRefreshController
();
late
var
refreshController
=
RefreshController
();
var
models
=
AIDrawTextToImageModel
();
var
images
=
Rx
<
List
<
MyWorkData
>>([]);
var
title
=
""
.
obs
;
@override
void
onInit
()
{
// TODO: implement onInit
super
.
onInit
();
final
arguments
=
Get
.
arguments
;
final
operator
=
arguments
[
"operator"
];
if
(
operator
==
"work"
)
{
title
.
value
=
"我的作品"
;
requestMyWorkImages
();
}
else
{
title
.
value
=
"我的收藏"
;
requestMyCollectImages
();
}
}
onClickImage
(
int
index
)
async
{
if
(
index
>=
0
&&
index
<
images
.
value
.
length
)
{
final
item
=
images
.
value
[
index
];
final
conversionId
=
await
UserAPI
.
createConversion
();
EasyLoading
.
dismiss
();
if
(
conversionId
==
401
)
{
EasyLoading
.
showInfo
(
'您还为登录,请登录后体验功能。'
);
Get
.
toNamed
(
AppRoutes
.
SIGN_IN
);
}
else
{
Get
.
toNamed
(
AppRoutes
.
AI_DRAW_IMAGE_RESULT_PAGE
,
arguments:
{
"opearter"
:
OpearterType
.
imageResult
,
"conversionId"
:
conversionId
,
"imageUrls"
:
[
item
.
minioUrl
??
""
],
"enText"
:
item
.
content
,
"text"
:
item
.
content
,
"ratio"
:
"16:9"
,
"s"
:
""
,
"styleName"
:
item
.
style
??
"通用风格"
,
"messageId"
:
item
.
messageId
??
""
});
}
}
}
requestMyWorkImages
()
async
{
EasyLoading
.
show
(
status:
"正在加载我的作品"
,
dismissOnTap:
false
,
maskType:
EasyLoadingMaskType
.
none
,
indicator:
LoadingAnimationWidget
.
staggeredDotsWave
(
color:
Colors
.
white
,
size:
30
,
));
final
res
=
await
UserAPI
.
getMyWorkImages
();
EasyLoading
.
dismiss
();
if
(
res
.
status
==
200
)
{
images
.
value
=
res
.
data
??
[];
}
else
{
EasyLoading
.
showError
(
res
.
message
??
"请求我的作品异常"
);
}
}
requestMyCollectImages
()
async
{
EasyLoading
.
show
(
status:
"正在加载我的收藏"
,
dismissOnTap:
false
,
maskType:
EasyLoadingMaskType
.
none
,
indicator:
LoadingAnimationWidget
.
staggeredDotsWave
(
color:
Colors
.
white
,
size:
30
,
));
final
res
=
await
UserAPI
.
getMyCollectImages
();
EasyLoading
.
dismiss
();
if
(
res
.
status
==
200
)
{
images
.
value
=
res
.
data
??
[];
}
else
{
EasyLoading
.
showError
(
res
.
message
??
"请求我的收藏异常"
);
}
}
onPullRefresh
()
{
Future
.
delayed
(
Duration
(
seconds:
3
),
()
{
refreshController
.
refreshCompleted
();
});
}
onLoadMore
()
{
Future
.
delayed
(
Duration
(
seconds:
3
),
()
{
refreshController
.
loadComplete
();
});
}
}
\ No newline at end of file
lib/pages/my-work/models.dart
0 → 100644
View file @
67118e06
class
MyWorkResponse
{
int
?
status
;
String
?
message
;
List
<
MyWorkData
>?
data
;
MyWorkResponse
({
this
.
status
,
this
.
message
,
this
.
data
});
MyWorkResponse
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
status
=
json
[
'status'
];
message
=
json
[
'message'
];
if
(
json
[
'data'
]
!=
null
)
{
data
=
[];
json
[
'data'
].
forEach
((
v
)
{
data
?.
add
(
new
MyWorkData
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'status'
]
=
this
.
status
;
data
[
'message'
]
=
this
.
message
;
if
(
this
.
data
!=
null
)
{
data
[
'data'
]
=
this
.
data
?.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
MyWorkData
{
int
?
id
;
int
?
userId
;
String
?
content
;
String
?
imageUrl
;
String
?
messageId
;
String
?
minioUrl
;
String
?
createTime
;
dynamic
style
;
int
?
showSquare
;
MyWorkData
(
{
this
.
id
,
this
.
userId
,
this
.
content
,
this
.
imageUrl
,
this
.
messageId
,
this
.
minioUrl
,
this
.
createTime
,
this
.
style
,
this
.
showSquare
});
MyWorkData
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
userId
=
json
[
'userId'
];
content
=
json
[
'content'
];
imageUrl
=
json
[
'imageUrl'
];
messageId
=
json
[
'messageId'
];
minioUrl
=
json
[
'minioUrl'
];
createTime
=
json
[
'createTime'
];
style
=
json
[
'style'
];
showSquare
=
json
[
'showSquare'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'userId'
]
=
this
.
userId
;
data
[
'content'
]
=
this
.
content
;
data
[
'imageUrl'
]
=
this
.
imageUrl
;
data
[
'messageId'
]
=
this
.
messageId
;
data
[
'minioUrl'
]
=
this
.
minioUrl
;
data
[
'createTime'
]
=
this
.
createTime
;
data
[
'style'
]
=
this
.
style
;
data
[
'showSquare'
]
=
this
.
showSquare
;
return
data
;
}
}
\ No newline at end of file
lib/pages/my-work/view.dart
View file @
67118e06
import
'package:cached_network_image/cached_network_image.dart'
;
import
'package:chart/common/routers/routes.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_easyrefresh/easy_refresh.dart'
;
import
'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'
;
import
'package:get/get.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
import
'../../common/style/color.dart'
;
import
'./controller.dart'
;
class
MyWorkPage
extends
GetView
<
MyWorkController
>
{
const
MyWorkPage
({
Key
?
key
})
:
super
(
key:
key
);
Widget
makeListView
()
{
// TODO: implement build
final
controller
=
Get
.
find
<
MyWorkController
>();
return
Contain
er
(
child:
EasyRefresh
(
return
SmartRefresh
er
(
enablePullUp:
true
,
controller:
controller
.
refreshController
,
header:
ClassicalHeader
(
bgColor:
Colors
.
white
,
textColor:
Colors
.
pink
,
infoColor:
Colors
.
pink
,
refreshReadyText:
'下拉刷新'
,
refreshingText:
'正在努力刷新'
,
refreshedText:
'加载完成'
,
showInfo:
true
,
infoText:
'正在加载中'
,
onRefresh:
controller
.
onPullRefresh
,
onLoading:
controller
.
onLoadMore
,
header:
const
ClassicHeader
(
releaseText:
"松开刷新"
,
refreshingText:
"刷新数据中"
,
completeText:
"刷新数据成功"
,
idleText:
"下拉刷新"
),
footer:
ClassicalFooter
(
bgColor:
Colors
.
white
,
textColor:
Colors
.
pink
,
infoColor:
Colors
.
pink
,
showInfo:
true
,
noMoreText:
'暂时没有更多了'
,
loadReadyText:
'上拉加载'
,
loadedText:
'加载完毕'
,
loadText:
'上拉加载更多'
,
loadingText:
'正在努力加载更多'
,
infoText:
'正在加载中'
,
footer:
const
ClassicFooter
(
loadingText:
"正在加载中..."
,
noDataText:
'没有更多数据啦'
),
child:
MasonryGridView
.
count
(
controller:
controller
.
loadingMoreController
,
itemCount:
controller
.
models
.
descriptives
.
length
,
child:
Obx
(()
=>
MasonryGridView
.
count
(
itemCount:
controller
.
images
.
value
.
length
,
crossAxisCount:
2
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
10
),
child:
Image
(
image:
AssetImage
(
controller
.
models
.
descriptives
[
index
].
imageUrl
),
fit:
BoxFit
.
cover
,
height:
index
%
2
==
0
?
260
:
200
,
return
InkWell
(
onTap:
()
{
controller
.
onClickImage
(
index
);
},
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
10
),
child:
CachedNetworkImage
(
fit:
BoxFit
.
cover
,
height:
index
%
2
==
0
?
260
:
200
,
imageUrl:
controller
.
images
.
value
[
index
].
minioUrl
??
""
,
placeholder:
(
context
,
url
)
=>
Container
(
alignment:
Alignment
.
center
,
child:
const
SizedBox
(
width:
30
,
height:
30
,
child:
CircularProgressIndicator
(),
),
),
errorWidget:
(
context
,
url
,
error
)
=>
Container
(
alignment:
Alignment
.
center
,
child:
Text
(
error
.
toString
()),
),
)
),
);
},
mainAxisSpacing:
10.0
,
crossAxisSpacing:
10.0
,
),
onLoad:
()
async
{
print
(
'没有更多了.......'
);
},
onRefresh:
()
async
{
print
(
'下拉刷新~~~~'
);
},
),
);
))
);
}
@override
...
...
@@ -77,22 +76,17 @@ class MyWorkPage extends GetView<MyWorkController> {
init:
MyWorkController
(),
id:
"mywork"
,
builder:
(
_
)
{
return
Container
(
height:
double
.
infinity
,
decoration:
const
BoxDecoration
(
color:
AppColor
.
black1
),
child:
Scaffold
(
final
controller
=
Get
.
find
<
MyWorkController
>();
return
Scaffold
(
backgroundColor:
AppColor
.
black1
,
appBar:
AppBar
(
elevation:
0
,
title:
Obx
(()
=>
Text
(
controller
.
title
.
value
)),
bottomOpacity:
0.1
,
backgroundColor:
const
Color
.
fromARGB
(
0
,
29
,
33
,
60
),
appBar:
AppBar
(
elevation:
0
,
title:
const
Text
(
"我的作品"
),
bottomOpacity:
0.1
,
backgroundColor:
const
Color
.
fromARGB
(
0
,
29
,
33
,
60
),
),
body:
SafeArea
(
child:
makeListView
(),
),
),
body:
SafeArea
(
child:
makeListView
(),
),
);
},
...
...
lib/pages/my/controller.dart
View file @
67118e06
...
...
@@ -39,7 +39,7 @@ class MyController extends GetxController {
if
(
await
inAppReview
.
isAvailable
())
{
inAppReview
.
requestReview
();
}
else
{
EasyLoading
.
showToast
(
"评价异常"
);
EasyLoading
.
showToast
(
"评价异常
或者已经评价
"
);
}
}
...
...
@@ -67,17 +67,6 @@ class MyController extends GetxController {
EasyLoading
.
showError
(
res
.
message
??
"获取个人信息失败"
);
}
userInfo
.
value
=
res
.
data
??
UserInfoData
(
username:
"未登录"
);
/**
* if let text = chatController.userInfo?.expireTime, !text.isEmpty {
if text.isExpireTime {
cell?.detailTextLabel?.text = "已过期: \(text.expireTime)"
} else {
cell?.detailTextLabel?.text = "到期日: \(text.expireTime)"
}
} else {
cell?.detailTextLabel?.text = "可用积分: \(chatController.userInfo?.integral ?? 0)"
}
*/
final
expireTime
=
userInfo
.
value
.
expireTime
;
if
(
expireTime
!=
null
&&
expireTime
.
isNotEmpty
)
{
final
expDate
=
DateTime
.
parse
(
expireTime
);
...
...
lib/pages/my/models.dart
View file @
67118e06
...
...
@@ -45,6 +45,8 @@ class UserInfoData {
String
?
shareCode
;
String
?
deviceType
;
String
?
gopenId
;
int
?
createImgCount
;
int
?
collectImgCount
;
UserInfoData
(
{
this
.
id
,
...
...
@@ -64,7 +66,9 @@ class UserInfoData {
this
.
source
,
this
.
shareCode
,
this
.
deviceType
,
this
.
gopenId
});
this
.
gopenId
,
this
.
createImgCount
,
this
.
collectImgCount
});
UserInfoData
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
...
...
@@ -85,6 +89,8 @@ class UserInfoData {
shareCode
=
json
[
'shareCode'
];
deviceType
=
json
[
'deviceType'
];
gopenId
=
json
[
'gopenId'
];
createImgCount
=
json
[
'createImgCount'
];
collectImgCount
=
json
[
'collectImgCount'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
...
...
@@ -107,6 +113,8 @@ class UserInfoData {
data
[
'shareCode'
]
=
this
.
shareCode
;
data
[
'deviceType'
]
=
this
.
deviceType
;
data
[
'gopenId'
]
=
this
.
gopenId
;
data
[
'createImgCount'
]
=
this
.
createImgCount
;
data
[
'collectImgCount'
]
=
this
.
collectImgCount
;
return
data
;
}
}
\ No newline at end of file
lib/pages/my/view.dart
View file @
67118e06
...
...
@@ -68,6 +68,7 @@ class MyPage extends GetView<MyController> {
}
Widget
makeHistoryInfoView
()
{
final
controller
=
Get
.
find
<
MyController
>();
return
Container
(
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
30
,
0
,
30
),
child:
Row
(
...
...
@@ -75,18 +76,18 @@ class MyPage extends GetView<MyController> {
Expanded
(
child:
InkWell
(
onTap:
()
{
Get
.
toNamed
(
AppRoutes
.
MY_WORK
);
Get
.
toNamed
(
AppRoutes
.
MY_WORK
,
arguments:
{
"operator"
:
"work"
}
);
},
child:
Column
(
children:
const
[
Text
(
"2
"
,
style:
TextStyle
(
children:
[
Obx
(()
=>
Text
(
"
${controller.userInfo.value.createImgCount ?? 0}
"
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
bold
,
fontSize:
30
),
),
SizedBox
(
height:
5
,),
Text
(
"绘画作品"
,
),
),
const
SizedBox
(
height:
5
,),
const
Text
(
"绘画作品"
,
style:
TextStyle
(
fontSize:
14
,
color:
AppColor
.
gray4
,
...
...
@@ -105,16 +106,19 @@ class MyPage extends GetView<MyController> {
),
Expanded
(
child:
InkWell
(
onTap:
()
{
Get
.
toNamed
(
AppRoutes
.
MY_WORK
,
arguments:
{
"operator"
:
"collect"
});
},
child:
Column
(
children:
const
[
Text
(
"0
"
,
style:
TextStyle
(
children:
[
Obx
(()
=>
Text
(
"
${controller.userInfo.value.collectImgCount ?? 0}
"
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
bold
,
fontSize:
30
),
),
SizedBox
(
height:
5
,),
Text
(
"我的收藏"
,
)
)
,
const
SizedBox
(
height:
5
,),
const
Text
(
"我的收藏"
,
style:
TextStyle
(
fontSize:
14
,
color:
AppColor
.
gray4
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment