-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
wish_simulator_page.dart
58 lines (52 loc) · 1.78 KB
/
wish_simulator_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:genshindb/application/bloc.dart';
import 'package:genshindb/generated/l10n.dart';
import 'package:genshindb/presentation/shared/app_webview.dart';
import 'package:genshindb/presentation/shared/loading.dart';
class WishSimulatorPage extends StatefulWidget {
@override
_WishSimulatorPageState createState() => _WishSimulatorPageState();
}
class _WishSimulatorPageState extends State<WishSimulatorPage> {
final script = '''
function closeModal(){
if (!document.getElementsByClassName("modal-container"))
return;
let modal = document.getElementsByClassName("modal-container")[0];
if (!modal)
return;
let closeModalBtn = modal.querySelector(".close-button");
if (!closeModalBtn)
return;
closeModalBtn.click();
}
setTimeout(closeModal, 300);
setTimeout(closeModal, 1200);
setTimeout(closeModal, 3000);
setTimeout(closeModal, 6000);
''';
@override
void didChangeDependencies() {
super.didChangeDependencies();
context.read<UrlPageBloc>().add(const UrlPageEvent.init(loadMap: false, loadWishSimulator: true, loadDailyCheckIn: false));
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return SafeArea(child: BlocBuilder<UrlPageBloc, UrlPageState>(
builder: (context, state) {
return state.map(
loading: (_) => const Loading(),
loaded: (state) => AppWebView(
appBar: AppBar(title: Text(s.wishSimulator)),
url: state.wishSimulatorUrl,
userAgent: state.userAgent,
hasInternetConnection: state.hasInternetConnection,
script: script,
),
);
},
));
}
}