mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
address mobile review feedback
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -143,13 +143,29 @@ class _CommunitySwitcherSheet extends HookConsumerWidget {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
onRemove: () => _confirmRemoveCommunity(
|
||||
context,
|
||||
ref,
|
||||
communities[index],
|
||||
closeSheetAfterRemoval:
|
||||
communities[index].id == activeId,
|
||||
),
|
||||
onRemove: () {
|
||||
final community = communities[index];
|
||||
final nextCommunity = community.id == activeId
|
||||
? communities
|
||||
.where(
|
||||
(candidate) =>
|
||||
candidate.id != community.id,
|
||||
)
|
||||
.firstOrNull
|
||||
: null;
|
||||
unawaited(
|
||||
_confirmRemoveCommunity(
|
||||
context,
|
||||
ref,
|
||||
community,
|
||||
closeSheetAfterRemoval:
|
||||
community.id == activeId,
|
||||
nextCommunityId: nextCommunity?.id,
|
||||
onCommunitySwitchStart:
|
||||
onCommunitySwitchStart,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
if (communities.isNotEmpty)
|
||||
@@ -447,6 +463,8 @@ Future<void> _confirmRemoveCommunity(
|
||||
WidgetRef ref,
|
||||
Community community, {
|
||||
required bool closeSheetAfterRemoval,
|
||||
required String? nextCommunityId,
|
||||
ValueChanged<String?>? onCommunitySwitchStart,
|
||||
}) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
@@ -473,6 +491,7 @@ Future<void> _confirmRemoveCommunity(
|
||||
if (confirmed != true || !context.mounted) return;
|
||||
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
onCommunitySwitchStart?.call(nextCommunityId);
|
||||
try {
|
||||
await ref
|
||||
.read(communityListProvider.notifier)
|
||||
@@ -481,6 +500,7 @@ Future<void> _confirmRemoveCommunity(
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} catch (e) {
|
||||
onCommunitySwitchStart?.call(null);
|
||||
messenger.showSnackBar(
|
||||
SnackBar(content: Text('Failed to remove community: $e')),
|
||||
);
|
||||
|
||||
@@ -4,30 +4,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
import 'frosted_header_scroll_state.dart';
|
||||
|
||||
/// Minimum height of the frosted app bar content area below the safe area.
|
||||
const _kBarContentMinHeight = Grid.xxs + 32 + Grid.xxs; // 48
|
||||
const _kBottomBorderWidth = 1.0;
|
||||
|
||||
/// Shares the scroll elevation state from [FrostedScaffold] with its header.
|
||||
/// Keeping this separate lets all of the existing page bodies continue to own
|
||||
/// their scroll views.
|
||||
class FrostedHeaderScrollState extends InheritedNotifier<ValueNotifier<bool>> {
|
||||
const FrostedHeaderScrollState({
|
||||
required super.notifier,
|
||||
required super.child,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static bool isScrolledOf(BuildContext context) {
|
||||
return context
|
||||
.dependOnInheritedWidgetOfExactType<FrostedHeaderScrollState>()
|
||||
?.notifier
|
||||
?.value ??
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
||||
TextStyle _effectiveTitleStyle(BuildContext context, TextStyle? titleStyle) {
|
||||
final baseStyle =
|
||||
context.textTheme.titleMedium ??
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Shares the scroll elevation state from [FrostedScaffold] with its header.
|
||||
/// Keeping this separate lets all of the existing page bodies continue to own
|
||||
/// their scroll views.
|
||||
class FrostedHeaderScrollState extends InheritedNotifier<ValueNotifier<bool>> {
|
||||
const FrostedHeaderScrollState({
|
||||
required super.notifier,
|
||||
required super.child,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static bool isScrolledOf(BuildContext context) {
|
||||
return context
|
||||
.dependOnInheritedWidgetOfExactType<FrostedHeaderScrollState>()
|
||||
?.notifier
|
||||
?.value ??
|
||||
false;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
||||
import 'frosted_app_bar.dart';
|
||||
import 'frosted_header_scroll_state.dart';
|
||||
|
||||
/// A convenience [Scaffold] that overlays a [FrostedAppBar] on top of its body.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user