- Replace NULLIF with CASE WHEN for proper UUID casting - Fix missing ::uuid casting in WHERE clauses - Resolve 'operator does not exist: uuid = text' errors - Focus on post_repository.go, notification_repository.go, and category_repository.go
113 lines
2.6 KiB
Dart
113 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
enum HeaderMode { feed, context }
|
|
|
|
class HeaderState {
|
|
final HeaderMode mode;
|
|
final String title;
|
|
final VoidCallback? onBack;
|
|
final VoidCallback? onRefresh;
|
|
final List<Widget> trailingActions;
|
|
|
|
const HeaderState({
|
|
required this.mode,
|
|
required this.title,
|
|
this.onBack,
|
|
this.onRefresh,
|
|
this.trailingActions = const [],
|
|
});
|
|
|
|
HeaderState copyWith({
|
|
HeaderMode? mode,
|
|
String? title,
|
|
VoidCallback? onBack,
|
|
VoidCallback? onRefresh,
|
|
List<Widget>? trailingActions,
|
|
}) {
|
|
return HeaderState(
|
|
mode: mode ?? this.mode,
|
|
title: title ?? this.title,
|
|
onBack: onBack ?? this.onBack,
|
|
onRefresh: onRefresh ?? this.onRefresh,
|
|
trailingActions: trailingActions ?? this.trailingActions,
|
|
);
|
|
}
|
|
|
|
factory HeaderState.feed({
|
|
VoidCallback? onRefresh,
|
|
List<Widget> trailingActions = const [],
|
|
}) {
|
|
return HeaderState(
|
|
mode: HeaderMode.feed,
|
|
title: 'sojorn',
|
|
onRefresh: onRefresh,
|
|
trailingActions: trailingActions,
|
|
);
|
|
}
|
|
|
|
factory HeaderState.context({
|
|
required String title,
|
|
VoidCallback? onBack,
|
|
VoidCallback? onRefresh,
|
|
List<Widget> trailingActions = const [],
|
|
}) {
|
|
return HeaderState(
|
|
mode: HeaderMode.context,
|
|
title: title,
|
|
onBack: onBack,
|
|
onRefresh: onRefresh,
|
|
trailingActions: trailingActions,
|
|
);
|
|
}
|
|
}
|
|
|
|
class HeaderController extends ChangeNotifier {
|
|
HeaderState _state = HeaderState.feed();
|
|
VoidCallback? _feedRefresh;
|
|
List<Widget> _feedTrailingActions = const [];
|
|
|
|
HeaderState get state => _state;
|
|
|
|
void configureFeed({
|
|
VoidCallback? onRefresh,
|
|
List<Widget> trailingActions = const [],
|
|
}) {
|
|
_feedRefresh = onRefresh;
|
|
_feedTrailingActions = trailingActions;
|
|
if (_state.mode == HeaderMode.feed) {
|
|
_state = HeaderState.feed(
|
|
onRefresh: _feedRefresh,
|
|
trailingActions: _feedTrailingActions,
|
|
);
|
|
notifyListeners();
|
|
}
|
|
}
|
|
|
|
void setFeed() {
|
|
_state = HeaderState.feed(
|
|
onRefresh: _feedRefresh,
|
|
trailingActions: _feedTrailingActions,
|
|
);
|
|
notifyListeners();
|
|
}
|
|
|
|
void setContext({
|
|
required String title,
|
|
VoidCallback? onBack,
|
|
VoidCallback? onRefresh,
|
|
List<Widget> trailingActions = const [],
|
|
}) {
|
|
_state = HeaderState.context(
|
|
title: title,
|
|
onBack: onBack,
|
|
onRefresh: onRefresh,
|
|
trailingActions: trailingActions,
|
|
);
|
|
notifyListeners();
|
|
}
|
|
}
|
|
|
|
final headerControllerProvider =
|
|
ChangeNotifierProvider<HeaderController>((ref) => HeaderController());
|