@@ -22,9 +22,9 @@ class _PrivacyWelcomeScreenState extends State<PrivacyWelcomeScreen> {
2222 final PageController _pageController = PageController ();
2323 int _currentPage = 0 ;
2424 final int _totalPages =
25- 8 ; // Increased to accommodate channels, sponsors, and Persian Gulf pages
25+ 7 ; // Reduced to remove background access page, now accommodating channels, sponsors, and Persian Gulf pages
2626 bool _acceptedPrivacy = false ;
27- bool _backgroundAccessHandled = false ;
27+
2828 AppLanguage ? _selectedLanguage;
2929
3030 @override
@@ -74,15 +74,10 @@ class _PrivacyWelcomeScreenState extends State<PrivacyWelcomeScreen> {
7474 return ;
7575 }
7676
77- // If on background access page and not handled, show dialog
78- if (_currentPage == 4 && ! _backgroundAccessHandled) {
79- // Changed from 3 to 4
80- _showBackgroundAccessDialog ();
81- return ;
82- }
77+
8378
8479 // If on channels page, proceed to next page
85- if (_currentPage == 5 ) {
80+ if (_currentPage == 4 ) {
8681 // No special handling required for channels page
8782 }
8883
@@ -172,94 +167,6 @@ class _PrivacyWelcomeScreenState extends State<PrivacyWelcomeScreen> {
172167 }
173168 }
174169
175- void _showBackgroundAccessDialog () {
176- showDialog (
177- context: context,
178- builder: (BuildContext context) {
179- return AlertDialog (
180- title: Text (
181- context.tr ('privacy_welcome.background_access_required' ),
182- style: const TextStyle (
183- fontWeight: FontWeight .bold,
184- color: Colors .white,
185- ),
186- ),
187- content: Text (
188- context.tr ('privacy_welcome.background_access_content' ),
189- style: const TextStyle (color: Colors .white70),
190- ),
191- backgroundColor: AppTheme .primaryDark,
192- shape: RoundedRectangleBorder (
193- borderRadius: BorderRadius .circular (12 ),
194- ),
195- actions: [
196- TextButton (
197- onPressed: () {
198- Navigator .of (context).pop (); // Close the dialog
199- // Stay on the current page
200- },
201- child: Text (
202- context.tr ('privacy_welcome.stay' ),
203- style: const TextStyle (color: Colors .white70),
204- ),
205- ),
206- TextButton (
207- onPressed: () {
208- Navigator .of (context).pop (); // Close the dialog
209- setState (() {
210- _backgroundAccessHandled = true ;
211- });
212- _nextPage (); // Continue to next page
213- },
214- child: Text (
215- context.tr ('common.next' ),
216- style: const TextStyle (color: AppTheme .primaryGreen),
217- ),
218- ),
219- ],
220- );
221- },
222- );
223- }
224-
225- void _openBackgroundSettings () async {
226- print (context.tr ('privacy_welcome.opening_background_settings' ));
227- try {
228- // Use platform channel to open Android battery optimization settings
229- const platform = MethodChannel ('com.cloud.pira/settings' );
230- final result = await platform.invokeMethod (
231- 'openBatteryOptimizationSettings' ,
232- );
233- print (
234- '${context .tr ('privacy_welcome.settings_opened_successfully' )}: $result ' ,
235- );
236- } catch (e) {
237- print (
238- '${context .tr ('privacy_welcome.error_opening_battery_settings' )}: $e ' ,
239- );
240- // Fallback: open general app settings
241- try {
242- const platform = MethodChannel ('com.cloud.pira/settings' );
243- final result = await platform.invokeMethod ('openAppSettings' );
244- print ('${context .tr ('privacy_welcome.app_settings_opened' )}: $result ' );
245- } catch (e2) {
246- print (
247- '${context .tr ('privacy_welcome.error_opening_app_settings' )}: $e2 ' ,
248- );
249- if (mounted) {
250- ScaffoldMessenger .of (context).showSnackBar (
251- SnackBar (
252- content: Text (
253- '${context .tr ('privacy_welcome.could_not_open_settings' )}: $e2 ' ,
254- ),
255- duration: const Duration (seconds: 3 ),
256- ),
257- );
258- }
259- }
260- }
261- }
262-
263170 @override
264171 Widget build (BuildContext context) {
265172 return Scaffold (
@@ -310,7 +217,6 @@ class _PrivacyWelcomeScreenState extends State<PrivacyWelcomeScreen> {
310217 _buildWelcomePage (),
311218 _buildPrivacyPage (),
312219 _buildNoLimitsPage (),
313- _buildBackgroundAccessPage (),
314220 _buildChannelsPage (), // Added channels and sponsors page
315221 _buildPersianGulfPage (), // Added Persian Gulf page
316222 _buildFreeToUsePage (),
@@ -365,9 +271,6 @@ class _PrivacyWelcomeScreenState extends State<PrivacyWelcomeScreen> {
365271 child: Text (
366272 _currentPage == _totalPages - 1
367273 ? context.tr ('privacy_welcome.get_started' )
368- : (_currentPage == 4 && // Changed from 3 to 4
369- ! _backgroundAccessHandled)
370- ? context.tr ('common.next' )
371274 : context.tr ('common.next' ),
372275 style: const TextStyle (
373276 fontSize: 16 ,
@@ -788,86 +691,6 @@ class _PrivacyWelcomeScreenState extends State<PrivacyWelcomeScreen> {
788691 );
789692 }
790693
791- Widget _buildBackgroundAccessPage () {
792- return Consumer <LanguageProvider >(
793- builder: (context, languageProvider, child) {
794- final isRtlLanguage =
795- languageProvider.currentLanguage.code == 'fa' ||
796- languageProvider.currentLanguage.code == 'ar' ;
797-
798- final titleStyle = isRtlLanguage
799- ? GoogleFonts .vazirmatn (
800- fontSize: 28 ,
801- fontWeight: FontWeight .bold,
802- color: Colors .white,
803- )
804- : const TextStyle (
805- fontSize: 28 ,
806- fontWeight: FontWeight .bold,
807- color: Colors .white,
808- );
809-
810- final subtitleStyle = isRtlLanguage
811- ? GoogleFonts .vazirmatn (fontSize: 16 , color: Colors .white70)
812- : const TextStyle (fontSize: 16 , color: Colors .white70);
813-
814- return Padding (
815- padding: const EdgeInsets .all (24.0 ),
816- child: SingleChildScrollView (
817- physics: const BouncingScrollPhysics (),
818- child: Column (
819- mainAxisAlignment: MainAxisAlignment .center,
820- children: [
821- const Icon (
822- Icons .battery_charging_full,
823- size: 100 ,
824- color: AppTheme .primaryGreen,
825- ),
826- const SizedBox (height: 24 ),
827- Text (
828- context.tr ('privacy_welcome.background_access_title' ),
829- style: titleStyle,
830- textAlign: TextAlign .center,
831- ),
832- const SizedBox (height: 16 ),
833- Text (
834- context.tr ('privacy_welcome.background_access_subtitle' ),
835- style: subtitleStyle,
836- textAlign: TextAlign .center,
837- ),
838- const SizedBox (height: 32 ),
839- // Primary button - Open Settings
840- SizedBox (
841- width: double .infinity,
842- child: ElevatedButton .icon (
843- onPressed: _openBackgroundSettings,
844- icon: const Icon (Icons .settings, color: Colors .white),
845- label: Text (
846- context.tr ('privacy_welcome.open_settings' ),
847- style: const TextStyle (
848- fontSize: 16 ,
849- fontWeight: FontWeight .bold,
850- color: Colors .white,
851- ),
852- ),
853- style: ElevatedButton .styleFrom (
854- backgroundColor: AppTheme .primaryGreen,
855- padding: const EdgeInsets .symmetric (vertical: 14 ),
856- shape: RoundedRectangleBorder (
857- borderRadius: BorderRadius .circular (8 ),
858- ),
859- ),
860- ),
861- ),
862- const SizedBox (height: 24 ),
863- ],
864- ),
865- ),
866- );
867- },
868- );
869- }
870-
871694 Widget _buildFreeToUsePage () {
872695 return Consumer <LanguageProvider >(
873696 builder: (context, languageProvider, child) {
0 commit comments