Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3842,5 +3842,6 @@
"chatFont": "Chat font",
"chatFontFallback": "Fallback chat fonts",
"openMessageSource": "Remote message",
"showProfileSource": "Profile data"
"showProfileSource": "Profile data",
"enableFloatingAppBar": "Floating chat app bar"
}
3 changes: 2 additions & 1 deletion assets/l10n/intl_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3913,5 +3913,6 @@
"monospaceFontFallback": "Дополнительные моноширинные шрифты",
"chatFont": "Шрифт чата",
"chatFontFallback": "Дополнительные шрифты чата",
"openMessageSource": "Исходное сообщение"
"openMessageSource": "Исходное сообщение",
"enableFloatingAppBar": "Плавающий заголовок чата"
}
1 change: 1 addition & 0 deletions lib/config/setting_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ enum AppSettings<T> {
audioRecordingSamplingRate<int>('audioRecordingSamplingRate', 44100),
enableVideoNotes<bool>('xyz.extera.next.enableVideoNotes', false),
enableChatFrostedGlass<bool>('xyz.extera.next.enableChatFrostedGlass', false),
enableFloatingAppBar<bool>('xyz.extera.enableFloatingAppBar', true),
showSeconds<bool>('xyz.extera.showSeconds', false),
enableAppBarCenterTitle<bool>(
'xyz.extera.next.enableAppBarCenterTitle',
Expand Down
140 changes: 140 additions & 0 deletions lib/pages/chat/chat_floating_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import 'package:extera_next/config/setting_keys.dart';
import 'package:extera_next/config/themes.dart';
import 'package:extera_next/generated/l10n/l10n.dart';
import 'package:extera_next/pages/chat/chat.dart';
import 'package:extera_next/pages/chat/chat_app_bar_title.dart';
import 'package:extera_next/pages/chat/pinned_events.dart';
import 'package:extera_next/utils/stream_extension.dart';
import 'package:extera_next/widgets/matrix.dart';
import 'package:extera_next/widgets/unread_rooms_badge.dart';

class FloatingChatAppbar extends StatelessWidget implements PreferredSizeWidget {
final ChatController controller;
final double appbarBottomHeight;
final List<Widget> actions;

const FloatingChatAppbar({
super.key,
required this.controller,
required this.appbarBottomHeight,
required this.actions,
});

@override
Size get preferredSize =>
Size.fromHeight(kToolbarHeight + appbarBottomHeight + 8);

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 4),
child: (() {
final appBar = AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
surfaceTintColor: Colors.transparent,
shadowColor: Colors.transparent,
actionsIconTheme: IconThemeData(
color: controller.selectedEvents.isEmpty
? null
: theme.colorScheme.tertiary,
),
automaticallyImplyLeading: false,
centerTitle: AppSettings.enableAppBarCenterTitle.value,
leading: controller.selectMode
? IconButton(
icon: const Icon(Icons.close),
onPressed: controller.clearSelectedEvents,
tooltip: L10n.of(context).close,
color: theme.colorScheme.tertiary,
)
: FluffyThemes.isColumnMode(context)
? null
: StreamBuilder<Object>(
stream: Matrix.of(context).client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, _) => UnreadRoomsBadge(
filter: (r) => r.id != controller.roomId,
badgePosition: .topEnd(top: 4, end: 8),
child: const Center(child: BackButton()),
),
),
titleSpacing: FluffyThemes.isColumnMode(context) ? 24 : 0,
title: ChatAppBarTitle(controller),
actions: actions,
bottom: PreferredSize(
preferredSize: Size.fromHeight(appbarBottomHeight),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [PinnedEvents(controller)],
),
),
);
return AppSettings.enableChatFrostedGlass.value
? _FloatingAppBar(child: appBar)
: Material(
clipBehavior: Clip.hardEdge,
color: theme.colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(24),
child: appBar,
);
})(),
),
);
}
}

class _FloatingAppBar extends StatelessWidget {
final Widget child;

const _FloatingAppBar({
required this.child,
});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(
theme.brightness == Brightness.dark ? 60 : 20,
),
blurRadius: 24,
offset: const Offset(0, 4),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: BackdropFilter(
filter: ui.ImageFilter.blur(sigmaX: 12, sigmaY: 12),
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface.withAlpha(
theme.brightness == Brightness.dark ? 180 : 200,
),
border: Border(
bottom: BorderSide(
color: theme.colorScheme.outlineVariant.withAlpha(80),
width: 0.5,
),
),
),
child: child,
),
),
),
);
}
}
105 changes: 105 additions & 0 deletions lib/pages/chat/chat_legacy_app_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import 'package:extera_next/config/setting_keys.dart';
import 'package:extera_next/config/themes.dart';
import 'package:extera_next/generated/l10n/l10n.dart';
import 'package:extera_next/pages/chat/chat.dart';
import 'package:extera_next/pages/chat/chat_app_bar_title.dart';
import 'package:extera_next/pages/chat/pinned_events.dart';
import 'package:extera_next/utils/stream_extension.dart';
import 'package:extera_next/widgets/matrix.dart';
import 'package:extera_next/widgets/unread_rooms_badge.dart';

class ChatLegacyAppBar extends StatelessWidget implements PreferredSizeWidget {
final ChatController controller;
final double appbarBottomHeight;
final List<Widget> actions;

const ChatLegacyAppBar({
super.key,
required this.controller,
required this.appbarBottomHeight,
required this.actions
});

@override
Size get preferredSize =>
Size.fromHeight(kToolbarHeight + appbarBottomHeight);

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AppBar(
backgroundColor: AppSettings.enableChatFrostedGlass.value
? Colors.transparent
: null,
elevation: AppSettings.enableChatFrostedGlass.value ? 0 : null,
shape: FluffyThemes.isColumnMode(context)
? Border(
bottom: BorderSide(color: theme.dividerColor, width: 1),
)
: null,
scrolledUnderElevation: AppSettings.enableChatFrostedGlass.value
? 0
: null,
flexibleSpace: AppSettings.enableChatFrostedGlass.value
? ClipRect(
child: BackdropFilter(
filter: ui.ImageFilter.blur(sigmaX: 20, sigmaY: 20),
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface.withAlpha(
theme.brightness == Brightness.dark ? 180 : 200,
),
border: Border(
bottom: BorderSide(
color: theme.colorScheme.outlineVariant
.withAlpha(80),
width: 0.5,
),
),
),
),
),
)
: null,
actionsIconTheme: IconThemeData(
color: controller.selectedEvents.isEmpty
? null
: theme.colorScheme.tertiary,
),
automaticallyImplyLeading: false,
centerTitle: AppSettings.enableAppBarCenterTitle.value,
leading: controller.selectMode
? IconButton(
icon: const Icon(Icons.close),
onPressed: controller.clearSelectedEvents,
tooltip: L10n.of(context).close,
color: theme.colorScheme.tertiary,
)
: FluffyThemes.isColumnMode(context)
? null
: StreamBuilder<Object>(
stream: Matrix.of(context).client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, _) => UnreadRoomsBadge(
filter: (r) => r.id != controller.roomId,
badgePosition: .topEnd(top: 4, end: 8),
child: const Center(child: BackButton()),
),
),
titleSpacing: FluffyThemes.isColumnMode(context) ? 24 : 0,
title: ChatAppBarTitle(controller),
actions: actions,
bottom: PreferredSize(
preferredSize: Size.fromHeight(appbarBottomHeight),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [PinnedEvents(controller)],
),
),
);
}
}
Loading