Skip to content

Commit

Permalink
feat: add media settings UI (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo2Hefny authored Dec 20, 2024
1 parent eba29a7 commit 2f9d470
Show file tree
Hide file tree
Showing 4 changed files with 478 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/core/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import 'package:telware_cross_platform/features/user/view/screens/blocked_users.
import 'package:telware_cross_platform/features/user/view/screens/change_email_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/change_number_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/change_username_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/data_and_storage_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/invites_permissions_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/last_seen_privacy_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/phone_privacy_screen.dart';
Expand All @@ -41,6 +42,7 @@ import 'package:telware_cross_platform/features/user/view/screens/profile_photo_
import 'package:telware_cross_platform/features/user/view/screens/self_destruct_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/settings_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/user_profile_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/wifi_media_screen.dart';

import '../../features/chat/view/screens/pinned_messages_screen.dart';
import '../../features/groups/view/screens/edit_group.dart';
Expand Down Expand Up @@ -87,6 +89,8 @@ class Routes {
static const String addMembersScreen = AddMembersScreen.route;
static const String membersScreen = MembersScreen.route;
static const String captionScreen = CaptionScreen.route;
static const String dataAndStorageScreen = DataAndStorageScreen.route;
static const String wifiMediaScreen = WifiMediaScreen.route;

static GoRouter appRouter(WidgetRef ref) => GoRouter(
initialLocation: Routes.splash,
Expand Down Expand Up @@ -347,6 +351,14 @@ class Routes {
);
},
),
GoRoute(
path: Routes.dataAndStorageScreen,
builder: (context, state) => const DataAndStorageScreen(),
),
GoRoute(
path: Routes.wifiMediaScreen,
builder: (context, state) => const WifiMediaScreen(),
)
],
);

Expand Down
205 changes: 205 additions & 0 deletions lib/features/user/view/screens/data_and_storage_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:telware_cross_platform/core/models/user_model.dart';
import 'package:telware_cross_platform/core/providers/user_provider.dart';
import 'package:telware_cross_platform/core/routes/routes.dart';
import 'package:telware_cross_platform/core/theme/dimensions.dart';
import 'package:telware_cross_platform/core/theme/palette.dart';
import 'package:telware_cross_platform/core/utils.dart';
import 'package:telware_cross_platform/features/auth/view/widget/confirmation_dialog.dart';
import 'package:telware_cross_platform/features/user/view/screens/invites_permissions_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/blocked_users.dart';
import 'package:telware_cross_platform/features/user/view/screens/last_seen_privacy_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/phone_privacy_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/profile_photo_privacy_screen.dart';
import 'package:telware_cross_platform/features/user/view/screens/self_destruct_screen.dart';
import 'package:telware_cross_platform/features/user/view/widget/settings_option_widget.dart';
import 'package:telware_cross_platform/features/user/view/widget/settings_section.dart';
import 'package:telware_cross_platform/features/user/view/widget/settings_toggle_switch_widget.dart';
import 'package:telware_cross_platform/features/user/view/widget/toolbar_widget.dart';

class DataAndStorageScreen extends ConsumerStatefulWidget {
static const String route = '/data-and-storage';

const DataAndStorageScreen({super.key});

@override
ConsumerState<DataAndStorageScreen> createState() =>
_DataAndStorageScreen();
}

class _DataAndStorageScreen extends ConsumerState<DataAndStorageScreen> {
final List<Map<String, dynamic>> profileSections = [
{
"title": "Disk and network usage",
"options": [
{
"icon": Icons.data_usage,
"text": 'Storage Usage',
"trailing": "62.4 MB",
},
{
"icon": Icons.analytics_outlined,
"text": 'Data Usage',
"trailing": "854.1 MB",
},
],
}
];
bool mobileMedia = true;
bool wifiMedia = true;
bool roamingMedia = true;
bool privateChats = false;
bool groups = false;
bool channels = false;
bool streamVideos = true;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const ToolbarWidget(
title: "Data and Storage",
),
body: SingleChildScrollView(
child: Column(
children: [
...List.generate(profileSections.length, (index) {
final section = profileSections[index];
final title = section["title"] ?? "";
final options = section["options"];
final trailing = section["trailing"] ?? "";
return Column(
children: [
SettingsSection(
title: title,
settingsOptions: options,
trailing: trailing,
),
const SizedBox(height: Dimensions.sectionGaps),
],
);
}),
SettingsSection(
title: "Automatic media download",
settingsOptions: [],
actions: [
SettingsToggleSwitchWidget(
text: 'When using mobile data',
subtext: mobileMedia ? 'Photos, Videos (10 MB), Files (1 MB)' : 'Disabled',
isChecked: mobileMedia,
onToggle: (value) => setState(() {
mobileMedia = value;
}),
onTap: (_) => showToastMessage("Coming soon"),
oneFunction: false,
),
SettingsToggleSwitchWidget(
text: 'When connected to Wi-Fi',
subtext: wifiMedia ? 'Photos, Videos (15 MB), Files (3 MB)' : 'Disabled',
isChecked: wifiMedia,
onToggle: (value) => setState(() {
wifiMedia = value;
}), // TODO: Marwan
onTap: (_) => context.push(Routes.wifiMediaScreen),
oneFunction: false,
),
SettingsToggleSwitchWidget(
text: 'When roaming',
subtext: roamingMedia ? 'Photos' : 'Disabled',
isChecked: roamingMedia,
onToggle: (value) => setState(() {
roamingMedia = value;
}),
onTap: (_) => showToastMessage("coming soon"),
oneFunction: false,
),
const SettingsOptionWidget(
text: 'Reset Auto-Download Settings',
color: Palette.error,
showDivider: false,
)
],
),
const SizedBox(height: Dimensions.sectionGaps),
SettingsSection(
title: "Save to Gallery",
settingsOptions: [],
actions: [
SettingsToggleSwitchWidget(
text: 'Private Chats',
subtext: privateChats ? 'On' : 'Off',
isChecked: privateChats,
onToggle: (value) => setState(() {
privateChats = value;
}),
onTap: (_) => showToastMessage("Coming soon"),
oneFunction: false,
),
SettingsToggleSwitchWidget(
text: 'Groups',
subtext: groups ? 'On' : 'Off',
isChecked: groups,
onToggle: (value) => setState(() {
groups = value;
}),
onTap: (_) => showToastMessage("Coming soon"),
oneFunction: false,
),
SettingsToggleSwitchWidget(
text: 'Channels',
subtext: channels ? 'On' : 'Off',
isChecked: channels,
onToggle: (value) => setState(() {
channels = value;
}),
onTap: (_) => showToastMessage("Coming soon"),
oneFunction: false,
showDivider: false,
),
],
),
const SizedBox(height: Dimensions.sectionGaps),
SettingsSection(
title: "Streaming",
settingsOptions: [],
actions: [
SettingsToggleSwitchWidget(
text: 'Stream Videos and Audio Files',
isChecked: streamVideos,
onToggle: (value) => setState(() {
streamVideos = value;
}),
oneFunction: true,
showDivider: false,
),
],
trailing: "When possible, TelWare will start playing videos and music right away, without"
" waiting for the files to fully download.",
),
const SizedBox(height: Dimensions.sectionGaps),
const SettingsSection(
title: "Calls",
settingsOptions: [{
"text": 'Use Less Data for Calls',
"trailing": "Never"
}],
),
const SizedBox(height: Dimensions.sectionGaps),
const SettingsSection(
title: "Proxy",
settingsOptions: [{
"text": 'Proxy Settings',
}],
),
const SizedBox(height: Dimensions.sectionGaps),
const SettingsSection(
settingsOptions: [{
"text": 'Delete All Cloud Drafts',
}],
),
],
)),
);
}
}
2 changes: 1 addition & 1 deletion lib/features/user/view/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _SettingsScreen extends ConsumerState<SettingsScreen> {
{
"icon": Icons.pie_chart_outline,
"text": 'Data and Storage',
"routes": 'locked'
"routes": Routes.dataAndStorageScreen
},
{
"icon": Icons.battery_saver_outlined,
Expand Down
Loading

0 comments on commit 2f9d470

Please sign in to comment.