listmember.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // ignore_for_file: must_call_super, prefer_typing_uninitialized_variables
  2. import 'package:dio/dio.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:namer_app/data/datamember.dart';
  5. import 'package:namer_app/footer.dart';
  6. import 'package:namer_app/header.dart';
  7. import '../globals.dart';
  8. class ListMemberPage extends StatefulWidget {
  9. final int id;
  10. const ListMemberPage({super.key, required this.id});
  11. @override
  12. State<ListMemberPage> createState() => _ListMemberPageState();
  13. }
  14. class _ListMemberPageState extends State<ListMemberPage> {
  15. var jsonList;
  16. @override
  17. void initState(){
  18. getData();
  19. }
  20. void getData() async {
  21. try {
  22. var response = await Dio()
  23. // .get('http://localhost:8080/api/v1/projects/$id/member',
  24. .get('http://localhost:8080/api/v1/projects/member',
  25. options: Options(headers: headers));
  26. if (response.statusCode == 200) {
  27. setState(() {
  28. jsonList = response.data['results'] as List;
  29. });
  30. } else {
  31. print(response.statusCode);
  32. }
  33. } catch (e) {
  34. print(e);
  35. }
  36. }
  37. @override
  38. Widget build(BuildContext context) {
  39. return Scaffold(
  40. appBar: CustomAppbar(),
  41. body: Stack(children: [
  42. SingleChildScrollView(
  43. child: Column(
  44. children: [
  45. Center(
  46. child: Row(
  47. mainAxisAlignment: MainAxisAlignment.center,
  48. children: [
  49. Text(
  50. 'LIST MEMBER',
  51. style: TextStyle(color: Colors.black, fontSize: 48),
  52. ),
  53. ],
  54. )),
  55. Column(
  56. children: List.generate(
  57. 2,
  58. (i) => SizedBox(
  59. child: ListTile(
  60. leading: SizedBox(
  61. child: Icon(Icons.group_work),
  62. ),
  63. title: Text(members[i]['project']),
  64. subtitle: Column(
  65. crossAxisAlignment: CrossAxisAlignment.start,
  66. children: [
  67. Row(
  68. children: [
  69. Text(members[i]['member1']),
  70. Expanded(child: Container()),
  71. Text(members[i]['role1'])
  72. ],
  73. ),
  74. Row(
  75. children: [
  76. Text(members[i]['member2']),
  77. Expanded(child: Container()),
  78. Text(members[i]['role2'])
  79. ],
  80. )
  81. ],
  82. ),
  83. trailing: ButtonUser(
  84. items: members[i],
  85. ),
  86. ),
  87. )),
  88. ),
  89. ],
  90. ),
  91. ),
  92. ]),
  93. bottomNavigationBar: Footer(),
  94. );
  95. }
  96. }
  97. class ButtonUser extends StatelessWidget {
  98. final Map<String, dynamic> items;
  99. ButtonUser({
  100. required this.items,
  101. super.key,
  102. });
  103. //todo delete
  104. //todo tombol item
  105. @override
  106. Widget build(BuildContext context) {
  107. return Row(
  108. // crossAxisAlignment: CrossAxisAlignment.center,
  109. mainAxisSize: MainAxisSize.min,
  110. children: [
  111. ElevatedButton(
  112. onPressed: null,
  113. style: ElevatedButton.styleFrom(
  114. backgroundColor: Colors.black,
  115. ),
  116. child: Text(
  117. 'Edit',
  118. style: TextStyle(color: Colors.white),
  119. ),
  120. ),
  121. ElevatedButton(
  122. onPressed: null,
  123. style: ElevatedButton.styleFrom(
  124. backgroundColor: Colors.black,
  125. ),
  126. child: Text(
  127. 'Delete',
  128. style: TextStyle(color: Colors.white),
  129. ),
  130. ),
  131. ],
  132. );
  133. }
  134. }