kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add initial settings screen with low BW moved to it
rodzic
02432a0a6e
commit
3401d51c3c
|
|
@ -11,6 +11,7 @@ import 'screens/menus_screen.dart';
|
|||
import 'screens/notifications_screen.dart';
|
||||
import 'screens/post_screen.dart';
|
||||
import 'screens/profile_screen.dart';
|
||||
import 'screens/settings_screen.dart';
|
||||
import 'screens/sign_in.dart';
|
||||
import 'screens/splash.dart';
|
||||
import 'screens/user_posts_screen.dart';
|
||||
|
|
@ -22,13 +23,13 @@ class ScreenPaths {
|
|||
static String contacts = '/contacts';
|
||||
static String splash = '/splash';
|
||||
static String menu = '/menu';
|
||||
static String settings = '/settings';
|
||||
static String timelines = '/';
|
||||
static String gallery = '/gallery';
|
||||
static String profile = '/profile';
|
||||
static String notifications = '/notifications';
|
||||
static String signin = '/signin';
|
||||
static String signup = '/signup';
|
||||
static String settings = '/settings';
|
||||
static String userProfile = '/user_profile';
|
||||
static String userPosts = '/user_posts';
|
||||
}
|
||||
|
|
@ -99,6 +100,13 @@ final appRouter = GoRouter(
|
|||
child: MenusScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ScreenPaths.settings,
|
||||
name: ScreenPaths.settings,
|
||||
pageBuilder: (context, state) => NoTransitionPage(
|
||||
child: SettingsScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ScreenPaths.gallery,
|
||||
name: ScreenPaths.gallery,
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ class MenusScreen extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final items = [
|
||||
final menuItems = [
|
||||
buildMenuButton('Gallery', () => context.pushNamed(ScreenPaths.gallery)),
|
||||
buildMenuButton('Profile', () => context.pushNamed(ScreenPaths.profile)),
|
||||
buildMenuButton(
|
||||
'Settings', () => context.pushNamed(ScreenPaths.settings)),
|
||||
buildMenuButton('Logout', () async {
|
||||
final confirm = await showYesNoDialog(context, 'Log out account?');
|
||||
if (confirm == true) {
|
||||
|
|
@ -26,13 +28,12 @@ class MenusScreen extends StatelessWidget {
|
|||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: GridView.builder(
|
||||
itemCount: items.length,
|
||||
child: GridView(
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisExtent: menuButtonHeight,
|
||||
maxCrossAxisExtent: menuButtonWidth,
|
||||
),
|
||||
itemBuilder: (context, index) => items[index],
|
||||
children: menuItems,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../controls/padding.dart';
|
||||
import '../controls/standard_appbar.dart';
|
||||
import '../services/auth_service.dart';
|
||||
import '../services/setting_service.dart';
|
||||
|
||||
class ProfileScreen extends StatefulWidget {
|
||||
const ProfileScreen({super.key});
|
||||
|
|
@ -16,7 +14,6 @@ class ProfileScreen extends StatefulWidget {
|
|||
class _ProfileScreenState extends State<ProfileScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settings = context.watch<SettingsService>();
|
||||
final authService = context.watch<AuthService>();
|
||||
return Scaffold(
|
||||
appBar: StandardAppBar.build(context, 'Profile'),
|
||||
|
|
@ -24,25 +21,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: settings.lowBandwidthMode,
|
||||
onChanged: (value) =>
|
||||
settings.lowBandwidthMode = value ?? false,
|
||||
),
|
||||
const Text('Low Bandwidth Mode'),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
'Profile: ${authService.currentClient.fold(onSuccess: (client) => client.credentials.handle, onError: (error) => 'Error Getting Profile')}'),
|
||||
const VerticalPadding(),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await authService.signOut();
|
||||
},
|
||||
child: const Text('Sign Out')),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:friendica_portal/services/setting_service.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../controls/standard_appbar.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settings = context.watch<SettingsService>();
|
||||
return Scaffold(
|
||||
appBar: StandardAppBar.build(context, 'Settings'),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView(
|
||||
children: [
|
||||
buildLowBandwidthWidget(settings),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget buildLowBandwidthWidget(SettingsService settings) {
|
||||
return ListTile(
|
||||
title: const Text('Low bandwidth mode'),
|
||||
trailing: Checkbox(
|
||||
onChanged: (value) {
|
||||
settings.lowBandwidthMode = value ?? false;
|
||||
},
|
||||
value: settings.lowBandwidthMode,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Ładowanie…
Reference in New Issue