Skip to content

Commit

Permalink
improve forum support
Browse files Browse the repository at this point in the history
  • Loading branch information
EricApostal committed Dec 17, 2024
1 parent fed0b9c commit ba24d18
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 134 deletions.
1 change: 0 additions & 1 deletion bonfire/lib/features/auth/views/switcher.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:bonfire/features/auth/views/credentials.dart';
import 'package:bonfire/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down
98 changes: 37 additions & 61 deletions bonfire/lib/features/forum/views/components/card/card.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:bonfire/features/forum/controllers/forum.dart';
import 'package:bonfire/features/forum/repositories/forum_posts.dart';
import 'package:bonfire/theme/theme.dart';
import 'package:firebridge/firebridge.dart';
import 'package:flutter/material.dart';
Expand All @@ -24,19 +23,8 @@ class _ThreadCardState extends ConsumerState<ThreadCard> {
@override
void initState() {
super.initState();
// widget.scrollController.addListener(_onScroll);
}

// void _onScroll() {
// if (widget.scrollController.position.pixels >=
// widget.scrollController.position.maxScrollExtent - 200) {
// final forumPosts = ref.read(forumPostsProvider(widget.threadId).notifier);
// if (forumPosts.hasMore) {
// forumPosts.loadMore();
// }
// }
// }

@override
Widget build(BuildContext context) {
// a bit of a hack, this can probably be done using other thread types so that should be handled
Expand All @@ -62,61 +50,49 @@ class _ThreadCardState extends ConsumerState<ThreadCard> {
context.go(
"/channels/${thread.guildId}/${widget.channelId}/threads/${thread.id}/");
},
child: Container(
decoration: BoxDecoration(
// color: Theme.of(context).custom.colorTheme.foreground,
// borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
thread.name,
style: Theme.of(context).custom.textTheme.titleSmall,
),
if (previewMessage != null)
ConstrainedBox(
constraints:
const BoxConstraints(maxHeight: 50, minHeight: 0),
child: Text(
previewMessage.content,
style: Theme.of(context).custom.textTheme.bodyText2,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
thread.name,
style: Theme.of(context).custom.textTheme.titleSmall,
),
if (previewMessage != null)
ConstrainedBox(
constraints:
const BoxConstraints(maxHeight: 50, minHeight: 0),
child: Text(
previewMessage.content,
style: Theme.of(context).custom.textTheme.bodyText2,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
],
),
),
],
),
if (previewMessage?.attachments.isNotEmpty == true &&
previewMessage!.attachments.first.contentType
?.split("/")[0] ==
"image")
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
previewMessage.attachments.first.url.toString(),
width: 80,
height: 80,
fit: BoxFit.cover,
),
),
if (previewMessage?.attachments.isNotEmpty == true &&
previewMessage!.attachments.first.contentType
?.split("/")[0] ==
"image")
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
previewMessage.attachments.first.url.toString(),
width: 80,
height: 80,
fit: BoxFit.cover,
),
],
),
),
],
),
),
),
);
}

@override
void dispose() {
// widget.scrollController.removeListener(_onScroll);
super.dispose();
}
}
2 changes: 1 addition & 1 deletion bonfire/lib/features/forum/views/forum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _ForumViewState extends ConsumerState<ForumView> {
data: (threadLists) {
// Combine all threads from the list of ThreadLists
threads = threadLists.expand((threadList) {
return (threadList?.threads ?? []) as List<Channel>;
return threadList?.threads ?? [] as List<Channel>;
}).toList();

return Stack(
Expand Down
1 change: 0 additions & 1 deletion bonfire/lib/features/friends/views/friend_card.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:bonfire/features/me/controllers/settings.dart';
import 'package:bonfire/features/user/components/presence_avatar.dart';
import 'package:bonfire/features/user/controllers/presence.dart';
import 'package:bonfire/shared/widgets/presence_text.dart';
Expand Down
2 changes: 1 addition & 1 deletion bonfire/lib/features/me/views/components/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MessageView extends ConsumerStatefulWidget {
class _MessageViewState extends ConsumerState<MessageView> {
@override
Widget build(BuildContext context) {
var channelId = widget.channelId;
Snowflake channelId = widget.channelId;
if (widget.threadId != null) {
channelId = widget.threadId!;
}
Expand Down
54 changes: 26 additions & 28 deletions bonfire/lib/features/messaging/views/components/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,35 +237,33 @@ class _MessageViewState extends ConsumerState<MessageList>
channelName = getChannelName(channel);

return Scaffold(
body: Container(
child: Column(
children: [
Expanded(
child: Stack(
children: [
FadeTransition(
opacity: _fadeAnimation,
child: Align(
alignment: Alignment.bottomLeft,
child: content,
)),
if (!isSmartwatch(context))
ChannelHeader(channelName: channelName),
],
),
body: Column(
children: [
Expanded(
child: Stack(
children: [
FadeTransition(
opacity: _fadeAnimation,
child: Align(
alignment: Alignment.bottomLeft,
child: content,
)),
if (!isSmartwatch(context))
ChannelHeader(channelName: channelName),
],
),
if (!isSmartwatch(context))
MessageBar(
guildId: guild?.id ?? Snowflake.zero,
channel: channel,
),
if (!isSmartwatch(context))
SizedBox(
height: MediaQuery.of(context).padding.bottom,
),
if (!isSmartwatch(context)) const KeyboardBuffer()
],
),
),
if (!isSmartwatch(context))
MessageBar(
guildId: guild?.id ?? Snowflake.zero,
channel: channel,
),
if (!isSmartwatch(context))
SizedBox(
height: MediaQuery.of(context).padding.bottom,
),
if (!isSmartwatch(context)) const KeyboardBuffer()
],
),
);
}
Expand Down
14 changes: 5 additions & 9 deletions bonfire/lib/features/overview/views/overlapping_panels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class OverlappingPanelsState extends State<OverlappingPanels>
goal = _calculateGoal(mediaWidth, -1);
break;
case RevealSide.main:
default:
goal = 0;
break;
}
Expand All @@ -133,25 +132,22 @@ class OverlappingPanelsState extends State<OverlappingPanels>
void _onApplyTranslation() {
final mediaWidth = MediaQuery.of(context).size.width;

var _averagedDelta = (_lastDelta + _lastLastDelta) / 2;
print("LastDelta $_lastDelta");
print("LastLastDelta $_lastLastDelta");
print("AveragedDelta $_averagedDelta");
double averagedDelta = (_lastDelta + _lastLastDelta) / 2;

var goal = 0.0;
if (_averagedDelta > 0) {
if (averagedDelta > 0) {
goal = _calculateGoal(mediaWidth, 1);
}

if (_averagedDelta < 0) {
if (averagedDelta < 0) {
goal = _calculateGoal(mediaWidth, -1);
}

if (_averagedDelta > 0 && _translate < 0) {
if (averagedDelta > 0 && _translate < 0) {
goal = 0;
}

if (_averagedDelta < 0 && _translate > 0) {
if (averagedDelta < 0 && _translate > 0) {
goal = 0;
}

Expand Down
26 changes: 13 additions & 13 deletions bonfire/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1005,52 +1005,52 @@ packages:
path: media_kit
ref: "652c49e02701bb6bb80953a6fdf650a5c8f002f9"
resolved-ref: "652c49e02701bb6bb80953a6fdf650a5c8f002f9"
url: "https://github.com/media-kit/media-kit"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.1.11"
media_kit_libs_android_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_android_video
sha256: "9dd8012572e4aff47516e55f2597998f0a378e3d588d0fad0ca1f11a53ae090c"
url: "https://pub.dev"
source: hosted
version: "1.3.6"
media_kit_libs_ios_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_ios_video
sha256: b5382994eb37a4564c368386c154ad70ba0cc78dacdd3fb0cd9f30db6d837991
url: "https://pub.dev"
source: hosted
version: "1.1.4"
media_kit_libs_linux:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_linux
sha256: e186891c31daa6bedab4d74dcdb4e8adfccc7d786bfed6ad81fe24a3b3010310
url: "https://pub.dev"
source: hosted
version: "1.1.3"
media_kit_libs_macos_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_macos_video
sha256: f26aa1452b665df288e360393758f84b911f70ffb3878032e1aabba23aa1032d
url: "https://pub.dev"
source: hosted
version: "1.1.4"
media_kit_libs_video:
dependency: "direct overridden"
dependency: "direct main"
description:
path: "libs/universal/media_kit_libs_video"
ref: "652c49e02701bb6bb80953a6fdf650a5c8f002f9"
resolved-ref: "652c49e02701bb6bb80953a6fdf650a5c8f002f9"
url: "https://github.com/media-kit/media-kit"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.0.5"
media_kit_libs_windows_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_windows_video
sha256: "32654572167825c42c55466f5d08eee23ea11061c84aa91b09d0e0f69bdd0887"
Expand All @@ -1071,7 +1071,7 @@ packages:
path: media_kit_video
ref: "652c49e02701bb6bb80953a6fdf650a5c8f002f9"
resolved-ref: "652c49e02701bb6bb80953a6fdf650a5c8f002f9"
url: "https://github.com/media-kit/media-kit"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.2.5"
meta:
Expand Down Expand Up @@ -1134,18 +1134,18 @@ packages:
dependency: transitive
description:
name: package_info_plus
sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918
sha256: "70c421fe9d9cc1a9a7f3b05ae56befd469fe4f8daa3b484823141a55442d858d"
url: "https://pub.dev"
source: hosted
version: "8.0.2"
version: "8.1.2"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: ac1f4a4847f1ade8e6a87d1f39f5d7c67490738642e2542f559ec38c37489a66
sha256: a5ef9986efc7bf772f2696183a3992615baa76c1ffb1189318dd8803778fb05b
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
path:
dependency: "direct main"
description:
Expand Down
Loading

0 comments on commit ba24d18

Please sign in to comment.