Advertisement
Zanak

Untitled

May 31st, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.69 KB | None | 0 0
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import 'package:google_fonts/google_fonts.dart';
  4. import 'package:line_icons/line_icons.dart';
  5. import 'package:teledentistry_baksos/ColorFilter.dart';
  6. import 'package:cloud_firestore/cloud_firestore.dart';
  7. import 'package:teledentistry_baksos/HomePage.dart';
  8.  
  9. class KoasCard extends StatelessWidget {
  10. final String nama;
  11. final String preseptor;
  12. final String asal;
  13. final bool online;
  14.  
  15. //// Pointer to Update Function
  16. final Function onUpdate;
  17. //// Pointer to Delete Function
  18. final Function onDelete;
  19.  
  20. KoasCard(this.nama, this.asal, this.preseptor, this.online,
  21. {this.onUpdate, this.onDelete});
  22.  
  23. @override
  24. Widget build(BuildContext context) {
  25. return Container(
  26. height: 300,
  27. width: 300,
  28. child: Card(
  29. clipBehavior: Clip.antiAlias,
  30. shape: RoundedRectangleBorder(
  31. borderRadius: BorderRadius.circular(24),
  32. ),
  33. elevation: 10,
  34. child: InkWell(
  35. child: Stack(
  36. alignment: Alignment.topCenter,
  37. children: [
  38. Ink.image(
  39. image: NetworkImage(
  40. 'https://images.unsplash.com/photo-1514888286974-6c03e2ca1dba?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1327&q=80',
  41. ),
  42. colorFilter: ColorFilters.greyscale,
  43. height: 200,
  44. width: 300,
  45. fit: BoxFit.fitHeight,
  46. ),
  47. SizedBox(
  48. height: 100,
  49. ),
  50. Column(
  51. mainAxisAlignment: MainAxisAlignment.end,
  52. children: <Widget>[
  53. Text(nama,
  54. style: GoogleFonts.poppins(
  55. fontWeight: FontWeight.w600,
  56. fontSize: 16,
  57. color: Colors.black)),
  58. Text(asal,
  59. style: GoogleFonts.poppins(
  60. fontWeight: FontWeight.w600,
  61. fontSize: 16,
  62. color: Colors.black)),
  63. Text(preseptor,
  64. style: GoogleFonts.poppins(
  65. fontWeight: FontWeight.w700,
  66. fontSize: 16,
  67. color: Colors.black)),
  68. Text((online) ? 'online' : 'tdk aktif',
  69. style: GoogleFonts.poppins(
  70. fontWeight: FontWeight.w500,
  71. fontSize: 16,
  72. color: Colors.black)),
  73. ],
  74. ),
  75. ],
  76. ),
  77. onTap: () {},
  78. ),
  79. ),
  80. );
  81. }
  82. }
  83.  
  84. class SelectKoasstl extends StatelessWidget {
  85. const SelectKoasstl({Key key}) : super(key: key);
  86.  
  87. @override
  88. Widget build(BuildContext context) {
  89. return MaterialApp(
  90. home: SelectKoas(),
  91. );
  92. }
  93. }
  94.  
  95. class SelectKoas extends StatefulWidget {
  96. const SelectKoas({Key key}) : super(key: key);
  97.  
  98. @override
  99. _SelectKoasState createState() => _SelectKoasState();
  100. }
  101.  
  102. class _SelectKoasState extends State<SelectKoas> {
  103. final TextEditingController judulController = TextEditingController();
  104. final TextEditingController penulisController = TextEditingController();
  105. final TextEditingController urlgambarController = TextEditingController();
  106.  
  107. @override
  108. Widget build(BuildContext context) {
  109. FirebaseFirestore firestore = FirebaseFirestore.instance;
  110. CollectionReference users = firestore.collection('data_koas');
  111. return Scaffold(
  112. backgroundColor: Colors.white,
  113. body: Column(
  114. children: [
  115. Container(
  116. height: 100,
  117. color: Colors.teal,
  118. child: Row(
  119. mainAxisAlignment: MainAxisAlignment.start,
  120. children: <Widget>[
  121. InkWell(
  122. child: Padding(
  123. padding: EdgeInsets.all(15),
  124. child: Icon(LineIcons.arrowCircleLeft,
  125. color: Colors.white, size: 36.0),
  126. ),
  127. onTap: () {
  128. Navigator.pushReplacement(context,
  129. MaterialPageRoute(builder: (context) {
  130. return HomePagestl();
  131. }));
  132. },
  133. ),
  134. Text('Ubah Profile',
  135. style: TextStyle(
  136. fontSize: 28,
  137. fontWeight: FontWeight.w500,
  138. color: Colors.white))
  139. ],
  140. ),
  141.  
  142. //ini pengganti appbar yg di modif
  143. ),
  144. Expanded(
  145. child: Container(
  146. color: Colors.teal,
  147. child: Container(
  148. decoration: BoxDecoration(
  149. color: Colors.white,
  150. borderRadius: BorderRadius.only(
  151. topLeft: Radius.circular(25),
  152. topRight: Radius.circular(25)),
  153. ),
  154. child: ListView(
  155. padding: EdgeInsets.all(16),
  156. children: [
  157. StreamBuilder(
  158. stream: users.snapshots(),
  159. builder: (_, snapshot) {
  160. if (snapshot.hasData) {
  161. if (true) { // I want if the data['online'] = true, then return Column executed
  162. return Column(
  163. children: snapshot.data.docs
  164. .map<Widget>(
  165. (e) => KoasCard(
  166. 'nama : ' + e.data()['nama'],
  167. 'preseptor : ' +
  168. e.data()['preseptor'],
  169. e.data()['asal'],
  170. e.data()['online'],
  171. onUpdate: () {},
  172. ),
  173. )
  174. .toList(),
  175. );
  176. }
  177. } else {
  178. Text('Loading');
  179.  
  180. SizedBox(
  181. height: 10,
  182. );
  183. }
  184. }),
  185. ],
  186. )),
  187. ),
  188. ),
  189. ],
  190. ),
  191. );
  192. }
  193. }
  194.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement