mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: npub1shglkdhngx3hrnhf4gf8vhpqdrmeludctechdvpwd3988zzs7ncq2cmtxu <85d1fb36f341a371cee9aa12765c2068f79ff1b85e7176b02e6c4a738850f4f0@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1shglkdhngx3hrnhf4gf8vhpqdrmeludctechdvpwd3988zzs7ncq2cmtxu <85d1fb36f341a371cee9aa12765c2068f79ff1b85e7176b02e6c4a738850f4f0@sprout-oss.stage.blox.sqprod.co>
39 lines
991 B
Dart
39 lines
991 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'channel.dart';
|
|
import 'channel_detail_page.dart';
|
|
import 'channels_provider.dart';
|
|
|
|
void openChannelLink({
|
|
required BuildContext context,
|
|
required WidgetRef ref,
|
|
required String channelId,
|
|
required String currentChannelId,
|
|
}) {
|
|
if (channelId == currentChannelId) return;
|
|
|
|
final channelsAsync = ref.read(channelsProvider);
|
|
final channels = channelsAsync.hasValue ? channelsAsync.value : null;
|
|
Channel? targetChannel;
|
|
for (final channel in channels ?? const <Channel>[]) {
|
|
if (channel.id == channelId) {
|
|
targetChannel = channel;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (targetChannel == null) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Channel could not be opened')),
|
|
);
|
|
return;
|
|
}
|
|
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) => ChannelDetailPage(channel: targetChannel!),
|
|
),
|
|
);
|
|
}
|