-
Notifications
You must be signed in to change notification settings - Fork 0
/
page_wudhu.dart
144 lines (136 loc) · 5.23 KB
/
page_wudhu.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:pdfx/pdfx.dart';
import 'package:tuntunan_sholat/page_wudhu/model_wudhu.dart';
import 'package:flutter/services.dart' as rootBundle;
class WudhuPage extends StatelessWidget {
const WudhuPage({super.key});
Future<List<ModelWudhu>> readJsonData() async {
final jsonData = await rootBundle.rootBundle.loadString('assets/data/wudhu/page_wudhu.json');
final listData = json.decode(jsonData) as List<dynamic>;
return listData.map((e) => ModelWudhu.fromJson(e)).toList();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: const Text(
"Wudhu",
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),
),
),
body: Expanded(
child: FutureBuilder(
future: readJsonData(),
builder: (context, data) {
if (data.hasError) {
return Center(child: Text("${data.error}"));
} else if (data.hasData) {
var items = data.data as List<ModelWudhu>;
return ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
elevation: 5,
margin: const EdgeInsets.all(10),
child: Theme(
data: Theme.of(context).copyWith(
dividerColor: Colors.transparent,
unselectedWidgetColor: Colors.black,
colorScheme: const ColorScheme.light(
primary: Colors.orange,
),
),
child: ExpansionTile(
title: Text(
items[index].title.toString(),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
),
children: [
GestureDetector(
onTap: () {
if (items[index].title == 'Tata Cara Wudhu') {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const OpenPDFPage()));
}
},
child: Container(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
items[index].content.toString(),
style: const TextStyle(
fontSize: 14,
),
),
),
)
],
),
),
),
],
),
),
);
});
} else {
return const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.orange),
),
);
}
},
),
),
);
}
}
class OpenPDFPage extends StatelessWidget {
const OpenPDFPage({super.key});
@override
Widget build(BuildContext context) {
final pdfController = PdfControllerPinch(
document: PdfDocument.openAsset('assets/data/wudhu/page_wudhu.pdf'),
);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: const Text(
"Tata Cara Wudhu",
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black),
),
),
body: Center(
child: PdfViewPinch(
controller: pdfController,
)
),
);
}
}