47 lines
1.4 KiB
Dart
47 lines
1.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:yumi/shared/tools/sc_room_utils.dart';
|
|
import 'package:yumi/shared/tools/sc_string_utils.dart';
|
|
import 'package:yumi/shared/tools/sc_url_launcher_utils.dart';
|
|
import 'package:yumi/shared/business_logic/models/res/sc_index_banner_res.dart';
|
|
import 'package:yumi/modules/index/main_route.dart';
|
|
import 'package:yumi/app/routes/sc_fluro_navigator.dart';
|
|
|
|
import '../../shared/data_sources/models/enum/sc_banner_open_type.dart';
|
|
|
|
class SCBannerUtils {
|
|
static Future<void> openBanner(
|
|
SCIndexBannerRes item,
|
|
BuildContext context,
|
|
) async {
|
|
if (item.content == SCBannerOpenType.ENTER_ROOM.name) {
|
|
var params = item.params;
|
|
if (params != null && params.isNotEmpty) {
|
|
SCRoomUtils.goRoom(params, context);
|
|
}
|
|
} else {
|
|
var params = item.params;
|
|
if (params == null || params.isEmpty) {
|
|
return;
|
|
}
|
|
|
|
if (SCUrlLauncherUtils.shouldOpenExternally(params)) {
|
|
final launched = await SCUrlLauncherUtils.launchExternal(params);
|
|
if (launched) {
|
|
return;
|
|
}
|
|
if (!context.mounted) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (SCStringUtils.checkIfUrl(params)) {
|
|
SCNavigatorUtils.push(
|
|
context,
|
|
"${SCMainRoute.webViewPage}?url=${Uri.encodeComponent(params)}&showTitle=false",
|
|
replace: false,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|