Skip to content

Commit

Permalink
update channel list
Browse files Browse the repository at this point in the history
  • Loading branch information
bai-3 authored and bai-3 committed Nov 1, 2024
1 parent 58dc767 commit 11ef06e
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 158 deletions.
4 changes: 2 additions & 2 deletions lib/infra/components/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class _BaseAvatarState extends State<BaseAvatar> {

buildCtx(BuildContext context) {
final constTheme = Theme.of(context).extension<ExtColors>()!;
final imgw = (widget.avatarWidth * 0.7 - widget.radius/4).toInt();
final imgw = (widget.avatarWidth * 0.7 - widget.radius/3).toInt();
final imgbg = widget.color ?? constTheme.centerChannelColor;
final boxBg = widget.bg ?? constTheme.centerChannelColor.withOpacity(0.1);
final img = Identicon(fg: [imgbg.red, imgbg.green, imgbg.blue]).generate(
Expand Down Expand Up @@ -212,7 +212,7 @@ class _BaseAvatarWithPopState extends State<BaseAvatarWithPop> {
showArrow: false,
controller: menuController,
position: PreferredPosition.bottomLeft,
pressType: kIsWeb ? PressType.singleClick : PressType.mouseHover,
pressType: PressType.singleClick,
child: Avatar(
id: widget.id,
mxContent: widget.mxContent,
Expand Down
6 changes: 5 additions & 1 deletion lib/infra/components/hover_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class HoverListItem extends StatefulWidget {
final VoidCallback onPressed;
final Function(bool)? onHover;
final Widget? trailing;
final Widget? unTrailing;
final Widget child;
final String subkey;
final double radius;
Expand All @@ -18,6 +19,7 @@ class HoverListItem extends StatefulWidget {
required this.onPressed,
required this.child,
this.trailing,
this.unTrailing,
this.color,
this.hoverColor,
this.ishover,
Expand All @@ -38,6 +40,7 @@ class HoverListItemState extends State<HoverListItem> {
Widget build(BuildContext context) {
bool calcHover = _isHover || (widget.ishover != null && widget.ishover!);
return MouseRegion(
cursor: SystemMouseCursors.click,
onEnter: (event) {
widget.onHover?.call(true);
setState(() {
Expand Down Expand Up @@ -65,7 +68,8 @@ class HoverListItemState extends State<HoverListItem> {
: Row(
children: [
Expanded(child: widget.child),
Visibility(visible: calcHover, child: widget.trailing!),
calcHover ? widget.trailing! : widget.unTrailing??const SizedBox(width: 0.1)
// Visibility(visible: calcHover, child: widget.trailing!),
],
),
),
Expand Down
27 changes: 27 additions & 0 deletions lib/infra/components/me_pop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,33 @@ class _MePopState extends State<MePop> {
),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
menuController.hideMenu();
showModelOrPage(context, "/setting", width: 0.7.sw, height: 0.8.sh);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 15.w),
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: constTheme.centerChannelColor.withOpacity(0.05))),
),
child: Row(
children: [
Text(
'组织设置',
style: TextStyle(fontSize: 14.w, color: constTheme.centerChannelColor),
),
const Spacer(),
Icon(
Icons.arrow_forward_ios,
size: 14.w,
color: constTheme.centerChannelColor,
)
],
),
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Expand Down
4 changes: 2 additions & 2 deletions lib/infra/components/popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BasePopupMenuController extends ChangeNotifier {

class BasePopupMenu extends StatefulWidget {
const BasePopupMenu({
Key? key,
super.key,
required this.child,
required this.menuBuilder,
required this.pressType,
Expand All @@ -51,7 +51,7 @@ class BasePopupMenu extends StatefulWidget {
this.position,
this.menuOnChange,
this.enablePassEvent = true,
}) : super(key: key);
});

final Widget child;
final PressType pressType;
Expand Down
26 changes: 13 additions & 13 deletions lib/infra/pages/chat/channel/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,19 +420,19 @@ class _ChannelDetailPageState extends State<ChannelDetailPage> with WindowListen
return SizedBox(height: 10.w);
}
if (index == events.length + 1) {
if (timeline != null && timeline!.canRequestHistory) {
return Center(
child: Container(
width: 15.w,
height: 15.w,
margin: EdgeInsets.all(8.w),
child: CircularProgressIndicator.adaptive(
strokeWidth: 4.w,
valueColor: AlwaysStoppedAnimation(constTheme.centerChannelColor),
),
),
);
}
// if (timeline != null && timeline!.canRequestHistory) {
// return Center(
// child: Container(
// width: 15.w,
// height: 15.w,
// margin: EdgeInsets.all(8.w),
// child: CircularProgressIndicator.adaptive(
// strokeWidth: 4.w,
// valueColor: AlwaysStoppedAnimation(constTheme.centerChannelColor),
// ),
// ),
// );
// }
return Container();
}

Expand Down
4 changes: 2 additions & 2 deletions lib/infra/pages/chat/channel/msg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class _MsgState extends State<Msg> {
user.id,
user.displayName ?? "-",
true,
40.w,
35.w,
color: constTheme.centerChannelColor,
bg: constTheme.centerChannelDivider,
mxContent: user.avatarUrl,
Expand All @@ -217,7 +217,7 @@ class _MsgState extends State<Msg> {
),
if (!showAvatar)
SizedBox(
width: 40.w,
width: 35.w,
child: hover
? Text(
getTime(event.originServerTs),
Expand Down
83 changes: 62 additions & 21 deletions lib/infra/pages/chat/channel_list.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:date_format/date_format.dart';
import 'package:dtim/domain/utils/time.dart';
import 'package:dtim/infra/components/components.dart';
import 'package:dtim/infra/router/pop_router.dart';
import 'package:dtim/application/store/app/org.dart';
Expand Down Expand Up @@ -55,7 +57,9 @@ class _ChannelListState extends State<ChannelList> {
subkey: "DirectChat${chat.id}",
ishover: index == hover,
color: currentId == chat.id ? constTheme.sidebarTextActiveBorder.withOpacity(0.09) : Colors.transparent,
hoverColor: currentId == chat.id ? constTheme.sidebarTextActiveBorder.withOpacity(0.09):constTheme.centerChannelColor.withOpacity(0.08),
hoverColor: currentId == chat.id
? constTheme.sidebarTextActiveBorder.withOpacity(0.09)
: constTheme.centerChannelColor.withOpacity(0.08),
radius: 5.w,
margin: EdgeInsets.only(left: 8.w, right: 8.w, bottom: 2.w),
onPressed: () async {
Expand Down Expand Up @@ -144,26 +148,39 @@ class _ChannelListState extends State<ChannelList> {
});
},
child: Container(
height: 29.w,
padding: EdgeInsets.only(right: 12.w, left: 12.w),
height: 50.w,
padding: EdgeInsets.only(right: 6.w, left: 6.w),
child: Icon(
Icons.adaptive.more,
size: 17.w,
color: constTheme.centerChannelColor.withAlpha(155),
),
),
),
unTrailing: Container(
width: 50.w,
height: 50.w,
padding: EdgeInsets.only(top: 8.w, right: 8.w),
child: Text(
getTime(chat.lastEvent!.originServerTs),
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 11.w,
fontWeight: chat.isUnreadOrInvited ? FontWeight.bold : FontWeight.normal,
color: constTheme.centerChannelColor.withAlpha(155),
),
),
),
child: SizedBox(
height: 45.w,
height: 50.w,
width: double.maxFinite,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(width: 10.w),
Container(
width: 25.w,
SizedBox(width: 6.w),
SizedBox(
width: 35.w,
height: 35.w,
padding: EdgeInsets.only(top: 2.w),
child: badges.Badge(
showBadge: chat.isUnread,
badgeStyle: badges.BadgeStyle(badgeColor: constTheme.sidebarUnreadText),
Expand All @@ -177,27 +194,51 @@ class _ChannelListState extends State<ChannelList> {
),
),
child: Center(
child: Icon(
chat.encrypted ? Icons.private_connectivity : Icons.all_inclusive_sharp,
size: chat.encrypted ? 24.w : 19.w,
child: BaseAvatar(
key: Key("list-id${chat.id}"),
chat.id,
true,
35.w,
color: chat.isUnreadOrInvited ? constTheme.sidebarUnreadText : constTheme.centerChannelColor,
bg: constTheme.centerChannelColor.withOpacity(0.05),
radius: 5.w,
),
),
),
),
SizedBox(width: 8.w),
SizedBox(width: 6.w),
Expanded(
child: Text(
chat.getLocalizedDisplayname(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 15.w,
fontWeight: chat.isUnreadOrInvited ? FontWeight.bold : FontWeight.normal,
color: chat.isUnreadOrInvited ? constTheme.sidebarUnreadText : constTheme.centerChannelColor,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
chat.getLocalizedDisplayname(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 17.w,
height: 1,
fontWeight: chat.isUnreadOrInvited ? FontWeight.bold : FontWeight.normal,
color: constTheme.centerChannelColor,
),
),
SizedBox(height: 2.w),
Text(
chat.lastEvent!.text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13.w,
height: 1,
fontWeight: chat.isUnreadOrInvited ? FontWeight.bold : FontWeight.normal,
color: constTheme.centerChannelColor.withAlpha(155),
),
)
],
),
),
SizedBox(width: 8.w),
],
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/infra/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OrgPage extends StatefulWidget {
}

class _OrgPageState extends State<OrgPage> {
double leftWidth = 200.w;
double leftWidth = 250.w;

@override
void dispose() {
Expand Down Expand Up @@ -62,7 +62,7 @@ class _OrgPageState extends State<OrgPage> {
),
onPanUpdate: (details) {
setState(() {
if (leftWidth + details.delta.dx < 180.w || leftWidth + details.delta.dx > 350.w) {
if (leftWidth + details.delta.dx < 220.w || leftWidth + details.delta.dx > 350.w) {
return;
}
leftWidth = leftWidth + details.delta.dx;
Expand Down
Loading

0 comments on commit 11ef06e

Please sign in to comment.