Skip to content

Commit

Permalink
change user profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Jan 12, 2022
1 parent 8311e38 commit e339b2c
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 23 deletions.
4 changes: 3 additions & 1 deletion lib/entity/ForumThread.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:discuz_flutter/converter/SecondToDateTimeConverter.dart';
import 'package:discuz_flutter/converter/StringToIntConverter.dart';
import 'package:json_annotation/json_annotation.dart';

part 'ForumThread.g.dart';
Expand All @@ -25,7 +26,8 @@ class ForumThread{
}

@JsonKey(name:"readperm")
String readPerm = "0";
@StringToIntConverter()
int readPerm = 0;
String author = "";
@JsonKey(name:"authorid")
String authorId = "0";
Expand Down
5 changes: 3 additions & 2 deletions lib/entity/ForumThread.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ class MessageLookup extends MessageLookupByLibrary {

static String m28(filename) => "Successfully download file: ${filename}.";

static String m29(username) => "User ${username} expired";
static String m29(num) => "RP ${num}";

static String m30(uid) => "UserId ${uid}";
static String m30(username) => "User ${username} expired";

static String m31(user) => "View ${user}\'s profile.";
static String m31(uid) => "UserId ${uid}";

static String m32(user) => "View ${user}\'s profile.";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
Expand Down Expand Up @@ -465,6 +467,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Take a bite on beta test"),
"threadIsClosed":
MessageLookupByLibrary.simpleMessage("Thread is closed."),
"threadReadAccess": m29,
"trashAd": MessageLookupByLibrary.simpleMessage("Trash Advertisement"),
"trustHostActionText":
MessageLookupByLibrary.simpleMessage("Trust this host"),
Expand Down Expand Up @@ -515,19 +518,22 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Send raw image"),
"uploadingImageToServer": MessageLookupByLibrary.simpleMessage(
"Upload the file to the server..."),
"userCredit": MessageLookupByLibrary.simpleMessage("Credits"),
"userExpiredSubtitle": MessageLookupByLibrary.simpleMessage(
"The current user is expired, some function may not work."),
"userExpiredTitle": m29,
"userIdTitle": m30,
"userExpiredTitle": m30,
"userIdTitle": m31,
"userPost": MessageLookupByLibrary.simpleMessage("Posts"),
"userProfile": MessageLookupByLibrary.simpleMessage("User Profile"),
"userProfileTitle":
MessageLookupByLibrary.simpleMessage("User Profiles"),
"userThread": MessageLookupByLibrary.simpleMessage("Threads"),
"viewAuthorInfo":
MessageLookupByLibrary.simpleMessage("View author\'s profile"),
"viewHistory": MessageLookupByLibrary.simpleMessage("View History"),
"viewThreadTitle":
MessageLookupByLibrary.simpleMessage("View a thread"),
"viewUserInfo": m31,
"viewUserInfo": m32,
"warnedPost":
MessageLookupByLibrary.simpleMessage("The post is warned."),
"watchPictureInFullScreen":
Expand Down
18 changes: 12 additions & 6 deletions lib/generated/intl/messages_zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ class MessageLookup extends MessageLookupByLibrary {

static String m28(filename) => "成功下载文件: ${filename}。";

static String m29(username) => "用户 ${username} 已失效";
static String m29(num) => "阅读权限 ${num}";

static String m30(uid) => "用户编号: ${uid}";
static String m30(username) => "用户 ${username} 已失效";

static String m31(user) => "查看${user}详情";
static String m31(uid) => "用户编号: ${uid}";

static String m32(user) => "查看${user}详情";

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
Expand Down Expand Up @@ -399,6 +401,7 @@ class MessageLookup extends MessageLookupByLibrary {
"testVersionNotificationTitle":
MessageLookupByLibrary.simpleMessage("欢迎参与测试版本"),
"threadIsClosed": MessageLookupByLibrary.simpleMessage("此贴已关闭发帖。"),
"threadReadAccess": m29,
"trashAd": MessageLookupByLibrary.simpleMessage("垃圾广告"),
"trustHostActionText": MessageLookupByLibrary.simpleMessage("信任此域名"),
"trustHostTitle": MessageLookupByLibrary.simpleMessage("主机域名白名单"),
Expand Down Expand Up @@ -440,16 +443,19 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("原始图片(可能因为太大被服务器拒绝)"),
"uploadingImageToServer":
MessageLookupByLibrary.simpleMessage("向服务器传输数据中。。。"),
"userCredit": MessageLookupByLibrary.simpleMessage("积分"),
"userExpiredSubtitle":
MessageLookupByLibrary.simpleMessage("当前用户授权已过期,你需要重新登录以重新激活此用户。"),
"userExpiredTitle": m29,
"userIdTitle": m30,
"userExpiredTitle": m30,
"userIdTitle": m31,
"userPost": MessageLookupByLibrary.simpleMessage("回复"),
"userProfile": MessageLookupByLibrary.simpleMessage("用户中心"),
"userProfileTitle": MessageLookupByLibrary.simpleMessage("用户信息"),
"userThread": MessageLookupByLibrary.simpleMessage("发帖"),
"viewAuthorInfo": MessageLookupByLibrary.simpleMessage("查看用户详情"),
"viewHistory": MessageLookupByLibrary.simpleMessage("浏览历史"),
"viewThreadTitle": MessageLookupByLibrary.simpleMessage("查看帖子"),
"viewUserInfo": m31,
"viewUserInfo": m32,
"warnedPost": MessageLookupByLibrary.simpleMessage("此贴被警告。"),
"watchPictureInFullScreen":
MessageLookupByLibrary.simpleMessage("查看大图"),
Expand Down
40 changes: 40 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -468,5 +468,14 @@
"placeholders": {
"discuzName": {}
}
},
"userPost": "Posts",
"userThread": "Threads",
"userCredit": "Credits",
"threadReadAccess": "RP {num}",
"@threadReadAccess": {
"placeholders": {
"num": {}
}
}
}
9 changes: 9 additions & 0 deletions lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -468,5 +468,14 @@
"placeholders": {
"discuzName": {}
}
},
"userPost": "回复",
"userThread": "发帖",
"userCredit": "积分",
"threadReadAccess": "阅读权限 {num}",
"@threadReadAccess": {
"placeholders": {
"num": {}
}
}
}
7 changes: 5 additions & 2 deletions lib/page/ExploreWebsitePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ class InnerWebviewState extends State<InnerWebviewScreen>{

if(_discuz != null){
loadCookieByUser(_discuz, _user);
initialURL = _discuz.baseURL;
if(initialURL == null){
initialURL = _discuz.baseURL;
}

}
else{
initialURL = "https://discuzhub.kidozh.com";
Expand Down Expand Up @@ -360,7 +363,7 @@ class InnerWebviewState extends State<InnerWebviewScreen>{
}
case "space":{
// check for forum, query fid
if(uri.queryParameters.containsKey("uid")){
if(uri.queryParameters.containsKey("uid") && !uri.queryParameters.containsKey("do")){
String uidString = uri.queryParameters["uid"]!;
// trigger tid
if(int.tryParse(uidString) != null){
Expand Down
23 changes: 23 additions & 0 deletions lib/page/ExploreWebsiteScaffordPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

import 'package:discuz_flutter/page/ExploreWebsitePage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';

class ExploreWebsiteScaffordPage extends StatelessWidget{
final String? initialURL;

ExploreWebsiteScaffordPage({this.initialURL});

@override
Widget build(BuildContext context) {
// TODO: implement build

return PlatformScaffold(
appBar: PlatformAppBar(
automaticallyImplyLeading: true,
),
body: ExploreWebsitePage(key: ValueKey(121212),initialURL: initialURL,),
);
}

}
76 changes: 75 additions & 1 deletion lib/page/UserProfilePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import 'package:discuz_flutter/client/MobileApiClient.dart';
import 'package:discuz_flutter/entity/Discuz.dart';
import 'package:discuz_flutter/entity/User.dart';
import 'package:discuz_flutter/generated/l10n.dart';
import 'package:discuz_flutter/page/ExploreWebsitePage.dart';
import 'package:discuz_flutter/provider/DiscuzAndUserNotifier.dart';
import 'package:discuz_flutter/screen/BlankScreen.dart';
import 'package:discuz_flutter/utility/CustomizeColor.dart';
import 'package:discuz_flutter/utility/NetworkUtils.dart';
import 'package:discuz_flutter/utility/URLUtils.dart';
import 'package:discuz_flutter/utility/VibrationUtils.dart';
import 'package:discuz_flutter/widget/DiscuzHtmlWidget.dart';
import 'package:discuz_flutter/widget/ErrorCard.dart';
import 'package:discuz_flutter/widget/UserProfileListItem.dart';
Expand All @@ -20,6 +22,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:provider/provider.dart';

import 'ExploreWebsiteScaffordPage.dart';
import 'PrivateMessageDetailPage.dart';

class UserProfilePage extends StatelessWidget {
Expand Down Expand Up @@ -86,7 +89,6 @@ class UserProfileState extends State<UserProfileStatefulWidget> {

@override
Widget build(BuildContext context) {
// TODO: implement build
if (_userProfileResult == null) {
return PlatformScaffold(
iosContentPadding: true,
Expand Down Expand Up @@ -243,6 +245,78 @@ class UserProfileState extends State<UserProfileStatefulWidget> {
),
],
),
Container(
width: double.infinity,
padding: EdgeInsets.all(10.0),
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.grey.shade900,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
child: Card(
elevation: 0,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
children: [
Text(S.of(context).userThread, style: Theme.of(context).textTheme.caption,),
Text(_userProfileResult!.variables.getSpace().threads.toString(),
style: Theme.of(context).textTheme.headline4?.copyWith(color: Theme.of(context).primaryColor),)
],
),
),
),
onTap: (){
VibrationUtils.vibrateWithClickIfPossible();
Navigator.push(
context,
platformPageRoute(
context: context,
builder: (context) => ExploreWebsiteScaffordPage(initialURL: discuz.baseURL+"/home.php?mod=space&uid=${uid}&do=thread&view=me&type=thread&from=space")));
},
),
InkWell(
child: Card(
elevation: 0,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
children: [
Text(S.of(context).userPost, style: Theme.of(context).textTheme.caption,),
Text(_userProfileResult!.variables.getSpace().posts.toString(),
style: Theme.of(context).textTheme.headline4?.copyWith(color: Theme.of(context).primaryColor),)
],
),
),
),
onTap: (){
VibrationUtils.vibrateWithClickIfPossible();
Navigator.push(
context,
platformPageRoute(
context: context,
builder: (context) => ExploreWebsiteScaffordPage(initialURL: discuz.baseURL+"/home.php?mod=space&uid=${uid}&do=thread&view=me&type=reply&from=space")));
},
),
Card(
elevation: 0,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
children: [
Text(S.of(context).userCredit, style: Theme.of(context).textTheme.caption,),
Text(_userProfileResult!.variables.getSpace().credits.toString(),
style: Theme.of(context).textTheme.headline4?.copyWith(color: Theme.of(context).primaryColor),)
],
),
),
)
],
),
),
Container(
width: double.infinity,
color: Theme.of(context).brightness == Brightness.light
Expand Down
2 changes: 1 addition & 1 deletion lib/page/ViewThreadSliverPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ class _ViewThreadSliverState extends State<ViewThreadStatefulSliverWidget> {
mainAxisAlignment: MainAxisAlignment.center,
children: [

Text(S.of(context).threadIsClosed,style: Theme.of(context).textTheme.headline5?.copyWith(
Text(S.of(context).threadIsClosed,style: Theme.of(context).textTheme.bodyText1?.copyWith(
color: Theme.of(context).errorColor
),)
],
Expand Down
5 changes: 5 additions & 0 deletions lib/widget/ForumThreadWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class ForumThreadState extends State<ForumThreadStatefulWidget>{
TextSpan(text: " / ",style: TextStyle(fontWeight: FontWeight.w300)),
if(threadCategory.isNotEmpty)
TextSpan(text: threadCategory,style: TextStyle(color: Theme.of(context).accentColor)),
if((_user == null && _forumThread.readPerm > 0)||(_user!= null && _forumThread.readPerm >_user!.readPerm))
TextSpan(text: " / " + S.of(context).threadReadAccess(_forumThread.readPerm),style: TextStyle(color: Theme.of(context).errorColor)),

],
),
),
Expand Down Expand Up @@ -251,6 +254,8 @@ class ForumThreadState extends State<ForumThreadStatefulWidget>{
TextSpan(text: " / ",style: TextStyle(fontWeight: FontWeight.w300, color: Theme.of(context).brightness == Brightness.light ? Colors.black38: Colors.white38)),
if(threadCategory.isNotEmpty)
TextSpan(text: threadCategory,style: TextStyle(color: Theme.of(context).brightness == Brightness.light ? Colors.black38: Colors.white38)),
if((_user == null && _forumThread.readPerm > 0)||(_user!= null && _forumThread.readPerm >_user!.readPerm))
TextSpan(text: " / " + S.of(context).threadReadAccess(_forumThread.readPerm),style: TextStyle(color: Theme.of(context).unselectedWidgetColor)),
],
),
),
Expand Down
Loading

0 comments on commit e339b2c

Please sign in to comment.