Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed Nov 15, 2024
1 parent a429092 commit 79507be
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 38 deletions.
7 changes: 4 additions & 3 deletions lib/page/AddDiscuzPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:discuz_flutter/database/AppDatabase.dart';
import 'package:discuz_flutter/entity/Discuz.dart';
import 'package:discuz_flutter/generated/l10n.dart';
import 'package:discuz_flutter/provider/DiscuzAndUserNotifier.dart';
import 'package:discuz_flutter/utility/NetworkUtils.dart';
import 'package:discuz_flutter/utility/UserPreferencesUtils.dart';
import 'package:discuz_flutter/utility/VibrationUtils.dart';
import 'package:discuz_flutter/widget/ErrorCard.dart';
Expand Down Expand Up @@ -81,7 +82,7 @@ class _AddDiscuzFormFieldState
});
} catch (e) {}

final dio = Dio();
final dio = await NetworkUtils.getDioWithTempCookieJar();
final client =
UtilityServiceApiClient(dio, baseUrl: 'https://discuzhub.kidozh.com');
client.getAllSuggestedDiscuzList().then((string) {
Expand Down Expand Up @@ -127,11 +128,11 @@ class _AddDiscuzFormFieldState
Navigator.pop(context);
}

void _checkApiAvailable() {
void _checkApiAvailable() async{
String discuzUrl = _urlController.text;
log("Recv url " + discuzUrl);
// check the availability
final dio = Dio();
final dio = await NetworkUtils.getDioWithTempCookieJar();
final client = MobileApiClient(dio, baseUrl: discuzUrl);
setState(() {
_isLoading = true;
Expand Down
18 changes: 12 additions & 6 deletions lib/page/ConfigurePictureBedPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class ConfigurePictureBedState extends State<ConfigurePictureBedPage> {
Center(
child: Text(
S.of(context).pictureBedTermsTitle(pictureBedName),
style: Theme.of(context).textTheme.headlineSmall,
style: Theme.of(context).textTheme.headlineMedium?..copyWith(
fontWeight: FontWeight.bold
),
),
),
SizedBox(
Expand Down Expand Up @@ -146,13 +148,17 @@ class ConfigurePictureBedState extends State<ConfigurePictureBedPage> {
SizedBox(
height: 16,
),
Padding(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 0),
child: PlatformElevatedButton(
child: Text(S.of(context).pictureBedAgreeToService),
onPressed: onPressed,
SizedBox(
width: double.infinity,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 0),
child: PlatformElevatedButton(
child: Text(S.of(context).pictureBedAgreeToService),
onPressed: onPressed,
),
),
)

],
),
),
Expand Down
25 changes: 14 additions & 11 deletions lib/page/SettingPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import 'package:url_launcher/url_launcher.dart';
import '../utility/AppPlatformIcons.dart';
import '../utility/PostTextFieldUtils.dart';
import 'ChooseThemeColorPage.dart';
import 'ConfigurePictureBedPage.dart';
import 'SetPushNotificationPage.dart';

class SettingPage extends StatefulWidget {
@override
Expand Down Expand Up @@ -120,6 +122,17 @@ class _SettingPageState extends State<SettingPage> {
});
}, initialValue: recordHistory,
),
SettingsTile.navigation(
title: Text(S.of(context).pictureBedTitle),
leading: Icon(AppPlatformIcons(context).pictureBedOutlined),
onPressed: (_) {
VibrationUtils.vibrateWithClickIfPossible();
Navigator.of(context).push(platformPageRoute(
builder: (_) => ConfigurePictureBedPage(),
context: context,
));
},
),
// SettingsTile.navigation(
// title: Text(S.of(context).pushNotification),
// leading: Icon(AppPlatformIcons(context).pushServiceOutlined),
Expand Down Expand Up @@ -301,17 +314,7 @@ class _SettingPageState extends State<SettingPage> {
)
),

// SettingsTile.navigation(
// title: Text(S.of(context).pictureBedTitle),
// leading: Icon(AppPlatformIcons(context).pictureBedOutlined),
// onPressed: (_) {
// VibrationUtils.vibrateWithClickIfPossible();
// Navigator.of(context).push(platformPageRoute(
// builder: (_) => ConfigurePictureBedPage(),
// context: context,
// ));
// },
// ),

],
),
SettingsSection(
Expand Down
26 changes: 13 additions & 13 deletions lib/page/TestFlightBannerPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,19 @@ class TestFlightBannerContentState extends State<TestFlightBannerContent>{
URLUtils.launchURL("https://discuzhub.kidozh.com/zh/term_of_use/");
},
),
Divider(),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.purple,
child: Icon(Icons.menu_open,color: Colors.white,),
),
title: Text(S.of(context).openSoftwareTitle),
subtitle: Text(S.of(context).openSoftwareSubtitle),
onTap: (){
VibrationUtils.vibrateWithClickIfPossible();
URLUtils.launchURL("https://github.com/kidozh/discuz_flutter");
},
),
//Divider(),
// ListTile(
// leading: CircleAvatar(
// backgroundColor: Colors.purple,
// child: Icon(Icons.menu_open,color: Colors.white,),
// ),
// title: Text(S.of(context).openSoftwareTitle),
// subtitle: Text(S.of(context).openSoftwareSubtitle),
// onTap: (){
// VibrationUtils.vibrateWithClickIfPossible();
// URLUtils.launchURL("https://github.com/kidozh/discuz_flutter");
// },
// ),
SizedBox(height: 24,),
Row(
mainAxisSize: MainAxisSize.max,
Expand Down
2 changes: 1 addition & 1 deletion lib/utility/AppPlatformIcons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class AppPlatformIcons{

IconData get hapticFeedbackOutlined => isMaterial(context)? Icons.vibration_outlined : CupertinoIcons.dial;

IconData get pictureBedOutlined => isMaterial(context)? Icons.photo_album_outlined : CupertinoIcons.square_stack;
IconData get pictureBedOutlined => isMaterial(context)? Icons.photo_album_outlined : CupertinoIcons.archivebox;

IconData get chevronSolid => isMaterial(context)? Icons.arrow_forward : CupertinoIcons.chevron_forward;

Expand Down
53 changes: 50 additions & 3 deletions lib/utility/NetworkUtils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import 'package:dio/dio.dart';
import 'package:discuz_flutter/entity/User.dart';
import 'package:path_provider/path_provider.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:random_user_agents/random_user_agents.dart';
import 'package:ua_client_hints/ua_client_hints.dart';

class NetworkUtils{

static final ua = RandomUserAgents.random();

static Future<PersistCookieJar> getPersistentCookieJarByUser(User user) async{
Directory appDocDir = await getApplicationDocumentsDirectory();
Expand All @@ -34,18 +37,62 @@ class NetworkUtils{
}

static Future<Dio> getDioWithTempCookieJar() async{
var dio = Dio();
String userAgent = ua;
final header = await userAgentClientHintsHeader();
var dio = Dio(
BaseOptions(
headers: {
'User-Agent': userAgent,
//'Accept-Language': 'en-US,en;q=0.9'
}
)
);
print("Running on UA ${ua} ${header}");

PersistCookieJar cookieJar = await getTemporaryCookieJar();
dio.interceptors.add(CookieManager(cookieJar));
// dio.interceptors.add(InterceptorsWrapper(
// onRequest: (options, handler) async{
// options.headers.addAll(await userAgentClientHintsHeader());
// //return options;
// },
// ));
return dio;
}

static Future<Dio> getDioWithPersistCookieJar(User? user) async{
if(user == null){
return Dio();
String userAgent = ua;
var dio = Dio(
BaseOptions(
headers: {
'User-Agent': userAgent
}
)
);
// dio.interceptors.add(InterceptorsWrapper(
// onRequest: (options, handler) async{
// options.headers.addAll(await userAgentClientHintsHeader());
// //return options;
// },
// ));
return dio;
}
else{
var dio = Dio();
String userAgent = ua;
var dio = Dio(
BaseOptions(
headers: {
'User-Agent': userAgent
}
)
);
// dio.interceptors.add(InterceptorsWrapper(
// onRequest: (options, handler) async{
// options.headers.addAll(await userAgentClientHintsHeader());
// //return options;
// },
// ));
PersistCookieJar cookieJar = await getPersistentCookieJarByUser(user);
dio.interceptors.add(CookieManager(cookieJar));
return dio;
Expand Down
2 changes: 1 addition & 1 deletion lib/utility/PushServiceUtils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class PushServiceUtils{
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
onDidReceiveLocalNotification: PushServiceUtils.onDidReceiveLocalNotification
//onDidReceiveLocalNotification: PushServiceUtils.onDidReceiveLocalNotification
);
final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ dependencies:
firebase_core: ^3.2.0
html: ^0.15.4
ios_utsname_ext: ^2.3.0
ua_client_hints: ^1.4.0
random_user_agents: ^1.0.6
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit 79507be

Please sign in to comment.