-
Notifications
You must be signed in to change notification settings - Fork 12
/
not_found_view.dart
102 lines (91 loc) · 3.33 KB
/
not_found_view.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:rive/rive.dart';
import 'package:stacked/stacked.dart';
// Project imports:
import 'package:notredame/features/app/error/not_found/not_found_viewmodel.dart';
import 'package:notredame/utils/app_theme.dart';
class NotFoundView extends StatefulWidget {
final String? pageName;
const NotFoundView({this.pageName});
@override
_NotFoundState createState() => _NotFoundState();
}
class _NotFoundState extends State<NotFoundView> {
late NotFoundViewModel viewModel;
_NotFoundState();
@override
void initState() {
viewModel = NotFoundViewModel(pageName: widget.pageName ?? '');
viewModel
.loadRiveAnimation()
.then((_) => setState(() => viewModel.startRiveAnimation()));
super.initState();
}
Widget _buildAnimatedWidget() {
return viewModel.artboard != null
? SizedBox(
width: 100,
height: 80,
child: Rive(
artboard: viewModel.artboard!,
fit: BoxFit.fitWidth,
))
: Container();
}
@override
Widget build(BuildContext context) =>
ViewModelBuilder<NotFoundViewModel>.nonReactive(
viewModelBuilder: () => viewModel,
builder: (context, model, child) => Scaffold(
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
bottom: 60,
),
child: _buildAnimatedWidget(),
),
Padding(
padding: const EdgeInsets.only(
bottom: 80,
),
child: Text(
AppIntl.of(context)!.not_found_title,
style: const TextStyle(
fontSize: 25, fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(
bottom: 70,
),
child: Text(
AppIntl.of(context)!
.not_found_message(model.notFoundPageName),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 15,
),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primary,
),
onPressed: () {
model.navigateToDashboard();
},
child: Text(AppIntl.of(context)!.go_to_dashboard),
),
],
),
),
),
));
}