Skip to content

Commit 744a5a3

Browse files
jigar-fatavism
andauthored
IOS review changes v1 (#8418)
* IOS review changes v1 * Do not snow protocol info on multi country & increase build number * Fix data cap issue with time. --------- Co-authored-by: atavism <atavism@users.noreply.github.com>
1 parent de4d68d commit 744a5a3

7 files changed

Lines changed: 84 additions & 37 deletions

File tree

assets/locales/en.po

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ msgstr "Select a region for your Private Server. Closer locations may improve sp
681681
msgid "gcp_location_options"
682682
msgstr "Google Cloud Platform Location Options (%d):"
683683

684-
685684
msgid "australia_sydney"
686685
msgstr "Australia - Sydney"
687686

@@ -1314,6 +1313,9 @@ msgstr "Daily data cap reached"
13141313
msgid "daily_data_cap_reached_message"
13151314
msgstr "Speed reduced to 128 kb/sec - Resets at %s."
13161315

1316+
msgid "subscription_renewal_info"
1317+
msgstr "Payment is charged to your Apple ID at purchase. Subscriptions renew automatically unless canceled at least 24 hours before the end of the current period. Manage or cancel in App Store Settings."
1318+
13171319

13181320

13191321

lib/core/widgets/base_screen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class BaseScreen extends StatelessWidget {
88
final bool padded;
99
final AppBar? appBar;
1010
final Widget? bottomNavigationBar;
11+
final Widget? bottomSheet;
1112
final Color? backgroundColor;
1213
final bool extendBody;
1314

@@ -20,6 +21,7 @@ class BaseScreen extends StatelessWidget {
2021
this.appBar,
2122
this.backgroundColor,
2223
this.extendBody = false,
24+
this.bottomSheet,
2325
});
2426

2527
@override
@@ -34,6 +36,7 @@ class BaseScreen extends StatelessWidget {
3436
padding: padded ? defaultPadding : EdgeInsets.zero,
3537
child: body,
3638
),
39+
bottomSheet: bottomSheet,
3740
bottomNavigationBar: bottomNavigationBar,
3841
extendBody: extendBody,
3942
);

lib/features/home/data_usage.dart

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ class DataUsage extends ConsumerWidget {
2828
final int usedBytes = dataCap.bytesUsed.clamp(0, totalBytes);
2929
final int remainingBytes = totalBytes - usedBytes;
3030
final isDataCapReached = usedBytes >= totalBytes;
31-
32-
final dataCapResetTime = formatDailyResetTime(dataCap.allotmentEndTime);
3331
appLogger.debug(
3432
"Data Usage - Bytes: $totalBytes bytes, Used: $usedBytes bytes, Remaining: $remainingBytes bytes");
33+
final dataCapResetTime = formatDailyResetTime(dataCap.allotmentEndTime);
34+
String dataCapMessage =
35+
"daily_data_cap_reached_message".i18n.fill([dataCapResetTime]);
36+
///If parsing fails and returns empty string
37+
///do not show time
38+
if (dataCapResetTime.isEmpty) {
39+
dataCapMessage = dataCapMessage.split('-').first;
40+
}
3541

3642
/// Convert to MB only for display
3743
final int totalData = (totalBytes.toMB).round();
@@ -92,9 +98,7 @@ class DataUsage extends ConsumerWidget {
9298
Padding(
9399
padding: const EdgeInsets.only(left: 30),
94100
child: AutoSizeText(
95-
"daily_data_cap_reached_message"
96-
.i18n
97-
.fill([dataCapResetTime]),
101+
dataCapMessage,
98102
minFontSize: 11,
99103
maxFontSize: 12,
100104
maxLines: 1,
@@ -144,20 +148,26 @@ class DataUsage extends ConsumerWidget {
144148

145149
/// Formats the daily reset time based on whether it's today or another day.
146150
String formatDailyResetTime(String serverTime) {
147-
if(serverTime.isEmpty){
151+
try {
152+
if (serverTime.isEmpty) {
153+
return "";
154+
}
155+
final DateTime endTime = DateTime.parse(
156+
serverTime,
157+
).toLocal();
158+
final DateTime now = DateTime.now();
159+
final DateTime today = DateTime(now.year, now.month, now.day);
160+
final DateTime endDate =
161+
DateTime(endTime.year, endTime.month, endTime.day);
162+
if (endDate == today) {
163+
return AppDateFormats.time.format(endTime);
164+
}
165+
166+
return '${AppDateFormats.weekday.format(endTime)}, '
167+
'${AppDateFormats.time.format(endTime)}';
168+
} catch (e) {
169+
appLogger.error('Error formatting daily reset time: $e');
148170
return "";
149171
}
150-
final DateTime endTime = DateTime.parse(
151-
'${serverTime.replaceFirst(' ', 'T')}Z',
152-
).toLocal();
153-
final DateTime now = DateTime.now();
154-
final DateTime today = DateTime(now.year, now.month, now.day);
155-
final DateTime endDate = DateTime(endTime.year, endTime.month, endTime.day);
156-
if (endDate == today) {
157-
return AppDateFormats.time.format(endTime);
158-
}
159-
160-
return '${AppDateFormats.weekday.format(endTime)}, '
161-
'${AppDateFormats.time.format(endTime)}';
162172
}
163173
}

lib/features/plans/plans.dart

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import 'package:lantern/core/utils/formatter.dart';
1111
import 'package:lantern/core/utils/screen_utils.dart';
1212
import 'package:lantern/core/widgets/loading_indicator.dart';
1313
import 'package:lantern/features/auth/provider/auth_notifier.dart';
14-
import 'package:lantern/features/plans/provider/payment_notifier.dart';
1514
import 'package:lantern/features/home/provider/app_setting_notifier.dart';
1615
import 'package:lantern/features/plans/feature_list.dart';
1716
import 'package:lantern/features/plans/plans_list.dart';
17+
import 'package:lantern/features/plans/provider/payment_notifier.dart';
1818
import 'package:lantern/features/plans/provider/plans_notifier.dart';
1919
import 'package:lantern/features/plans/provider/referral_notifier.dart';
2020

@@ -34,7 +34,6 @@ class _PlansState extends ConsumerState<Plans> {
3434
@override
3535
Widget build(BuildContext context) {
3636
textTheme = Theme.of(context).textTheme;
37-
3837
return BaseScreen(
3938
backgroundColor: AppColors.white,
4039
padded: false,
@@ -74,7 +73,7 @@ class _PlansState extends ConsumerState<Plans> {
7473
padding: EdgeInsets.symmetric(horizontal: defaultSize),
7574
child: SizedBox(
7675
height:
77-
context.isSmallDevice ? size.height * 0.4 : size.height * 0.4,
76+
context.isSmallDevice ? size.height * 0.4 : size.height * 0.39,
7877
child: SingleChildScrollView(child: FeatureList()),
7978
),
8079
),
@@ -133,6 +132,47 @@ class _PlansState extends ConsumerState<Plans> {
133132
onPressed: onGetLanternProTap,
134133
),
135134
),
135+
if (PlatformUtils.isIOS) ...{
136+
SizedBox(height: defaultSize),
137+
Padding(
138+
padding: const EdgeInsets.only(left: 8.0),
139+
child: Text(
140+
'subscription_renewal_info'.i18n,
141+
style: textTheme.labelMedium!.copyWith(
142+
color: AppColors.gray7,
143+
),
144+
),
145+
),
146+
IntrinsicHeight(
147+
child: Row(
148+
mainAxisAlignment: MainAxisAlignment.spaceAround,
149+
children: <Widget>[
150+
AppTextButton(
151+
label: 'privacy_policy'.i18n,
152+
fontSize: 12,
153+
textColor: AppColors.gray7,
154+
onPressed: () {
155+
UrlUtils.openWithSystemBrowser(
156+
AppUrls.privacyPolicy);
157+
},
158+
),
159+
VerticalDivider(
160+
indent: 10,
161+
endIndent: 10,
162+
),
163+
AppTextButton(
164+
label: 'terms_of_service'.i18n,
165+
fontSize: 12,
166+
textColor: AppColors.gray7,
167+
onPressed: () {
168+
UrlUtils.openWithSystemBrowser(
169+
AppUrls.termsOfService);
170+
},
171+
)
172+
],
173+
),
174+
),
175+
},
136176
SizedBox(height: size24),
137177
],
138178
),

lib/features/vpn/server_selection.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ class _CountryCityListViewState extends State<_CountryCityListView> {
521521
Widget build(BuildContext context) {
522522
final countryCode = widget.locations.first.countryCode;
523523
final country = widget.locations.first.country;
524-
final textTheme = Theme.of(context).textTheme;
525524
if (PlatformUtils.isDesktop) {
526525
return Theme(
527526
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
@@ -567,19 +566,9 @@ class _CountryCityListViewState extends State<_CountryCityListView> {
567566
),
568567
);
569568
}
570-
571-
final location = widget.locations.first;
572569
return AppTile(
573570
icon: Flag(countryCode: countryCode),
574571
label: widget.country,
575-
subtitle: location.protocol.isEmpty
576-
? null
577-
: Text(
578-
location.protocol.capitalize,
579-
style: textTheme.labelMedium!.copyWith(
580-
color: AppColors.gray7,
581-
),
582-
),
583572
trailing: AppImage(
584573
path: AppImagePaths.arrowForward,
585574
height: 20.0,
@@ -611,6 +600,7 @@ class _CountryCityListViewState extends State<_CountryCityListView> {
611600
final isSelected = widget.selectedServerTag == loc.tag;
612601

613602
return SingleCityServerView(
603+
nested: true,
614604
onServerSelected: (selected) {
615605
Navigator.of(bottomSheetContext).pop();
616606
widget.onServerSelected(selected);

lib/features/vpn/single_city_server_view.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ class SingleCityServerView extends StatefulWidget {
1010
final Location_ location;
1111
final OnServerSelected onServerSelected;
1212
final bool isSelected;
13+
final bool nested;
1314

1415
const SingleCityServerView({
1516
super.key,
1617
required this.onServerSelected,
1718
required this.location,
1819
this.isSelected = false,
20+
this.nested = false,
1921
});
2022

2123
@override
@@ -27,9 +29,9 @@ class _SingleCityServerViewState extends State<SingleCityServerView> {
2729
Widget build(BuildContext context) {
2830
final textTheme = Theme.of(context).textTheme;
2931
return AppTile(
30-
// minHeight: 55,
31-
// contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
32-
label: '${widget.location.country} - ${widget.location.city}',
32+
label: widget.nested
33+
? widget.location.city
34+
: '${widget.location.country} - ${widget.location.city}',
3335
selected: widget.isSelected,
3436
subtitle: widget.location.protocol.isEmpty
3537
? null

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
19-
version: 9.0.1+84
19+
version: 9.0.1+85
2020

2121
environment:
2222
sdk: ^3.6.0

0 commit comments

Comments
 (0)