1
This commit is contained in:
103
lib/page/education/list/education_list_page.dart
Normal file
103
lib/page/education/list/education_list_page.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'package:derma_flutter/api/dto/article_dto.dart';
|
||||
import 'package:derma_flutter/api/endpoints/skin_api.dart';
|
||||
import 'package:derma_flutter/widgets/common/app_backend.dart';
|
||||
import 'package:derma_flutter/widgets/ui_kit/empty/index.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../router/config/route_paths.dart';
|
||||
|
||||
class EducationListPage extends StatefulWidget {
|
||||
const EducationListPage({super.key});
|
||||
|
||||
@override
|
||||
State<EducationListPage> createState() => _EducationListPageState();
|
||||
}
|
||||
|
||||
class _EducationListPageState extends State<EducationListPage> {
|
||||
var _loading = false;
|
||||
final List<ArticleDto> _list = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_init();
|
||||
}
|
||||
|
||||
void _init() async {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
});
|
||||
var list = await articleListApi();
|
||||
setState(() {
|
||||
_list.clear();
|
||||
_list.addAll(list);
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _handToDetail(ArticleDto item) {
|
||||
context.push(RoutePaths.articleDetail(item.id));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Skin Health Education"),
|
||||
),
|
||||
body: AppBackend(
|
||||
child: SafeArea(
|
||||
child: Visibility(
|
||||
visible: !_loading && _list.isNotEmpty,
|
||||
replacement: Empty(),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
var item = _list[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
_handToDetail(item);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0xffE9E9E9),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 9,
|
||||
offset: Offset(1, 2), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.title ?? ''),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
item.subtitle ?? "",
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Container(
|
||||
height: 15,
|
||||
);
|
||||
},
|
||||
itemCount: _list.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user