feat: menambahkan ui kemajuan dan data santri & integrate api get materi dan sub materi
This commit is contained in:
parent
45de05a765
commit
363d216f21
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
|
@ -0,0 +1,4 @@
|
|||
// lib/config.dart
|
||||
class BaseUrl {
|
||||
static const String baseUrl = 'http://192.168.100.45:8000/api';
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ta_tahsin/view/home/latihan/latihan.dart';
|
||||
import 'package:ta_tahsin/view/pengajar/data_santri/detail_data_santri.dart';
|
||||
import 'package:ta_tahsin/view/pengajar/kemajuan/detail_kemajuan.dart';
|
||||
|
||||
import '../../view/auth/login/login.dart';
|
||||
import '../../view/home/latihan/pelafalan_popup.dart';
|
||||
|
@ -32,9 +34,9 @@ final router = GoRouter(
|
|||
builder: (BuildContext context, GoRouterState state) {
|
||||
final Map<String, dynamic> extra = state.extra as Map<String, dynamic>;
|
||||
return MateriPage(
|
||||
id: extra['id'],
|
||||
title: extra['title'],
|
||||
description: extra['description'],
|
||||
subMateri: extra['subMateri'],
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -83,11 +85,24 @@ final router = GoRouter(
|
|||
return const KemajuanPage(); // Halaman untuk pengajar
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/detail_kemajuan',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
final Map<String, dynamic> extra = state.extra as Map<String, dynamic>;
|
||||
return DetailKemajuanPage(
|
||||
nama: extra['nama'],
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/data_santri',
|
||||
builder: (context, state) {
|
||||
return const DataSantriPage(); // Halaman Data Santri untuk pengajar
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/detail_user',
|
||||
builder: (context, state) => DetailDataSantriPage(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:ta_tahsin/core/baseurl/base_url.dart';
|
||||
import 'package:ta_tahsin/core/sized/sized.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
|
||||
|
@ -29,7 +30,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
|
||||
Future<void> login() async {
|
||||
final response = await http.post(
|
||||
Uri.parse('http://192.168.100.45:8000/api/login'),
|
||||
Uri.parse('${BaseUrl.baseUrl}/login'),
|
||||
body: {
|
||||
'email': emailController.text,
|
||||
'password': passwordController.text,
|
||||
|
|
|
@ -1,13 +1,43 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ta_tahsin/core/baseurl/base_url.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
import '../materi/model/model_data_materi.dart';
|
||||
|
||||
class BelajarPage extends StatelessWidget {
|
||||
class BelajarPage extends StatefulWidget {
|
||||
const BelajarPage({super.key});
|
||||
|
||||
@override
|
||||
_BelajarPageState createState() => _BelajarPageState();
|
||||
}
|
||||
|
||||
class _BelajarPageState extends State<BelajarPage> {
|
||||
List<dynamic> materiList = [];
|
||||
bool isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchMateri();
|
||||
}
|
||||
|
||||
// Fungsi untuk mengambil data materi dari API
|
||||
Future<void> _fetchMateri() async {
|
||||
final response = await http.get(Uri.parse('${BaseUrl.baseUrl}/materi'));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Mengubah format response JSON yang berisi objek dengan data dalam properti 'data'
|
||||
final Map<String, dynamic> data = json.decode(response.body);
|
||||
setState(() {
|
||||
materiList = data['data']; // Mengambil data dari properti 'data'
|
||||
isLoading = false;
|
||||
});
|
||||
} else {
|
||||
throw Exception('Failed to load materi');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -15,86 +45,79 @@ class BelajarPage extends StatelessWidget {
|
|||
title: const Text("Belajar"),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
for (var materi in materiList)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.go('/materi', extra: {
|
||||
'title': materi['title'],
|
||||
'description': materi['description'],
|
||||
'subMateri': materi['subMateri'],
|
||||
});
|
||||
},
|
||||
child: Center(
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(15),
|
||||
),
|
||||
child: Container(
|
||||
width: 400,
|
||||
height: 230,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
secondPrimaryColor,
|
||||
Colors.blue
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
Container(),
|
||||
),
|
||||
Text(
|
||||
materi['title'],
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: whiteColor,
|
||||
child: isLoading
|
||||
? const CircularProgressIndicator() // Menampilkan loading saat data masih dimuat
|
||||
: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
for (var materi in materiList)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.go('/materi', extra: {
|
||||
'id': materi['id'],
|
||||
'title': materi['title'],
|
||||
'description': materi['description'],
|
||||
|
||||
});
|
||||
},
|
||||
child: Center(
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Container(
|
||||
width: 400,
|
||||
height: 230,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
gradient: LinearGradient(
|
||||
colors: [secondPrimaryColor, Colors.blue],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
materi['arti'],
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: whiteColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(child: Container()),
|
||||
Text(
|
||||
materi['title'], // Menampilkan judul materi
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: whiteColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
materi['subtitle'], // Menampilkan subtitle materi
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: whiteColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,169 +1,223 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ta_tahsin/core/baseurl/base_url.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
import 'model/model_data_materi.dart'; // Impor model data materi
|
||||
|
||||
class MateriPage extends StatelessWidget {
|
||||
class MateriPage extends StatefulWidget {
|
||||
final int id;
|
||||
final String title;
|
||||
final String description;
|
||||
final List<dynamic> subMateri;
|
||||
|
||||
const MateriPage({
|
||||
super.key,
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.subMateri,
|
||||
});
|
||||
|
||||
@override
|
||||
_MateriPageState createState() => _MateriPageState();
|
||||
}
|
||||
|
||||
class _MateriPageState extends State<MateriPage> {
|
||||
late Future<List<dynamic>> kategoriData;
|
||||
bool isLoading = true; // Variabel untuk mengatur status loading
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
kategoriData = fetchKategoriData(widget.id); // Ambil kategori berdasarkan id materi
|
||||
}
|
||||
|
||||
// Fungsi untuk mengambil kategori berdasarkan id_materi
|
||||
Future<List<dynamic>> fetchKategoriData(int id_materi) async {
|
||||
final response = await http.get(Uri.parse('${BaseUrl.baseUrl}/kategori/$id_materi'));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
setState(() {
|
||||
isLoading = false; // Set isLoading ke false setelah data kategori berhasil diambil
|
||||
});
|
||||
return json.decode(response.body)['data']; // Parse JSON response ke List kategori
|
||||
} else {
|
||||
throw Exception('Failed to load kategori');
|
||||
}
|
||||
}
|
||||
|
||||
// Fungsi untuk mengambil sub-materi berdasarkan id_kategori
|
||||
Future<List<dynamic>> fetchSubMateriData(int id_kategori) async {
|
||||
final response = await http.get(Uri.parse('${BaseUrl.baseUrl}/sub_materi/$id_kategori'));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return json.decode(response.body)['data']['sub_materi']; // Parse JSON response ke List sub-materi
|
||||
} else {
|
||||
throw Exception('Failed to load sub-materi');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: secondPrimaryColor,
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: whiteColor,
|
||||
),
|
||||
),
|
||||
widget.title,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: whiteColor,
|
||||
),
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),color: whiteColor,
|
||||
icon: const Icon(Icons.arrow_back), color: whiteColor,
|
||||
onPressed: () {
|
||||
if (context.canPop()) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.go('/');
|
||||
context.go('/navigasi');
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
// Teks Title dan Description yang akan ikut scroll
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
Text(
|
||||
description,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// SliverList untuk subMateri
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final kategori = subMateri[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0), // Padding untuk subMateri
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Header kategori
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Text(
|
||||
kategori['category'],
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
for (var sub in kategori['subMateri'])
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 0), // Mengurangi jarak antar subMateri
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 8.0,
|
||||
horizontal:
|
||||
12.0), // Mengatur padding agar lebih rapat
|
||||
leading: Container(
|
||||
width: 60, // Lebar kotak
|
||||
height: 60, // Tinggi kotak
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
secondPrimaryColor, // Latar belakang kotak
|
||||
borderRadius: BorderRadius.circular(
|
||||
12), // Memberikan radius pada sudut
|
||||
),
|
||||
child: Icon(
|
||||
Icons.menu_book,
|
||||
color: whiteColor,
|
||||
size: 24, // Ukuran ikon
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
sub['title'],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
sub['subtitle'],
|
||||
body: isLoading
|
||||
? Center(child: CircularProgressIndicator()) // Tampilkan loading spinner selama proses loading
|
||||
: FutureBuilder<List<dynamic>>(
|
||||
future: kategoriData,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(child: CircularProgressIndicator()); // Tampilkan loading saat menunggu
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}')); // Tampilkan error jika ada masalah
|
||||
} else if (!snapshot.hasData || snapshot.data == null) {
|
||||
return Center(child: Text('Tidak ada data tersedia')); // Tampilkan jika data kosong
|
||||
}
|
||||
|
||||
final kategoriList = snapshot.data!;
|
||||
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.description,
|
||||
style: const TextStyle(
|
||||
fontSize: 14, color: Colors.grey),
|
||||
fontSize: 16,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
context.push(
|
||||
'/submateri', // Gantilah dengan rute yang sesuai
|
||||
extra: {
|
||||
'title': sub['title'],
|
||||
'description': sub['subtitle'],
|
||||
'videoLink': sub[
|
||||
'videoLink'], // Link video untuk diputar
|
||||
'intro': sub['intro'], // Materi pengantar
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
thickness: 1,
|
||||
indent: 80,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// SliverList untuk kategori dan sub-materi
|
||||
for (var kategori in kategoriList)
|
||||
FutureBuilder<List<dynamic>>(
|
||||
future: fetchSubMateriData(kategori['id']), // Ambil submateri untuk kategori ini
|
||||
builder: (context, subMateriSnapshot) {
|
||||
if (subMateriSnapshot.connectionState == ConnectionState.waiting) {
|
||||
return SliverToBoxAdapter(child: SizedBox()); // Tidak ada loading spinner lagi
|
||||
} else if (subMateriSnapshot.hasError) {
|
||||
return SliverToBoxAdapter(child: Center(child: Text('Error: ${subMateriSnapshot.error}')));
|
||||
} else if (!subMateriSnapshot.hasData || subMateriSnapshot.data == null) {
|
||||
return SliverToBoxAdapter(child: Center(child: Text('No sub-materi available')));
|
||||
}
|
||||
|
||||
final subMateriList = subMateriSnapshot.data!;
|
||||
|
||||
return SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
// Menampilkan nama kategori sekali
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 5.0),
|
||||
child: Text(
|
||||
kategori['nama_kategori'], // Menampilkan nama kategori
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Menampilkan sub-materi yang terkait dengan kategori ini
|
||||
for (var submateri in subMateriList)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: secondPrimaryColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.menu_book,
|
||||
color: whiteColor,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
submateri['title'],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
submateri['subtitle'],
|
||||
style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||
),
|
||||
onTap: () {
|
||||
context.push(
|
||||
'/submateri', // Gantilah dengan rute yang sesuai
|
||||
extra: {
|
||||
'title': submateri['title'],
|
||||
'description': submateri['subtitle'],
|
||||
'videoLink': submateri['video_url'],
|
||||
'intro': submateri['intro'],
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
thickness: 1,
|
||||
indent: 80,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
childCount: subMateri.length,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:ta_tahsin/core/baseurl/base_url.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
|
||||
class ProfilePage extends StatelessWidget {
|
||||
|
@ -15,7 +16,7 @@ class ProfilePage extends StatelessWidget {
|
|||
if (token != null) {
|
||||
// Panggil API logout untuk menghapus token di server
|
||||
final response = await http.post(
|
||||
Uri.parse('http://192.168.100.45:8000/api/logout'), // Ganti dengan URL API logout
|
||||
Uri.parse('${BaseUrl.baseUrl}/logout'), // Ganti dengan URL API logout
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token', // Kirim token di header
|
||||
},
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:ta_tahsin/core/router/route.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
import 'package:ta_tahsin/view/pengajar/data_santri/model/model_data_santri.dart';
|
||||
|
||||
class DataSantriPage extends StatelessWidget {
|
||||
const DataSantriPage({super.key});
|
||||
|
@ -10,14 +13,183 @@ class DataSantriPage extends StatelessWidget {
|
|||
title: const Text('Data Santri'),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: const Center(
|
||||
child: Text(
|
||||
'data santri',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Search bar
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
hintText: 'Cari Santri...',
|
||||
hintStyle: TextStyle(color: Colors.grey),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: secondPrimaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// Tombol + untuk menambah data santri
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
// Tindakan ketika tombol + diklik
|
||||
print("Menambahkan data santri...");
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
), // Ikon dengan warna putih
|
||||
label: const Text(
|
||||
'Tambah',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
), // Teks dengan warna putih
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor:
|
||||
secondPrimaryColor, // Warna latar belakang tombol
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
textStyle: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
// Tindakan untuk impor
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.import_export,
|
||||
color: Colors.white,
|
||||
), // Ikon dengan warna putih
|
||||
label: const Text(
|
||||
'Import',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
), // Teks dengan warna putih
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor:
|
||||
secondPrimaryColor, // Warna latar belakang tombol
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
textStyle: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Judul Pilih Santri
|
||||
Text(
|
||||
'Pilih Santri',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: secondPrimaryColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Menggunakan SliverList dengan santriList
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
var santri = santriList[index];
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
vertical: 5.0,
|
||||
),
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
'assets/icon/${santri['image']}',
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
santri['nama'],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
santri['jilid'],
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
// context.go('/detail_kemajuan', extra: {'nama': santri['nama']});
|
||||
router.push("/detail_user");
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
thickness: 1,
|
||||
indent: 80,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, childCount: santriList.length),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: DetailDataSantriPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DetailDataSantriPage extends StatefulWidget {
|
||||
@override
|
||||
_DetailDataSantriPageState createState() => _DetailDataSantriPageState();
|
||||
}
|
||||
|
||||
class _DetailDataSantriPageState extends State<DetailDataSantriPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController _fullNameController = TextEditingController();
|
||||
final TextEditingController _dobController = TextEditingController();
|
||||
final TextEditingController _phoneController = TextEditingController();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
final TextEditingController _weightController = TextEditingController();
|
||||
final TextEditingController _heightController = TextEditingController();
|
||||
String _gender = 'Laki-laki';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Detail Santri'),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView( // Add this to make the screen scrollable
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Profile picture section
|
||||
Center(
|
||||
child: CircleAvatar(
|
||||
radius: 60,
|
||||
backgroundImage: AssetImage('assets/icon/defaultprofile.jpeg'),
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
|
||||
// Title section
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: secondPrimaryColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 10, offset: Offset(0, 4))],
|
||||
),
|
||||
child: Text(
|
||||
'Detail Dasar',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: whiteColor),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
// Basic details section
|
||||
_buildTextFormField(_fullNameController, 'Nama Lengkap'),
|
||||
_buildTextFormField(_dobController, 'Usia'),
|
||||
_buildTextFormField(_dobController, 'Jilid Tilawati'),
|
||||
|
||||
// Gender selection section
|
||||
Row(
|
||||
children: [
|
||||
Text('Jenis Kelamin', style: TextStyle(fontSize: 16)),
|
||||
Radio<String>(
|
||||
value: 'Laki-laki',
|
||||
groupValue: _gender,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_gender = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
Text('Laki-laki'),
|
||||
Radio<String>(
|
||||
value: 'Perempuan',
|
||||
groupValue: _gender,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_gender = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
Text('Perempuan'),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
|
||||
// Contact details section
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: secondPrimaryColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 10, offset: Offset(0, 4))],
|
||||
),
|
||||
child: Text(
|
||||
'Detail Kontak',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: whiteColor),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
_buildTextFormField(_phoneController, 'No WA Wali'),
|
||||
_buildTextFormField(_emailController, 'Email'),
|
||||
SizedBox(height: 20),
|
||||
|
||||
// Personal details section
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: secondPrimaryColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 10, offset: Offset(0, 4))],
|
||||
),
|
||||
child: Text(
|
||||
'Detail Pribadi',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: whiteColor),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
_buildTextFormField(_weightController, 'Berat Badan (kg)'),
|
||||
_buildTextFormField(_heightController, 'Tinggi Badan (cm)'),
|
||||
SizedBox(height: 40),
|
||||
|
||||
// Save button section with shadow effect
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: secondPrimaryColor, // Customize your color
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
minimumSize: Size(double.infinity, 50),
|
||||
elevation: 5, // Adding shadow to the button
|
||||
),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Profil tersimpan')),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
"Simpan",
|
||||
style: TextStyle(fontSize: 16, color: whiteColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTextFormField(TextEditingController controller, String labelText) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(labelText, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500)),
|
||||
SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.blue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Harap masukkan $labelText Anda';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
import 'package:ta_tahsin/view/home/submateri/model/model_data_submateri.dart';
|
||||
|
||||
final List<Map<String, dynamic>> santriList = [
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
|
||||
// Lainnya...
|
||||
];
|
|
@ -0,0 +1,102 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
|
||||
class DetailKemajuanPage extends StatelessWidget {
|
||||
const DetailKemajuanPage({super.key, required this.nama});
|
||||
|
||||
final String nama;
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Kemajuan'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),color: blackColor,
|
||||
onPressed: () {
|
||||
if (context.canPop()) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.go('/navigasiPengajar');
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Foto Profil Pengguna
|
||||
Center(
|
||||
child: CircleAvatar(
|
||||
radius: 70,
|
||||
backgroundImage: AssetImage('assets/icon/defaultprofile.jpeg'), // Ganti dengan gambar profil
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Nama Pengguna
|
||||
Center(
|
||||
child: Text(
|
||||
nama, // Ganti dengan nama pengguna
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
// Judul Progres Belajar
|
||||
Text(
|
||||
'Progres Belajar',
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: blackColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// Progress Bar untuk materi
|
||||
ProgressBar(title: 'Jumlah Materi 1 Selesai', progress: 0.6), // Progress 60%
|
||||
const SizedBox(height: 20),
|
||||
ProgressBar(title: 'Jumlah Materi 2 Selesai', progress: 0.4), // Progress 40%
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProgressBar extends StatelessWidget {
|
||||
final String title;
|
||||
final double progress;
|
||||
|
||||
const ProgressBar({super.key, required this.title, required this.progress});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: blackColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
LinearProgressIndicator(
|
||||
value: progress,
|
||||
backgroundColor: Colors.grey[300],
|
||||
color: secondPrimaryColor, // Ganti dengan warna yang sesuai
|
||||
minHeight: 20,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
// Pastikan untuk menyesuaikan import theme.dart sesuai lokasi file theme.dart Anda
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
import 'package:ta_tahsin/view/pengajar/kemajuan/model/model_data_kemajuan.dart'; // Import kemajuanList
|
||||
|
||||
class KemajuanPage extends StatelessWidget {
|
||||
const KemajuanPage({super.key});
|
||||
|
@ -10,14 +15,128 @@ class KemajuanPage extends StatelessWidget {
|
|||
title: const Text('Kemajuan'),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: const Center(
|
||||
child: Text(
|
||||
'Kemajuan Pembelajaran Anda',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Search bar
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
hintText: 'Cari Santri...',
|
||||
hintStyle: TextStyle(color: Colors.grey),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(color: secondPrimaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Judul Pilih Santri
|
||||
Text(
|
||||
'Pilih Santri',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color:
|
||||
secondPrimaryColor, // Gunakan secondPrimaryColor dari theme.dart
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Menggunakan SliverList dengan kemajuanList
|
||||
Expanded(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
// Mengambil data kemajuan dari kemajuanList
|
||||
var kemajuan = kemajuanList[index];
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Menampilkan detail subMateri, menggunakan subMateri yang terkait
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(
|
||||
vertical: 5.0,
|
||||
),
|
||||
leading: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
shape:
|
||||
BoxShape
|
||||
.circle, // Membuat kontainer berbentuk bulat
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
'assets/icon/${kemajuan['image']}',
|
||||
), // Gambar asset lokal
|
||||
fit:
|
||||
BoxFit
|
||||
.cover, // Gambar akan menyesuaikan dengan ukuran kontainer
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
kemajuan['nama'], // Menampilkan nama
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
kemajuan['jilid'], // Menampilkan jilid
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
context.go('/detail_kemajuan',
|
||||
extra: {'nama': kemajuan['nama']},
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
thickness: 1,
|
||||
indent: 80,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount:
|
||||
kemajuanList
|
||||
.length, // Menyesuaikan jumlah item yang ada pada kemajuanList
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
import 'package:ta_tahsin/view/home/submateri/model/model_data_submateri.dart';
|
||||
|
||||
final List<Map<String, dynamic>> kemajuanList = [
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
{
|
||||
'nama': 'irfan',
|
||||
'jilid': 'tilawati 2',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
// Menyambungkan subMateri dari model terpisah
|
||||
},
|
||||
{
|
||||
'nama': 'fahmi',
|
||||
'jilid': 'tilawati 1',
|
||||
'image': 'defaultprofile.jpeg',
|
||||
},
|
||||
|
||||
// Lainnya...
|
||||
];
|
|
@ -1,25 +1,218 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:ta_tahsin/core/baseurl/base_url.dart';
|
||||
import 'package:ta_tahsin/core/theme.dart';
|
||||
|
||||
class PengajarProfilePage extends StatelessWidget {
|
||||
const PengajarProfilePage({super.key});
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
// Ambil token yang ada di SharedPreferences
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
|
||||
if (token != null) {
|
||||
// Panggil API logout untuk menghapus token di server
|
||||
final response = await http.post(
|
||||
Uri.parse('${BaseUrl.baseUrl}/logout'), // Ganti dengan URL API logout
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token', // Kirim token di header
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Jika berhasil logout, hapus token dari SharedPreferences
|
||||
prefs.remove('token');
|
||||
|
||||
// Arahkan pengguna ke halaman login atau halaman lain setelah logout
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Berhasil logout!')),
|
||||
);
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
context.go('/login');
|
||||
} else {
|
||||
// Jika ada error dari server
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Gagal logout: ${response.body}')),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Jika tidak ada token yang tersimpan
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Token tidak ditemukan')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Profile'),
|
||||
elevation: 0,
|
||||
title: Text(
|
||||
"Profile",
|
||||
),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: const Center(
|
||||
child: Text(
|
||||
'Profile',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Profile Section with Gradient Card
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
elevation: 5,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
secondPrimaryColor,
|
||||
Colors.blue,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
// Profile Avatar
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor: Colors.white,
|
||||
backgroundImage: AssetImage('assets/logo/sho.jpg'),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Name and Phone Number to the right
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"irfan",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
"083166408735",
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: Colors.white.withOpacity(0.8)),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// "Hasil Placement Test" Section with Gradient Card
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
elevation: 5,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
secondPrimaryColor,
|
||||
Colors.blue,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTestResultSection("Tgl Lahir", "-"),
|
||||
Divider(color: Colors.white), // White Divider for contrast
|
||||
_buildTestResultSection("Alamat", "-"),
|
||||
Divider(color: Colors.white), // White Divider for contrast
|
||||
_buildTestResultSection("Nama Orang Tua", "-"),
|
||||
Divider(color: Colors.white), // White Divider for contrast
|
||||
_buildTestResultSection("email", "-"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: secondPrimaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
minimumSize: Size(double.infinity, 50),
|
||||
),
|
||||
onPressed: () {
|
||||
logout(context);
|
||||
},
|
||||
child: Text(
|
||||
"Logout",
|
||||
style: TextStyle(fontSize: 16,color: whiteColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Method to build test result sections
|
||||
Widget _buildTestResultSection(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
SizedBox(height: 6), // Space between label and value
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Method to create info links
|
||||
Widget _buildInfoLink(String label) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Icon(Icons.arrow_forward, color: secondPrimaryColor),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(fontSize: 16, color: secondPrimaryColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ flutter:
|
|||
assets:
|
||||
- assets/logo/
|
||||
- assets/audio/
|
||||
- assets/icon/
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
|
Loading…
Reference in New Issue