Initial commit: Flutter app + PHP/MySQL backend on Hostinger
Replaces Firebase with a self-hosted PHP/MySQL API served from winded.prymsolutions.com. Includes full backend (schema, auth, events, teams, brackets, suggestions, stats, media, file upload) and updated Flutter repositories and domain models. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../auth/application/auth_notifier.dart';
|
||||
import '../domain/suggestion.dart';
|
||||
import '../infrastructure/suggestions_repository.dart';
|
||||
|
||||
part 'suggestions_notifier.g.dart';
|
||||
|
||||
/// Tracks the submission lifecycle of the suggestion form.
|
||||
///
|
||||
/// State is an `AsyncValue<void>`:
|
||||
/// * idle → `AsyncData(null)` after [build]
|
||||
/// * busy → `AsyncLoading()` while a submit is in flight
|
||||
/// * done → `AsyncData(null)` after a successful submit
|
||||
/// * error → `AsyncError(...)` on failure
|
||||
@riverpod
|
||||
class SuggestionsNotifier extends _$SuggestionsNotifier {
|
||||
@override
|
||||
Future<void> build() async {
|
||||
return;
|
||||
}
|
||||
|
||||
/// Submits a suggestion. UI should already have validated [text] length
|
||||
/// before calling — this method does not re-validate.
|
||||
Future<void> submit({
|
||||
required String text,
|
||||
required bool isAnonymous,
|
||||
String? userId,
|
||||
String? displayName,
|
||||
}) async {
|
||||
final repo = ref.read(suggestionsRepositoryProvider);
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(() async {
|
||||
await repo.submitSuggestion(
|
||||
text: text.trim(),
|
||||
isAnonymous: isAnonymous,
|
||||
userId: isAnonymous ? null : userId,
|
||||
displayName: isAnonymous ? null : displayName,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Streams the current user's previously-submitted suggestions.
|
||||
///
|
||||
/// Emits an empty list when the user is signed out, so the UI can render a
|
||||
/// stable widget tree without juggling auth-vs-stream loading states.
|
||||
@riverpod
|
||||
Stream<List<Suggestion>> userSuggestions(UserSuggestionsRef ref) async* {
|
||||
final auth = ref.watch(authNotifierProvider);
|
||||
final user = auth.valueOrNull;
|
||||
if (user == null) {
|
||||
yield <Suggestion>[];
|
||||
return;
|
||||
}
|
||||
final repo = ref.watch(suggestionsRepositoryProvider);
|
||||
yield* repo.watchUserSuggestions(user.uid);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'suggestions_notifier.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$userSuggestionsHash() => r'8544dca51c0cb3453bfc7219fde2ec43e55b3106';
|
||||
|
||||
/// Streams the current user's previously-submitted suggestions.
|
||||
///
|
||||
/// Emits an empty list when the user is signed out, so the UI can render a
|
||||
/// stable widget tree without juggling auth-vs-stream loading states.
|
||||
///
|
||||
/// Copied from [userSuggestions].
|
||||
@ProviderFor(userSuggestions)
|
||||
final userSuggestionsProvider =
|
||||
AutoDisposeStreamProvider<List<Suggestion>>.internal(
|
||||
userSuggestions,
|
||||
name: r'userSuggestionsProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$userSuggestionsHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef UserSuggestionsRef = AutoDisposeStreamProviderRef<List<Suggestion>>;
|
||||
String _$suggestionsNotifierHash() =>
|
||||
r'f7a4d35220e955e11bbd10872c8e2d838cc1a3a7';
|
||||
|
||||
/// Tracks the submission lifecycle of the suggestion form.
|
||||
///
|
||||
/// State is an `AsyncValue<void>`:
|
||||
/// * idle → `AsyncData(null)` after [build]
|
||||
/// * busy → `AsyncLoading()` while a submit is in flight
|
||||
/// * done → `AsyncData(null)` after a successful submit
|
||||
/// * error → `AsyncError(...)` on failure
|
||||
///
|
||||
/// Copied from [SuggestionsNotifier].
|
||||
@ProviderFor(SuggestionsNotifier)
|
||||
final suggestionsNotifierProvider =
|
||||
AutoDisposeAsyncNotifierProvider<SuggestionsNotifier, void>.internal(
|
||||
SuggestionsNotifier.new,
|
||||
name: r'suggestionsNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$suggestionsNotifierHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$SuggestionsNotifier = AutoDisposeAsyncNotifier<void>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
Reference in New Issue
Block a user