Skip to content

Commit

Permalink
add private message update
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Aug 13, 2024
1 parent 823482a commit 25594bd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 47 deletions.
2 changes: 1 addition & 1 deletion lib/app/MainApp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
key: UniqueKey(),
icon: (_selecteddiscuz != null && _selecteddiscuz == discuz)
? PlatformIcons(context).checkMarkCircledSolid
: Icons.amp_stories,
: AppPlatformIcons(context).discuzSolid,
color: (_selecteddiscuz != null && _selecteddiscuz == discuz)
? Theme.of(context).colorScheme.primary
: Theme.of(context).unselectedWidgetColor,
Expand Down
7 changes: 3 additions & 4 deletions lib/page/UserProfilePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,13 @@ class UserProfileState extends State<UserProfileStatefulWidget> {
children: [
InkWell(
child: Card(

child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Column(
children: [
Text(S.of(context).userThread, style: Theme.of(context).textTheme.bodySmall,),
Text(_userProfileResult!.variables.getSpace().threads.toString(),
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Theme.of(context).colorScheme.onPrimaryContainer),)
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Theme.of(context).colorScheme.primary),)
],
),
),
Expand All @@ -313,7 +312,7 @@ class UserProfileState extends State<UserProfileStatefulWidget> {
children: [
Text(S.of(context).userPost, style: Theme.of(context).textTheme.bodySmall,),
Text(_userProfileResult!.variables.getSpace().posts.toString(),
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Theme.of(context).colorScheme.onPrimaryContainer,))
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Theme.of(context).colorScheme.primary,))
],
),
),
Expand All @@ -335,7 +334,7 @@ class UserProfileState extends State<UserProfileStatefulWidget> {
children: [
Text(S.of(context).userCredit, style: Theme.of(context).textTheme.bodySmall,),
Text(_userProfileResult!.variables.getSpace().credits.toString(),
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Theme.of(context).colorScheme.onPrimaryContainer))
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Theme.of(context).colorScheme.primary))
],
),
),
Expand Down
7 changes: 1 addition & 6 deletions lib/screen/PrivateMessagePortalScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,7 @@ class _PrivateMessagePortalState
},
child: ListView.builder(
itemBuilder: (context, index) {
return Column(
children: [
PrivateMessagePortalWidget(discuzAndUser.discuz!, discuzAndUser.user, _pmList[index]),
Divider()
],
);
return PrivateMessagePortalWidget(discuzAndUser.discuz!, discuzAndUser.user, _pmList[index]);
},
itemCount: _pmList.length,
),
Expand Down
2 changes: 2 additions & 0 deletions lib/utility/AppPlatformIcons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,6 @@ class AppPlatformIcons{
IconData get loginUserSuccessSolid => isMaterial(context)? Icons.check_circle : CupertinoIcons.person_crop_circle_badge_checkmark;

IconData get userIncognitoSolid => isMaterial(context)? Icons.airplanemode_active : CupertinoIcons.eyeglasses;

IconData get discuzSolid => isMaterial(context)? Icons.amp_stories : Icons.amp_stories;
}
83 changes: 47 additions & 36 deletions lib/widget/PrivateMessagePortalWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:discuz_flutter/provider/DiscuzAndUserNotifier.dart';
import 'package:discuz_flutter/utility/CustomizeColor.dart';
import 'package:discuz_flutter/utility/URLUtils.dart';
import 'package:discuz_flutter/utility/VibrationUtils.dart';
import 'package:discuz_flutter/widget/UserAvatar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:provider/provider.dart';
Expand All @@ -26,47 +27,57 @@ class PrivateMessagePortalWidget extends StatelessWidget{

@override
Widget build(BuildContext context) {
User? user = Provider.of<DiscuzAndUserNotifier>(context, listen: false).user;
int uid = 0;
if(user != null){
uid = user.uid;
}

return Container(
child: ListTile(
leading: InkWell(
child: ClipRRect(
return PlatformWidgetBuilder(
material: (context, child, platform) => Card(
elevation: 4.0,
color: Theme.of(context).brightness == Brightness.light? Colors.white: Colors.white10,
surfaceTintColor: Theme.of(context).brightness == Brightness.light? Colors.white: Colors.white10,
child: Padding(padding: EdgeInsets.all(4.0),
child: child,
),
),
cupertino: (context, child, platform) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(child!=null)
child,
Divider()

borderRadius: BorderRadius.circular(10000.0),
child: CachedNetworkImage(
imageUrl: URLUtils.getAvatarURL(_discuz, _privateMessagePortal.msgFromId.toString()),
progressIndicatorBuilder: (context, url, downloadProgress) => CircularProgressIndicator(value: downloadProgress.progress),
errorWidget: (context, url, error) =>
CircleAvatar(
],
),
child: ListTile(
leading: UserAvatar(_discuz, _privateMessagePortal.toUid, _privateMessagePortal.toUserName, size: 36,),

backgroundColor: CustomizeColor.getColorBackgroundById(_privateMessagePortal.msgFromId),
child: Text(_privateMessagePortal.msgFromName.length !=0 ? _privateMessagePortal.msgFromName[0].toUpperCase()
: S.of(context).anonymous,
style: TextStyle(color: Colors.white)),
)
,
),
),
onTap: () async{
User? user = Provider.of<DiscuzAndUserNotifier>(context, listen: false).user;
VibrationUtils.vibrateWithClickIfPossible();
await Navigator.push(
context,
platformPageRoute(context:context,builder: (context) => UserProfilePage(_discuz,user, _privateMessagePortal.msgFromId)));
},
title: Text(_privateMessagePortal.subject,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
title: Text(_privateMessagePortal.message,style: TextStyle(fontWeight: FontWeight.bold)),
subtitle: RichText(
text: TextSpan(
text: _privateMessagePortal.msgFromName,
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
//TextSpan(text: S.of(context).publishAt, style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(text: " · ",style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(text: _privateMessagePortal.readableString),
],
),
subtitle: Text(
"${_privateMessagePortal.msgFromName}: ${_privateMessagePortal.message}",
overflow: TextOverflow.ellipsis,
maxLines: 1,
),

// subtitle: RichText(
// text: TextSpan(
// text: "${_privateMessagePortal.msgFromName}:${_privateMessagePortal.message}",
// style: DefaultTextStyle.of(context).style,
// children: <TextSpan>[
// TextSpan(text: "\n"),
// TextSpan(text: _privateMessagePortal.toUserName),
// //TextSpan(text: S.of(context).publishAt, style: TextStyle(fontWeight: FontWeight.w300)),
// TextSpan(text: " · ",style: TextStyle(fontWeight: FontWeight.w300)),
// TextSpan(text: _privateMessagePortal.readableString),
// ],
// ),
// ),
trailing: _privateMessagePortal.isNew ? Icon(Icons.new_releases_outlined, color: Theme.of(context).colorScheme.primary,) :null,
onTap: () async {
VibrationUtils.vibrateWithClickIfPossible();
Expand Down

0 comments on commit 25594bd

Please sign in to comment.