mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-01 02:02:35 +01:00
Online-gate the exercise submission page/links
This commit is contained in:
@@ -48,11 +48,7 @@ class AddExerciseScreen extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final account = ref.watch(accountProvider).value;
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
if (account == null) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
if (!isOnline) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -77,6 +73,10 @@ class AddExerciseScreen extends ConsumerWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
final account = ref.watch(accountProvider).value;
|
||||
if (account == null) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
return account.isTrustworthy ? const AddExerciseStepper() : const EmailNotVerified();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/auth_notifier.dart';
|
||||
import 'package:wger/providers/network_provider.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
|
||||
import 'log_overview.dart';
|
||||
@@ -51,6 +52,7 @@ class AboutPage extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final authState = ref.watch(authProvider).value;
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final today = DateTime.now();
|
||||
|
||||
@@ -125,10 +127,16 @@ class AboutPage extends ConsumerWidget {
|
||||
onTap: () => launchURL(GITHUB_PROJECT_URL, context),
|
||||
),
|
||||
ListTile(
|
||||
enabled: isOnline,
|
||||
leading: const FaIcon(FontAwesomeIcons.dumbbell, size: 18),
|
||||
title: Text(i18n.contributeExercise),
|
||||
trailing: isOnline
|
||||
? null
|
||||
: Icon(Icons.cloud_off, color: Theme.of(context).colorScheme.outline),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onTap: () => Navigator.of(context).pushNamed(AddExerciseScreen.routeName),
|
||||
onTap: isOnline
|
||||
? () => Navigator.of(context).pushNamed(AddExerciseScreen.routeName)
|
||||
: null,
|
||||
),
|
||||
|
||||
// Don't show the donate section under iOS. The app was rejected once because
|
||||
|
||||
@@ -25,6 +25,7 @@ import 'package:wger/models/core/search_options.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/providers/exercise_filters_riverpod.dart';
|
||||
import 'package:wger/providers/exercises_notifier.dart';
|
||||
import 'package:wger/providers/network_provider.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
import 'package:wger/widgets/exercises/exercise_filter_dialog.dart';
|
||||
import 'package:wger/widgets/exercises/images.dart';
|
||||
@@ -110,6 +111,7 @@ class _ExerciseAutocompleterState extends ConsumerState<ExerciseAutocompleter> {
|
||||
),
|
||||
),
|
||||
emptyBuilder: (context) {
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -118,10 +120,23 @@ class _ExerciseAutocompleterState extends ConsumerState<ExerciseAutocompleter> {
|
||||
),
|
||||
ListTile(
|
||||
title: OutlinedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(AddExerciseScreen.routeName);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
onPressed: isOnline
|
||||
? () => Navigator.of(context).pushNamed(AddExerciseScreen.routeName)
|
||||
: null,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (!isOnline) ...[
|
||||
Icon(
|
||||
Icons.cloud_off,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
Text(AppLocalizations.of(context).contributeExercise),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
import 'package:wger/providers/exercise_filters_notifier.dart';
|
||||
import 'package:wger/providers/network_provider.dart';
|
||||
import 'package:wger/screens/add_exercise_screen.dart';
|
||||
|
||||
import 'filter_modal.dart';
|
||||
@@ -57,6 +58,7 @@ class _FilterRowState extends ConsumerState<FilterRow> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 15),
|
||||
child: Row(
|
||||
@@ -95,7 +97,21 @@ class _FilterRowState extends ConsumerState<FilterRow> {
|
||||
return [
|
||||
PopupMenuItem<ExerciseMoreOption>(
|
||||
value: ExerciseMoreOption.ADD_EXERCISE,
|
||||
child: Text(AppLocalizations.of(context).contributeExercise),
|
||||
enabled: isOnline,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).contributeExercise),
|
||||
if (!isOnline) ...[
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
Icons.cloud_off,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
@@ -38,12 +38,13 @@ enum _RoutineDetailBarOptions {
|
||||
logs,
|
||||
}
|
||||
|
||||
class RoutineListAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
class RoutineListAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
||||
const RoutineListAppBar();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final i18n = AppLocalizations.of(context);
|
||||
final isOnline = ref.watch(networkStatusProvider);
|
||||
|
||||
return AppBar(
|
||||
title: Text(i18n.routines),
|
||||
@@ -57,7 +58,21 @@ class RoutineListAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
),
|
||||
PopupMenuItem<_RoutineAppBarOptions>(
|
||||
value: _RoutineAppBarOptions.contribute,
|
||||
child: Text(i18n.contributeExercise),
|
||||
enabled: isOnline,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(i18n.contributeExercise),
|
||||
if (!isOnline) ...[
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
Icons.cloud_off,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user