repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/auth
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/auth/screens/auth_screen.dart
import 'package:amazon_clone/common/widgets/custom_button.dart'; import 'package:amazon_clone/common/widgets/custom_textfield.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/features/auth/services/auth_service.dart'; import 'package:flutter/material.dart'; enum Auth { signin, signup, } class AuthScreen extends StatefulWidget { static const String routeName = '/auth-screen'; const AuthScreen({Key? key}) : super(key: key); @override State<AuthScreen> createState() => _AuthScreenState(); } class _AuthScreenState extends State<AuthScreen> { Auth _auth = Auth.signup; final _signUpFormKey = GlobalKey<FormState>(); final _signInFormKey = GlobalKey<FormState>(); final AuthService authService = AuthService(); final TextEditingController _emailController = TextEditingController(); final TextEditingController _passwordController = TextEditingController(); final TextEditingController _nameController = TextEditingController(); @override void dispose() { super.dispose(); _emailController.dispose(); _passwordController.dispose(); _nameController.dispose(); } void signUpUser() { authService.signUpUser( context: context, email: _emailController.text, password: _passwordController.text, name: _nameController.text, ); } void signInUser() { authService.signInUser( context: context, email: _emailController.text, password: _passwordController.text, ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: GlobalVariables.greyBackgroundCOlor, body: SafeArea( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Welcome', style: TextStyle( fontSize: 22, fontWeight: FontWeight.w500, ), ), ListTile( tileColor: _auth == Auth.signup ? GlobalVariables.backgroundColor : GlobalVariables.greyBackgroundCOlor, title: const Text( 'Create Account', style: TextStyle( fontWeight: FontWeight.bold, ), ), leading: Radio( activeColor: GlobalVariables.secondaryColor, value: Auth.signup, groupValue: _auth, onChanged: (Auth? val) { setState(() { _auth = val!; }); }, ), ), if (_auth == Auth.signup) Container( padding: const EdgeInsets.all(8), color: GlobalVariables.backgroundColor, child: Form( key: _signUpFormKey, child: Column( children: [ CustomTextField( controller: _nameController, hintText: 'Name', ), const SizedBox(height: 10), CustomTextField( controller: _emailController, hintText: 'Email', ), const SizedBox(height: 10), CustomTextField( controller: _passwordController, hintText: 'Password', ), const SizedBox(height: 10), CustomButton( text: 'Sign Up', onTap: () { if (_signUpFormKey.currentState!.validate()) { signUpUser(); } }, ) ], ), ), ), ListTile( tileColor: _auth == Auth.signin ? GlobalVariables.backgroundColor : GlobalVariables.greyBackgroundCOlor, title: const Text( 'Sign-In.', style: TextStyle( fontWeight: FontWeight.bold, ), ), leading: Radio( activeColor: GlobalVariables.secondaryColor, value: Auth.signin, groupValue: _auth, onChanged: (Auth? val) { setState(() { _auth = val!; }); }, ), ), if (_auth == Auth.signin) Container( padding: const EdgeInsets.all(8), color: GlobalVariables.backgroundColor, child: Form( key: _signInFormKey, child: Column( children: [ CustomTextField( controller: _emailController, hintText: 'Email', ), const SizedBox(height: 10), CustomTextField( controller: _passwordController, hintText: 'Password', ), const SizedBox(height: 10), CustomButton( text: 'Sign In', onTap: () { if (_signInFormKey.currentState!.validate()) { signInUser(); } }, ) ], ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/widgets/deal_of_day.dart
import 'package:amazon_clone/common/widgets/loader.dart'; import 'package:amazon_clone/features/home/services/home_services.dart'; import 'package:amazon_clone/features/product_details/screens/product_details_screen.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:flutter/material.dart'; class DealOfDay extends StatefulWidget { const DealOfDay({Key? key}) : super(key: key); @override State<DealOfDay> createState() => _DealOfDayState(); } class _DealOfDayState extends State<DealOfDay> { Product? product; final HomeServices homeServices = HomeServices(); @override void initState() { super.initState(); fetchDealOfDay(); } void fetchDealOfDay() async { product = await homeServices.fetchDealOfDay(context: context); setState(() {}); } void navigateToDetailScreen() { Navigator.pushNamed( context, ProductDetailScreen.routeName, arguments: product, ); } @override Widget build(BuildContext context) { return product == null ? const Loader() : product!.name.isEmpty ? const SizedBox() : GestureDetector( onTap: navigateToDetailScreen, child: Column( children: [ Container( alignment: Alignment.topLeft, padding: const EdgeInsets.only(left: 10, top: 15), child: const Text( 'Deal of the day', style: TextStyle(fontSize: 20), ), ), Image.network( product!.images[0], height: 235, fit: BoxFit.fitHeight, ), Container( padding: const EdgeInsets.only(left: 15), alignment: Alignment.topLeft, child: const Text( '\$100', style: TextStyle(fontSize: 18), ), ), Container( alignment: Alignment.topLeft, padding: const EdgeInsets.only(left: 15, top: 5, right: 40), child: const Text( 'Pratyush', maxLines: 2, overflow: TextOverflow.ellipsis, ), ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: product!.images .map( (e) => Image.network( e, fit: BoxFit.fitWidth, width: 100, height: 100, ), ) .toList(), ), ), Container( padding: const EdgeInsets.symmetric( vertical: 15, ).copyWith(left: 15), alignment: Alignment.topLeft, child: Text( 'See all deals', style: TextStyle( color: Colors.cyan[800], ), ), ), ], ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/widgets/carousel_image.dart
import 'package:amazon_clone/constants/global_variables.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; class CarouselImage extends StatelessWidget { const CarouselImage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return CarouselSlider( items: GlobalVariables.carouselImages.map( (i) { return Builder( builder: (BuildContext context) => Image.network( i, fit: BoxFit.cover, height: 200, ), ); }, ).toList(), options: CarouselOptions( viewportFraction: 1, height: 200, ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/widgets/top_categories.dart
import 'package:flutter/material.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/features/home/screens/category_deals_screen.dart'; class TopCategories extends StatelessWidget { const TopCategories({Key? key}) : super(key: key); void navigateToCategoryPage(BuildContext context, String category) { Navigator.pushNamed(context, CategoryDealsScreen.routeName, arguments: category); } @override Widget build(BuildContext context) { return SizedBox( height: 60, child: ListView.builder( itemCount: GlobalVariables.categoryImages.length, scrollDirection: Axis.horizontal, itemExtent: 75, itemBuilder: (context, index) { return GestureDetector( onTap: () => navigateToCategoryPage( context, GlobalVariables.categoryImages[index]['title']!, ), child: Column( children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 10), child: ClipRRect( borderRadius: BorderRadius.circular(50), child: Image.asset( GlobalVariables.categoryImages[index]['image']!, fit: BoxFit.cover, height: 40, width: 40, ), ), ), Text( GlobalVariables.categoryImages[index]['title']!, style: const TextStyle( fontSize: 12, fontWeight: FontWeight.w400, ), ), ], ), ); }, ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/widgets/address_box.dart
import 'package:amazon_clone/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class AddressBox extends StatelessWidget { const AddressBox({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context).user; return Container( height: 40, decoration: const BoxDecoration( gradient: LinearGradient( colors: [ Color.fromARGB(255, 114, 226, 221), Color.fromARGB(255, 162, 236, 233), ], stops: [0.5, 1.0], ), ), padding: const EdgeInsets.only(left: 10), child: Row( children: [ const Icon( Icons.location_on_outlined, size: 20, ), Expanded( child: Padding( padding: const EdgeInsets.only(left: 5), child: Text( 'Delivery to ${user.name} - ${user.address}', style: const TextStyle( fontWeight: FontWeight.w500, ), overflow: TextOverflow.ellipsis, ), ), ), const Padding( padding: EdgeInsets.only( left: 5, top: 2, ), child: Icon( Icons.arrow_drop_down_outlined, size: 18, ), ) ], ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/services/home_services.dart
import 'dart:convert'; import 'package:amazon_clone/constants/error_handling.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/constants/utils.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:amazon_clone/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; class HomeServices { Future<List<Product>> fetchCategoryProducts({ required BuildContext context, required String category, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); List<Product> productList = []; try { http.Response res = await http .get(Uri.parse('$uri/api/products?category=$category'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }); httpErrorHandle( response: res, context: context, onSuccess: () { for (int i = 0; i < jsonDecode(res.body).length; i++) { productList.add( Product.fromJson( jsonEncode( jsonDecode(res.body)[i], ), ), ); } }, ); } catch (e) { showSnackBar(context, e.toString()); } return productList; } Future<Product> fetchDealOfDay({ required BuildContext context, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); Product product = Product( name: '', description: '', quantity: 0, images: [], category: '', price: 0, ); try { http.Response res = await http.get(Uri.parse('$uri/api/deal-of-day'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }); httpErrorHandle( response: res, context: context, onSuccess: () { product = Product.fromJson(res.body); }, ); } catch (e) { showSnackBar(context, e.toString()); } return product; } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/screens/home_screen.dart
import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/features/home/widgets/address_box.dart'; import 'package:amazon_clone/features/home/widgets/carousel_image.dart'; import 'package:amazon_clone/features/home/widgets/deal_of_day.dart'; import 'package:amazon_clone/features/home/widgets/top_categories.dart'; import 'package:amazon_clone/features/search/screens/search_screen.dart'; import 'package:flutter/material.dart'; class HomeScreen extends StatefulWidget { static const String routeName = '/home'; const HomeScreen({Key? key}) : super(key: key); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { void navigateToSearchScreen(String query) { Navigator.pushNamed(context, SearchScreen.routeName, arguments: query); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), child: AppBar( flexibleSpace: Container( decoration: const BoxDecoration( gradient: GlobalVariables.appBarGradient, ), ), title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Container( height: 42, margin: const EdgeInsets.only(left: 15), child: Material( borderRadius: BorderRadius.circular(7), elevation: 1, child: TextFormField( onFieldSubmitted: navigateToSearchScreen, decoration: InputDecoration( prefixIcon: InkWell( onTap: () {}, child: const Padding( padding: EdgeInsets.only( left: 6, ), child: Icon( Icons.search, color: Colors.black, size: 23, ), ), ), filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.only(top: 10), border: const OutlineInputBorder( borderRadius: BorderRadius.all( Radius.circular(7), ), borderSide: BorderSide.none, ), enabledBorder: const OutlineInputBorder( borderRadius: BorderRadius.all( Radius.circular(7), ), borderSide: BorderSide( color: Colors.black38, width: 1, ), ), hintText: 'Search Amazon.in', hintStyle: const TextStyle( fontWeight: FontWeight.w500, fontSize: 17, ), ), ), ), ), ), Container( color: Colors.transparent, height: 42, margin: const EdgeInsets.symmetric(horizontal: 10), child: const Icon(Icons.mic, color: Colors.black, size: 25), ), ], ), ), ), body: const SingleChildScrollView( child: Column( children: [ AddressBox(), SizedBox(height: 10), TopCategories(), SizedBox(height: 10), CarouselImage(), DealOfDay(), ], ), ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/home/screens/category_deals_screen.dart
import 'package:amazon_clone/common/widgets/loader.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/features/home/services/home_services.dart'; import 'package:amazon_clone/features/product_details/screens/product_details_screen.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:flutter/material.dart'; class CategoryDealsScreen extends StatefulWidget { static const String routeName = '/category-deals'; final String category; const CategoryDealsScreen({ Key? key, required this.category, }) : super(key: key); @override State<CategoryDealsScreen> createState() => _CategoryDealsScreenState(); } class _CategoryDealsScreenState extends State<CategoryDealsScreen> { List<Product>? productList; final HomeServices homeServices = HomeServices(); @override void initState() { super.initState(); fetchCategoryProducts(); } fetchCategoryProducts() async { productList = (await homeServices.fetchCategoryProducts( context: context, category: widget.category, )).cast<Product>(); setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(50), child: AppBar( flexibleSpace: Container( decoration: const BoxDecoration( gradient: GlobalVariables.appBarGradient, ), ), title: Text( widget.category, style: const TextStyle( color: Colors.black, ), ), ), ), body: productList == null ? const Loader() : Column( children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), alignment: Alignment.topLeft, child: Text( 'Keep shopping for ${widget.category}', style: const TextStyle( fontSize: 20, ), ), ), SizedBox( height: 170, child: GridView.builder( scrollDirection: Axis.horizontal, padding: const EdgeInsets.only(left: 15), itemCount: productList!.length, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 1, childAspectRatio: 1.4, mainAxisSpacing: 10, ), itemBuilder: (context, index) { final product = productList![index]; return GestureDetector( onTap: () { Navigator.pushNamed( context, ProductDetailScreen.routeName, arguments: product, ); }, child: Column( children: [ SizedBox( height: 130, child: DecoratedBox( decoration: BoxDecoration( border: Border.all( color: Colors.black12, width: 0.5, ), ), child: Padding( padding: const EdgeInsets.all(10), child: Image.network( product.images[0], ), ), ), ), Container( alignment: Alignment.topLeft, padding: const EdgeInsets.only( left: 0, top: 5, right: 15, ), child: Text( product.name, maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ), ); }, ), ), ], ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/address
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/address/services/address_services.dart
import 'dart:convert'; import 'package:amazon_clone/constants/error_handling.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/constants/utils.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:amazon_clone/models/user.dart'; import 'package:amazon_clone/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:provider/provider.dart'; class AddressServices { void saveUserAddress({ required BuildContext context, required String address, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post( Uri.parse('$uri/api/save-user-address'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode({ 'address': address, }), ); httpErrorHandle( response: res, context: context, onSuccess: () { User user = userProvider.user.copyWith( address: jsonDecode(res.body)['address'], ); userProvider.setUserFromModel(user); }, ); } catch (e) { showSnackBar(context, e.toString()); } } // get all the products void placeOrder({ required BuildContext context, required String address, required double totalSum, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post(Uri.parse('$uri/api/order'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode({ 'cart': userProvider.user.cart, 'address': address, 'totalPrice': totalSum, })); httpErrorHandle( response: res, context: context, onSuccess: () { showSnackBar(context, 'Your order has been placed!'); User user = userProvider.user.copyWith( cart: [], ); userProvider.setUserFromModel(user); }, ); } catch (e) { showSnackBar(context, e.toString()); } } void deleteProduct({ required BuildContext context, required Product product, required VoidCallback onSuccess, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post( Uri.parse('$uri/admin/delete-product'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode({ 'id': product.id, }), ); httpErrorHandle( response: res, context: context, onSuccess: () { onSuccess(); }, ); } catch (e) { showSnackBar(context, e.toString()); } } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/address
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/address/screens/address_screen.dart
import 'package:amazon_clone/common/widgets/custom_textfield.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/constants/utils.dart'; import 'package:amazon_clone/features/address/services/address_services.dart'; import 'package:amazon_clone/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:pay/pay.dart'; import 'package:provider/provider.dart'; class AddressScreen extends StatefulWidget { static const String routeName = '/address'; final String totalAmount; const AddressScreen({ Key? key, required this.totalAmount, }) : super(key: key); @override State<AddressScreen> createState() => _AddressScreenState(); } class _AddressScreenState extends State<AddressScreen> { final TextEditingController flatBuildingController = TextEditingController(); final TextEditingController areaController = TextEditingController(); final TextEditingController pincodeController = TextEditingController(); final TextEditingController cityController = TextEditingController(); final _addressFormKey = GlobalKey<FormState>(); String addressToBeUsed = ""; List<PaymentItem> paymentItems = []; final AddressServices addressServices = AddressServices(); @override void initState() { super.initState(); paymentItems.add( PaymentItem( amount: widget.totalAmount, label: 'Total Amount', status: PaymentItemStatus.final_price, ), ); } @override void dispose() { super.dispose(); flatBuildingController.dispose(); areaController.dispose(); pincodeController.dispose(); cityController.dispose(); } void onApplePayResult(res) { if (Provider.of<UserProvider>(context, listen: false) .user .address .isEmpty) { addressServices.saveUserAddress( context: context, address: addressToBeUsed); } addressServices.placeOrder( context: context, address: addressToBeUsed, totalSum: double.parse(widget.totalAmount), ); } void onGooglePayResult(res) { if (Provider.of<UserProvider>(context, listen: false) .user .address .isEmpty) { addressServices.saveUserAddress( context: context, address: addressToBeUsed); } addressServices.placeOrder( context: context, address: addressToBeUsed, totalSum: double.parse(widget.totalAmount), ); } void payPressed(String addressFromProvider) { addressToBeUsed = ""; bool isForm = flatBuildingController.text.isNotEmpty || areaController.text.isNotEmpty || pincodeController.text.isNotEmpty || cityController.text.isNotEmpty; if (isForm) { if (_addressFormKey.currentState!.validate()) { addressToBeUsed = '${flatBuildingController.text}, ${areaController.text}, ${cityController.text} - ${pincodeController.text}'; } else { throw Exception('Please enter all the values!'); } } else if (addressFromProvider.isNotEmpty) { addressToBeUsed = addressFromProvider; } else { showSnackBar(context, 'ERROR'); } } @override Widget build(BuildContext context) { var address = context.watch<UserProvider>().user.address; return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), child: AppBar( flexibleSpace: Container( decoration: const BoxDecoration( gradient: GlobalVariables.appBarGradient, ), ), ), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ if (address.isNotEmpty) Column( children: [ Container( width: double.infinity, decoration: BoxDecoration( border: Border.all( color: Colors.black12, ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Text( address, style: const TextStyle( fontSize: 18, ), ), ), ), const SizedBox(height: 20), const Text( 'OR', style: TextStyle( fontSize: 18, ), ), const SizedBox(height: 20), ], ), Form( key: _addressFormKey, child: Column( children: [ CustomTextField( controller: flatBuildingController, hintText: 'Flat, House no, Building', ), const SizedBox(height: 10), CustomTextField( controller: areaController, hintText: 'Area, Street', ), const SizedBox(height: 10), CustomTextField( controller: pincodeController, hintText: 'Pincode', ), const SizedBox(height: 10), CustomTextField( controller: cityController, hintText: 'Town/City', ), const SizedBox(height: 10), ], ), ), ApplePayButton( width: double.infinity, style: ApplePayButtonStyle.whiteOutline, type: ApplePayButtonType.buy, paymentConfigurationAsset: 'applepay.json', onPaymentResult: onApplePayResult, paymentItems: paymentItems, margin: const EdgeInsets.only(top: 15), height: 50, onPressed: () => payPressed(address), ), const SizedBox(height: 10), GooglePayButton( onPressed: () => payPressed(address), paymentConfigurationAsset: 'gpay.json', onPaymentResult: onGooglePayResult, paymentItems: paymentItems, height: 50, type: GooglePayButtonType.buy, margin: const EdgeInsets.only(top: 15), loadingIndicator: const Center( child: CircularProgressIndicator(), ), ), ], ), ), ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/search
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/search/widget/searched_product.dart
import 'package:amazon_clone/common/widgets/stars.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:flutter/material.dart'; class SearchedProduct extends StatelessWidget { final Product product; const SearchedProduct({ Key? key, required this.product, }) : super(key: key); @override Widget build(BuildContext context) { double totalRating = 0; for (int i = 0; i < product.rating!.length; i++) { totalRating += product.rating![i].rating; } double avgRating = 0; if (totalRating != 0) { avgRating = totalRating / product.rating!.length; } return Column( children: [ Container( margin: const EdgeInsets.symmetric( horizontal: 10, ), child: Row( children: [ Image.network( product.images[0], fit: BoxFit.contain, height: 135, width: 135, ), Column( children: [ Container( width: 235, padding: const EdgeInsets.symmetric(horizontal: 10), child: Text( product.name, style: const TextStyle( fontSize: 16, ), maxLines: 2, ), ), Container( width: 235, padding: const EdgeInsets.only(left: 10, top: 5), child: Stars( rating: avgRating, ), ), Container( width: 235, padding: const EdgeInsets.only(left: 10, top: 5), child: Text( '\$${product.price}', style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold, ), maxLines: 2, ), ), Container( width: 235, padding: const EdgeInsets.only(left: 10), child: const Text('Eligible for FREE Shipping'), ), Container( width: 235, padding: const EdgeInsets.only(left: 10, top: 5), child: const Text( 'In Stock', style: TextStyle( color: Colors.teal, ), maxLines: 2, ), ), ], ), ], ), ), ], ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/search
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/search/services/search_services.dart
import 'dart:convert'; import 'package:amazon_clone/constants/error_handling.dart'; import 'package:amazon_clone/constants/utils.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:amazon_clone/private.dart'; import 'package:amazon_clone/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; class SearchServices { Future<List<Product>> fetchSearchedProduct({ required BuildContext context, required String searchQuery, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); List<Product> productList = []; try { http.Response res = await http.get( Uri.parse('$uri/api/products/search/$searchQuery'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, ); httpErrorHandle( response: res, context: context, onSuccess: () { for (int i = 0; i < jsonDecode(res.body).length; i++) { productList.add( Product.fromJson( jsonEncode( jsonDecode(res.body)[i], ), ), ); } }, ); } catch (e) { showSnackBar(context, e.toString()); } return productList; } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/search
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/features/search/screens/search_screen.dart
import 'package:amazon_clone/common/widgets/loader.dart'; import 'package:amazon_clone/constants/global_variables.dart'; import 'package:amazon_clone/features/home/widgets/address_box.dart'; import 'package:amazon_clone/features/product_details/screens/product_details_screen.dart'; import 'package:amazon_clone/features/search/services/search_services.dart'; import 'package:amazon_clone/features/search/widget/searched_product.dart'; import 'package:amazon_clone/models/product.dart'; import 'package:flutter/material.dart'; class SearchScreen extends StatefulWidget { static const String routeName = '/search-screen'; final String searchQuery; const SearchScreen({ Key? key, required this.searchQuery, }) : super(key: key); @override State<SearchScreen> createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { List<Product>? products; final SearchServices searchServices = SearchServices(); @override void initState() { super.initState(); fetchSearchedProduct(); } fetchSearchedProduct() async { products = (await searchServices.fetchSearchedProduct( context: context, searchQuery: widget.searchQuery)).cast<Product>(); setState(() {}); } void navigateToSearchScreen(String query) { Navigator.pushNamed(context, SearchScreen.routeName, arguments: query); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), child: AppBar( flexibleSpace: Container( decoration: const BoxDecoration( gradient: GlobalVariables.appBarGradient, ), ), title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Container( height: 42, margin: const EdgeInsets.only(left: 15), child: Material( borderRadius: BorderRadius.circular(7), elevation: 1, child: TextFormField( onFieldSubmitted: navigateToSearchScreen, decoration: InputDecoration( prefixIcon: InkWell( onTap: () {}, child: const Padding( padding: EdgeInsets.only( left: 6, ), child: Icon( Icons.search, color: Colors.black, size: 23, ), ), ), filled: true, fillColor: Colors.white, contentPadding: const EdgeInsets.only(top: 10), border: const OutlineInputBorder( borderRadius: BorderRadius.all( Radius.circular(7), ), borderSide: BorderSide.none, ), enabledBorder: const OutlineInputBorder( borderRadius: BorderRadius.all( Radius.circular(7), ), borderSide: BorderSide( color: Colors.black38, width: 1, ), ), hintText: 'Search Amazon.in', hintStyle: const TextStyle( fontWeight: FontWeight.w500, fontSize: 17, ), ), ), ), ), ), Container( color: Colors.transparent, height: 42, margin: const EdgeInsets.symmetric(horizontal: 10), child: const Icon(Icons.mic, color: Colors.black, size: 25), ), ], ), ), ), body: products == null ? const Loader() : Column( children: [ const AddressBox(), const SizedBox(height: 10), Expanded( child: ListView.builder( itemCount: products!.length, itemBuilder: (context, index) { return GestureDetector( onTap: () { Navigator.pushNamed( context, ProductDetailScreen.routeName, arguments: products![index], ); }, child: SearchedProduct( product: products![index], ), ); }, ), ), ], ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/models/rating.dart
import 'dart:convert'; class Rating { final String userId; final double rating; Rating({ required this.userId, required this.rating, }); Map<String, dynamic> toMap() { return { 'userId': userId, 'rating': rating, }; } factory Rating.fromMap(Map<String, dynamic> map) { return Rating( userId: map['userId'] ?? '', rating: map['rating']?.toDouble() ?? 0.0, ); } String toJson() => json.encode(toMap()); factory Rating.fromJson(String source) => Rating.fromMap(json.decode(source)); }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/models/order.dart
import 'dart:convert'; import 'package:amazon_clone/models/product.dart'; class Order { final String id; final List<Product> products; final List<int> quantity; final String address; final String userId; final int orderedAt; final int status; final double totalPrice; Order({ required this.id, required this.products, required this.quantity, required this.address, required this.userId, required this.orderedAt, required this.status, required this.totalPrice, }); Map<String, dynamic> toMap() { return { 'id': id, 'products': products.map((x) => x.toMap()).toList(), 'quantity': quantity, 'address': address, 'userId': userId, 'orderedAt': orderedAt, 'status': status, 'totalPrice': totalPrice, }; } factory Order.fromMap(Map<String, dynamic> map) { return Order( id: map['_id'] ?? '', products: List<Product>.from( map['products']?.map((x) => Product.fromMap(x['product']))), quantity: List<int>.from( map['products']?.map( (x) => x['quantity'], ), ), address: map['address'] ?? '', userId: map['userId'] ?? '', orderedAt: map['orderedAt']?.toInt() ?? 0, status: map['status']?.toInt() ?? 0, totalPrice: map['totalPrice']?.toDouble() ?? 0.0, ); } String toJson() => json.encode(toMap()); factory Order.fromJson(String source) => Order.fromMap(json.decode(source)); }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/models/product.dart
import 'dart:convert'; import 'package:amazon_clone/models/rating.dart'; class Product { final String name; final String description; final double quantity; final List<String> images; final String category; final double price; final String? id; final List<Rating>? rating; Product({ required this.name, required this.description, required this.quantity, required this.images, required this.category, required this.price, this.id, this.rating, }); Map<String, dynamic> toMap() { return { 'name': name, 'description': description, 'quantity': quantity, 'images': images, 'category': category, 'price': price, 'id': id, 'rating': rating, }; } factory Product.fromMap(Map<String, dynamic> map) { return Product( name: map['name'] ?? '', description: map['description'] ?? '', quantity: map['quantity']?.toDouble() ?? 0.0, images: List<String>.from(map['images']), category: map['category'] ?? '', price: map['price']?.toDouble() ?? 0.0, id: map['_id'], rating: map['ratings'] != null ? List<Rating>.from( map['ratings']?.map( (x) => Rating.fromMap(x), ), ) : null, ); } String toJson() => json.encode(toMap()); factory Product.fromJson(String source) => Product.fromMap(json.decode(source)); }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/models/user.dart
import 'dart:convert'; class User { final String id; final String name; final String email; final String password; final String address; final String type; final String token; final List<dynamic> cart; User({ required this.id, required this.name, required this.email, required this.password, required this.address, required this.type, required this.token, required this.cart, }); Map<String, dynamic> toMap() { return { 'id': id, 'name': name, 'email': email, 'password': password, 'address': address, 'type': type, 'token': token, 'cart': cart, }; } factory User.fromMap(Map<String, dynamic> map) { return User( id: map['_id'] ?? '', name: map['name'] ?? '', email: map['email'] ?? '', password: map['password'] ?? '', address: map['address'] ?? '', type: map['type'] ?? '', token: map['token'] ?? '', cart: List<Map<String, dynamic>>.from( map['cart']?.map( (x) => Map<String, dynamic>.from(x), ), ), ); } String toJson() => json.encode(toMap()); factory User.fromJson(String source) => User.fromMap(json.decode(source)); User copyWith({ String? id, String? name, String? email, String? password, String? address, String? type, String? token, List<dynamic>? cart, }) { return User( id: id ?? this.id, name: name ?? this.name, email: email ?? this.email, password: password ?? this.password, address: address ?? this.address, type: type ?? this.type, token: token ?? this.token, cart: cart ?? this.cart, ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common/widgets/custom_button.dart
import 'package:flutter/material.dart'; class CustomButton extends StatelessWidget { final String text; final VoidCallback onTap; final Color? color; const CustomButton({ Key? key, required this.text, required this.onTap, this.color, }) : super(key: key); @override Widget build(BuildContext context) { return ElevatedButton( onPressed: onTap, style: ElevatedButton.styleFrom( minimumSize: const Size(double.infinity, 50), backgroundColor: color, ), child: Text( text, style: TextStyle( color: color == null ? Colors.white : Colors.black, ), ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common/widgets/bottom_bar.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../constants/global_variables.dart'; import '../../features/account/screens/account_screen.dart'; import '../../features/cart/screens/cart_screen.dart'; import '../../features/home/screens/home_screen.dart'; import '../../providers/user_provider.dart'; class BottomBar extends StatefulWidget { static const String routeName = '/actual-home'; const BottomBar({Key? key}) : super(key: key); @override State<BottomBar> createState() => _BottomBarState(); } class _BottomBarState extends State<BottomBar> { int _page = 0; double bottomBarWidth = 42; double bottomBarBorderWidth = 5; List<Widget> pages = [ const HomeScreen(), const AccountScreen(), const CartScreen(), ]; void updatePage(int page) { setState(() { _page = page; }); } @override Widget build(BuildContext context) { final userCartLen = context.watch<UserProvider>().user.cart.length; return Scaffold( body: pages[_page], bottomNavigationBar: BottomNavigationBar( currentIndex: _page, selectedItemColor: GlobalVariables.selectedNavBarColor, unselectedItemColor: GlobalVariables.unselectedNavBarColor, backgroundColor: GlobalVariables.backgroundColor, iconSize: 28, onTap: updatePage, items: [ // HOME BottomNavigationBarItem( icon: Container( width: bottomBarWidth, decoration: BoxDecoration( border: Border( top: BorderSide( color: _page == 0 ? GlobalVariables.selectedNavBarColor : GlobalVariables.backgroundColor, width: bottomBarBorderWidth, ), ), ), child: const Icon( Icons.home_outlined, ), ), label: '', ), // ACCOUNT BottomNavigationBarItem( icon: Container( width: bottomBarWidth, decoration: BoxDecoration( border: Border( top: BorderSide( color: _page == 1 ? GlobalVariables.selectedNavBarColor : GlobalVariables.backgroundColor, width: bottomBarBorderWidth, ), ), ), child: const Icon( Icons.person_outline_outlined, ), ), label: '', ), // CART BottomNavigationBarItem( icon: Container( width: bottomBarWidth, decoration: BoxDecoration( border: Border( top: BorderSide( color: _page == 2 ? GlobalVariables.selectedNavBarColor : GlobalVariables.backgroundColor, width: bottomBarBorderWidth, ), ), ), child: Badge( // elevation: 0, label: Text(userCartLen.toString()), // badgeColor: Colors.white, child: const Icon( Icons.shopping_cart_outlined, ), ), ), label: '', ), ], ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common/widgets/loader.dart
import 'package:flutter/material.dart'; class Loader extends StatelessWidget { const Loader({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Center( child: CircularProgressIndicator(), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common/widgets/custom_textfield.dart
import 'package:flutter/material.dart'; class CustomTextField extends StatelessWidget { final TextEditingController controller; final String hintText; final int maxLines; const CustomTextField({ Key? key, required this.controller, required this.hintText, this.maxLines = 1, }) : super(key: key); @override Widget build(BuildContext context) { return TextFormField( controller: controller, decoration: InputDecoration( hintText: hintText, border: const OutlineInputBorder( borderSide: BorderSide( color: Colors.black38, )), enabledBorder: const OutlineInputBorder( borderSide: BorderSide( color: Colors.black38, ))), validator: (val) { if (val == null || val.isEmpty) { return 'Enter your $hintText'; } return null; }, maxLines: maxLines, ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/common/widgets/stars.dart
import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import '../../constants/global_variables.dart'; class Stars extends StatelessWidget { final double rating; const Stars({ Key? key, required this.rating, }) : super(key: key); @override Widget build(BuildContext context) { return RatingBarIndicator( direction: Axis.horizontal, itemCount: 5, rating: rating, itemSize: 15, itemBuilder: (context, _) => const Icon( Icons.star, color: GlobalVariables.secondaryColor, ), ); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App/lib
mirrored_repositories/Cloud-Based-E-Commerce-App/lib/providers/user_provider.dart
import 'package:amazon_clone/models/user.dart'; import 'package:flutter/material.dart'; class UserProvider extends ChangeNotifier { User _user = User( id: '', name: '', email: '', password: '', address: '', type: '', token: '', cart: [], ); User get user => _user; void setUser(String user) { _user = User.fromJson(user); notifyListeners(); } void setUserFromModel(User user) { _user = user; notifyListeners(); } }
0
mirrored_repositories/Cloud-Based-E-Commerce-App
mirrored_repositories/Cloud-Based-E-Commerce-App/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:amazon_clone/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/gomeet
mirrored_repositories/gomeet/lib/main.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:gomeet/screens/HomePage.dart'; import 'package:gomeet/screens/IntroAuthScreen.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: NavigationPage(), ); } } class NavigationPage extends StatefulWidget { NavigationPage({Key key}) : super(key: key); @override _NavigationPageState createState() => _NavigationPageState(); } class _NavigationPageState extends State<NavigationPage> { bool isSigned = false; @override void initState() { super.initState(); FirebaseAuth.instance.authStateChanges().listen((user) { if (user != null) { setState(() { isSigned = true; }); } else { setState(() { isSigned = false; }); } }); } @override Widget build(BuildContext context) { return Scaffold( body: isSigned == false ? IntroAuthScreen() : HomePage(), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/videoconf/CreateMeeting.dart
import 'package:flutter/material.dart'; import 'package:flutter_gradient_colors/flutter_gradient_colors.dart'; import 'package:gomeet/utlis/constant.dart'; import 'package:uuid/uuid.dart'; class CreateMeeting extends StatefulWidget { CreateMeeting({Key key}) : super(key: key); @override _CreateMeetingState createState() => _CreateMeetingState(); } class _CreateMeetingState extends State<CreateMeeting> { String code = ''; createcode() { setState(() { code = Uuid().v1().substring(0, 6); }); } @override Widget build(BuildContext context) { return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.only(top: 20), child: Text( "Create Meeting Room to share with your Friends", style: myStyle(20), textAlign: TextAlign.center, ), ), SizedBox( height: 40, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( "Room: ", style: myStyle(30), ), Text( code, style: myStyle(30, Colors.purple, FontWeight.w700), ), ], ), SizedBox( height: 25, ), InkWell( onTap: () => createcode(), child: Container( width: MediaQuery.of(context).size.width / 2, height: 50, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.facebookMessenger)), child: Center( child: Text( "Create Room", style: myStyle(20, Colors.white), ), ), ), ) ], ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/videoconf/JoinMeeting.dart
import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gradient_colors/flutter_gradient_colors.dart'; import 'package:gomeet/utlis/constant.dart'; import 'package:jitsi_meet/feature_flag/feature_flag.dart'; import 'package:jitsi_meet/jitsi_meet.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; class JoinMeeting extends StatefulWidget { JoinMeeting({Key key}) : super(key: key); @override _JoinMeetingState createState() => _JoinMeetingState(); } class _JoinMeetingState extends State<JoinMeeting> { TextEditingController namecontroller = TextEditingController(); TextEditingController roomcontroller = TextEditingController(); bool isVideoMuted = true; bool isAudioMuted = true; String username = ''; @override void initState() { super.initState(); getuserdata(); } getuserdata() async { DocumentSnapshot userdoc = await usercollection.doc(FirebaseAuth.instance.currentUser.uid).get(); setState(() { username = userdoc.data()['username']; }); } joinmeeting() async { try { FeatureFlag featureFlag = FeatureFlag(); featureFlag.welcomePageEnabled = false; // Here is an example, disabling features for each platform if (Platform.isAndroid) { // Disable ConnectionService usage on Android to avoid issues (see README) featureFlag.callIntegrationEnabled = false; } else if (Platform.isIOS) { // Disable PIP on iOS as it looks weird featureFlag.pipEnabled = false; } var options = JitsiMeetingOptions() ..room = roomcontroller.text ..userDisplayName = namecontroller.text == '' ? username : namecontroller.text ..audioMuted = isAudioMuted ..videoMuted = isVideoMuted ..featureFlag = featureFlag; await JitsiMeet.joinMeeting(options); } catch (e) { print("Error: $e"); } } @override Widget build(BuildContext context) { return Scaffold( body: Container( padding: EdgeInsets.symmetric(horizontal: 16), child: SingleChildScrollView( child: Column( children: [ SizedBox( height: 24, ), Text( "Room Code", style: myStyle(20), ), SizedBox( height: 20, ), PinCodeTextField( controller: roomcontroller, appContext: context, autoDisposeControllers: false, animationType: AnimationType.fade, pinTheme: PinTheme(shape: PinCodeFieldShape.underline), animationDuration: Duration(milliseconds: 300), length: 6, onChanged: (value) {}, ), SizedBox( height: 10, ), TextField( style: myStyle(20), controller: namecontroller, decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Your Name (Optional)", labelStyle: myStyle(15), ), ), SizedBox( height: 16, ), CheckboxListTile( value: isVideoMuted, onChanged: (value) { setState(() { isVideoMuted = value; }); }, title: Text( "Video Muted", style: myStyle(18, Colors.black), ), ), SizedBox( height: 16, ), CheckboxListTile( value: isAudioMuted, onChanged: (value) { setState(() { isAudioMuted = value; }); }, title: Text( "Audio Muted", style: myStyle(18, Colors.black), ), ), SizedBox( height: 20, ), Text("You will be able to change your setting on meeting page.", style: myStyle(15), textAlign: TextAlign.center), Divider( height: 48, thickness: 2.0, ), InkWell( onTap: () => joinmeeting(), child: Container( width: double.maxFinite, height: 64, decoration: BoxDecoration( gradient: LinearGradient( colors: GradientColors.facebookMessenger)), child: Center( child: Text( "Join Meeting", style: myStyle(20, Colors.white), ), ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/auth/NavAuthScreen.dart
import 'package:flutter/material.dart'; import 'package:flutter_gradient_colors/flutter_gradient_colors.dart'; import 'package:gomeet/utlis/constant.dart'; import 'LoginScreen.dart'; import 'RegisterScreen.dart'; class NavigateAuthScreen extends StatefulWidget { NavigateAuthScreen({Key key}) : super(key: key); @override _NavigateAuthScreenState createState() => _NavigateAuthScreenState(); } class _NavigateAuthScreenState extends State<NavigateAuthScreen> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[250], body: Stack( children: [ Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height / 2, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.blue)), child: Center( child: Image.asset( 'assets/images/logo.png', height: 150, ), ), ), Align( alignment: Alignment.bottomCenter, child: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height / 1.6, margin: EdgeInsets.only(left: 30, right: 30), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.green.withOpacity(0.5), spreadRadius: 5, blurRadius: 5, offset: const Offset(0, 3), ) ], color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (context) => LoginScreen(), ), ), child: Container( width: MediaQuery.of(context).size.width / 2, height: 60, decoration: BoxDecoration( gradient: LinearGradient( colors: GradientColors.beautifulGreen), borderRadius: BorderRadius.circular(20), ), child: Center( child: Text( "SIGN IN", style: myStyle(30, Colors.white), ), ), ), ), SizedBox( height: 40, ), InkWell( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (context) => RegisterScreen(), ), ), child: Container( width: MediaQuery.of(context).size.width / 2, height: 60, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.orangePink), borderRadius: BorderRadius.circular(20), ), child: Center( child: Text( "SIGN UP", style: myStyle(30, Colors.white), ), ), ), ), ], ), ), ) ], ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/auth/RegisterScreen.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gradient_colors/flutter_gradient_colors.dart'; import 'package:gomeet/utlis/constant.dart'; class RegisterScreen extends StatefulWidget { RegisterScreen({Key key}) : super(key: key); @override _RegisterScreenState createState() => _RegisterScreenState(); } class _RegisterScreenState extends State<RegisterScreen> { TextEditingController emailcontroller = TextEditingController(); TextEditingController passwordcontroller = TextEditingController(); TextEditingController usernamecontroller = TextEditingController(); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[250], body: Stack( children: [ Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height / 2, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.blue)), child: Center( child: Image.asset( 'assets/images/logo.png', height: 150, ), ), ), Align( alignment: Alignment.bottomCenter, child: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height / 1.6, margin: EdgeInsets.only(left: 30, right: 30), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.green.withOpacity(0.5), spreadRadius: 5, blurRadius: 5, offset: const Offset(0, 3), ) ], color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 50, ), Container( width: MediaQuery.of(context).size.width / 1.7, child: TextField( style: myStyle(18, Colors.black), keyboardType: TextInputType.emailAddress, controller: emailcontroller, decoration: InputDecoration( hintText: "Your Email", prefixIcon: Icon(Icons.email), hintStyle: myStyle(20, Colors.grey, FontWeight.w700), ), ), ), SizedBox( height: 20, ), Container( width: MediaQuery.of(context).size.width / 1.7, child: TextField( style: myStyle(18, Colors.black), controller: passwordcontroller, decoration: InputDecoration( hintText: "Password", prefixIcon: Icon(Icons.lock), hintStyle: myStyle(20, Colors.grey, FontWeight.w700), ), ), ), SizedBox( height: 20, ), Container( width: MediaQuery.of(context).size.width / 1.7, child: TextField( style: myStyle(18, Colors.black), keyboardType: TextInputType.emailAddress, controller: usernamecontroller, decoration: InputDecoration( hintText: "Your Name", prefixIcon: Icon(Icons.person), hintStyle: myStyle(20, Colors.grey, FontWeight.w700), ), ), ), SizedBox( height: 40, ), InkWell( onTap: () { try { FirebaseAuth.instance .createUserWithEmailAndPassword( email: emailcontroller.text, password: passwordcontroller.text) .then((signeduser) { usercollection.doc(signeduser.user.uid).set({ 'username': usernamecontroller.text, 'email': emailcontroller.text, 'password': passwordcontroller.text, 'uid': signeduser.user.uid, }); }); Navigator.pop(context); } catch (e) { print(e); var snackbar = SnackBar( content: Text( e.toString(), style: myStyle(20), ), ); Scaffold.of(context).showSnackBar(snackbar); } }, child: Container( width: MediaQuery.of(context).size.width / 2, height: 45, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.orangePink), borderRadius: BorderRadius.circular(20), ), child: Center( child: Text( "SIGN UP", style: myStyle(20, Colors.white), ), ), ), ), ], ), ), ) ], ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/auth/LoginScreen.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gradient_colors/flutter_gradient_colors.dart'; import 'package:gomeet/utlis/constant.dart'; class LoginScreen extends StatefulWidget { LoginScreen({Key key}) : super(key: key); @override _LoginScreenState createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> { TextEditingController emailcontroller = TextEditingController(); TextEditingController passwordcontroller = TextEditingController(); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[250], body: Stack( children: [ Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height / 2, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.blue)), child: Center( child: Image.asset( 'assets/images/logo.png', height: 150, ), ), ), Align( alignment: Alignment.bottomCenter, child: Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height / 1.6, margin: EdgeInsets.only(left: 30, right: 30), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.green.withOpacity(0.5), spreadRadius: 5, blurRadius: 5, offset: const Offset(0, 3), ) ], color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 50, ), Container( width: MediaQuery.of(context).size.width / 1.7, child: TextField( style: myStyle(18, Colors.black), keyboardType: TextInputType.emailAddress, controller: emailcontroller, decoration: InputDecoration( hintText: "Your Email", prefixIcon: Icon(Icons.email), hintStyle: myStyle(20, Colors.grey, FontWeight.w700), ), ), ), SizedBox( height: 20, ), Container( width: MediaQuery.of(context).size.width / 1.7, child: TextField( style: myStyle(18, Colors.black), controller: passwordcontroller, decoration: InputDecoration( hintText: "Password", prefixIcon: Icon(Icons.lock), hintStyle: myStyle(20, Colors.grey, FontWeight.w700), ), ), ), SizedBox( height: 40, ), InkWell( onTap: () { try { int count = 0; FirebaseAuth.instance.signInWithEmailAndPassword( email: emailcontroller.text, password: passwordcontroller.text); Navigator.popUntil(context, (route) { return count++ == 2; }); } catch (e) { print(e); var snackbar = SnackBar( content: Text( e.toString(), style: myStyle(20), ), ); Scaffold.of(context).showSnackBar(snackbar); } }, child: Container( width: MediaQuery.of(context).size.width / 2, height: 45, decoration: BoxDecoration( gradient: LinearGradient( colors: GradientColors.beautifulGreen), borderRadius: BorderRadius.circular(20), ), child: Center( child: Text( "SIGN IN", style: myStyle(20, Colors.white), ), ), ), ), ], ), ), ) ], ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/screens/ProfileScreen.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_custom_clippers/flutter_custom_clippers.dart'; import 'package:flutter_gradient_colors/flutter_gradient_colors.dart'; import 'package:gomeet/utlis/constant.dart'; class ProfileScreen extends StatefulWidget { ProfileScreen({Key key}) : super(key: key); @override _ProfileScreenState createState() => _ProfileScreenState(); } class _ProfileScreenState extends State<ProfileScreen> { String username = ''; bool dataisthere = false; TextEditingController usernamecontroller = TextEditingController(); @override void initState() { super.initState(); getuserdata(); } getuserdata() async { DocumentSnapshot userdoc = await usercollection.doc(FirebaseAuth.instance.currentUser.uid).get(); setState(() { username = userdoc.data()['username']; dataisthere = true; }); } editprofile() async { usercollection .doc(FirebaseAuth.instance.currentUser.uid) .update({'username': usernamecontroller.text}); setState(() { username = usernamecontroller.text; }); Navigator.pop(context); } openeditprofilebox() async { return showDialog( context: context, builder: (context) { return Dialog( child: Container( height: 200, child: Column( children: [ SizedBox( height: 30, ), Container( margin: EdgeInsets.only(left: 30, right: 30), child: TextField( controller: usernamecontroller, style: myStyle(18, Colors.black), decoration: InputDecoration( labelText: "Update Your Name", labelStyle: myStyle(16, Colors.grey), ), ), ), SizedBox( height: 40, ), InkWell( onTap: () => editprofile(), child: Container( width: MediaQuery.of(context).size.width / 2, height: 40, decoration: BoxDecoration( gradient: LinearGradient(colors: GradientColors.cherry)), child: Center( child: Text( "Update Now", style: myStyle(17, Colors.white), ), ), ), ) ], ), ), ); }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[250], body: dataisthere == false ? Center( child: CircularProgressIndicator(), ) : Stack( children: [ ClipPath( clipper: OvalBottomBorderClipper(), child: Container( width: double.infinity, height: MediaQuery.of(context).size.height / 2.5, decoration: BoxDecoration( gradient: LinearGradient( colors: GradientColors.facebookMessenger)), ), ), Container( margin: EdgeInsets.only( left: MediaQuery.of(context).size.width / 2 - 64, top: MediaQuery.of(context).size.height / 3.1, ), child: CircleAvatar( radius: 64, backgroundImage: NetworkImage( 'https://thumbs.dreamstime.com/b/creative-illustration-default-avatar-profile-placeholder-isolated-background-art-design-grey-photo-blank-template-mockup-144849704.jpg'), ), ), Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: 300, ), Text( username, style: myStyle(40, Colors.black), textAlign: TextAlign.center, ), SizedBox( height: 30, ), InkWell( onTap: () => openeditprofilebox(), child: Container( width: MediaQuery.of(context).size.width / 2, height: 40, decoration: BoxDecoration( gradient: LinearGradient( colors: GradientColors.cherry)), child: Center( child: Text( "Edit Profile", style: myStyle(17, Colors.white), ), ), ), ) ], ), ) ], ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/screens/VideoConferenceScreen.dart
import 'package:flutter/material.dart'; import 'package:gomeet/utlis/constant.dart'; import 'package:gomeet/videoconf/CreateMeeting.dart'; import 'package:gomeet/videoconf/JoinMeeting.dart'; class VideoConferenceScreen extends StatefulWidget { VideoConferenceScreen({Key key}) : super(key: key); @override _VideoConferenceScreenState createState() => _VideoConferenceScreenState(); } class _VideoConferenceScreenState extends State<VideoConferenceScreen> with SingleTickerProviderStateMixin { TabController tabController; buildtab(String name) { return Container( width: 150, height: 50, child: Card( child: Center( child: Text( name, style: myStyle(16, Colors.black, FontWeight.w700), ), ), ), ); } @override void initState() { super.initState(); tabController = TabController(length: 2, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, backgroundColor: Colors.lightBlue, title: Text( "GoMeet", style: myStyle(20, Colors.white, FontWeight.w700), ), bottom: TabBar( controller: tabController, tabs: [buildtab("Join Room"), buildtab("Create Room")], ), ), body: TabBarView( controller: tabController, children: [JoinMeeting(), CreateMeeting()], ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/screens/HomePage.dart
import 'package:flutter/material.dart'; import 'package:gomeet/utlis/constant.dart'; import 'ProfileScreen.dart'; import 'VideoConferenceScreen.dart'; class HomePage extends StatefulWidget { HomePage({Key key}) : super(key: key); @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { int page = 0; List pageoptions = [VideoConferenceScreen(), ProfileScreen()]; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[300], bottomNavigationBar: BottomNavigationBar( backgroundColor: Colors.white, selectedItemColor: Colors.blue, selectedLabelStyle: myStyle(17, Colors.blue), unselectedItemColor: Colors.black, unselectedLabelStyle: myStyle(17, Colors.black), currentIndex: page, onTap: (index) { setState(() { page = index; }); }, items: [ BottomNavigationBarItem( label: 'Video Call', icon: Icon( Icons.video_call, size: 32, ), ), BottomNavigationBarItem( label: 'Profile', icon: Icon( Icons.person, size: 32, ), ), ], ), body: pageoptions[page], ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/screens/IntroAuthScreen.dart
import 'package:flutter/material.dart'; import 'package:gomeet/auth/NavAuthScreen.dart'; import 'package:gomeet/utlis/constant.dart'; import 'package:introduction_screen/introduction_screen.dart'; class IntroAuthScreen extends StatelessWidget { const IntroAuthScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { return IntroductionScreen( pages: [ PageViewModel( title: "Welcome to GoMeet", body: "One consistent enterprise experience for all use cases", image: Center( child: Image.asset('assets/images/welcome.png', height: 175), ), decoration: PageDecoration( bodyTextStyle: myStyle(20, Colors.black), titleTextStyle: myStyle(20, Colors.black)), ), PageViewModel( title: "Meetings & Chat", body: "Online Meetings, Training & Technical Support", image: Center( child: Image.asset('assets/images/secure.png', height: 175), ), decoration: PageDecoration( bodyTextStyle: myStyle(20, Colors.black), titleTextStyle: myStyle(20, Colors.black)), ), PageViewModel( title: "Video Webinar", body: "Marketing Events & Town Hall Meetings", image: Center( child: Image.asset('assets/images/conference.png', height: 175), ), decoration: PageDecoration( bodyTextStyle: myStyle(20, Colors.black), titleTextStyle: myStyle(20, Colors.black)), ), ], onDone: () { Navigator.push(context, MaterialPageRoute(builder: (context) => NavigateAuthScreen())); }, onSkip: () {}, showNextButton: true, skip: const Icon(Icons.skip_next, size: 45), next: const Icon(Icons.arrow_forward_ios), done: Text( "Done", style: myStyle(20, Colors.black), ), ); } }
0
mirrored_repositories/gomeet/lib
mirrored_repositories/gomeet/lib/utlis/constant.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; TextStyle myStyle(double size, [Color color, FontWeight fw = FontWeight.w700]) { return GoogleFonts.montserrat(fontSize: size, color: color, fontWeight: fw); } CollectionReference usercollection = FirebaseFirestore.instance.collection('users');
0
mirrored_repositories/gomeet
mirrored_repositories/gomeet/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:gomeet/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Abrakadabar-Flutter
mirrored_repositories/Abrakadabar-Flutter/lib/main.dart
import 'package:abrakadabar/helper/Auth.dart'; import 'package:abrakadabar/screen/ForgotPasswordScreen.dart'; import 'package:abrakadabar/screen/ProfilPengembangMedia.dart'; import 'package:abrakadabar/screen/daftar/DaftarGuruAdminScreen.dart'; import 'package:abrakadabar/screen/daftar/DaftarGuruAdminUnScreen.dart'; import 'package:abrakadabar/screen/daftar/DaftarGuruScreen.dart'; import 'package:abrakadabar/screen/game/GameTigaScreen.dart'; import 'package:abrakadabar/screen/game/ModeGameScreen.dart'; import 'package:abrakadabar/screen/guru/PetunjukPengisianScreen.dart'; import 'package:abrakadabar/screen/siswa/AturanPermainanScreen.dart'; import 'package:abrakadabar/screen/siswa/DaftarSkorSiswaScreen.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'screen/WelcomeScreen.dart'; import 'screen/HomeScreen.dart'; import 'screen/RegisterScreen.dart'; import 'screen/LoginScreen.dart'; import 'screen/ForgotPasswordScreen.dart'; import 'screen/DetailScreen.dart'; import 'screen/daftar/DaftarSiswaScreen.dart'; import 'screen/materi/AddMateriScreen.dart'; import 'screen/materi/SoalGambarScreen.dart'; import 'screen/materi/ModeScreen.dart'; import 'helper/Auth.dart'; import 'screen/materi/listmode/ListSoalScreen.dart'; void main() { runApp(ChangeNotifierProvider( create: (_) => Auth(), child: MaterialApp( home: WelcomeScreen(), routes: { '/home': (context) => HomeScreen(), '/register': (context) => RegisterScreen(), '/login': (context) => LoginScreen(), '/forgotpassword': (context) => ForgotPasswordScreen(), '/detail': (context) => DetailScreen(), '/addMatery': (context) => AddMateriScreen(title: 'Pengisian Materi'), '/soalGambar': (context) => SoalGambarScreen(num: 1), '/modeList': (context) => ModeScreen(), '/soalAll': (context) => ListSoalScreen(), '/daftarGuru': (context) => DaftarGuruScreen(status: 'Guru'), '/daftarGuruAdmin': (context) => DaftarGuruAdminScreen(status: 'Guru'), '/daftarGuruAdminUn': (context) => DaftarGuruAdminUnScreen(status: 'Guru'), '/daftarSkorSiswa': (context) => DaftarSkorSiswaScreen(status: 'Siswa'), '/daftarSiswaAdmin': (context) => DaftarGuruAdminScreen(status: 'Siswa'), '/daftarSiswa': (context) => DaftarSiswaScreen(status: 'Siswa'), '/profilPengembang': (context) => ProfilPengembangMediaScreen(), '/petunjukGuru': (context) => PetunjukPengisianScreen(), '/modeGame': (context) => ModeGameScreen(), '/gameTiga': (context) => GameTigaScreen(), '/petunjukSiswa': (context) => AturanPermainanScreen(), }, theme: ThemeData( fontFamily: 'Spartan', primaryColor: Color.fromRGBO(29, 172, 234, 1)), ))); }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/model/User.dart
class Users { late List<User> users; Users({required this.users}); factory Users.fromJson(json) { var list = List.generate(json.toList().length, (i) => User.fromJson(json[i])); return Users(users: list); } } class User { int ide; String fullName; String username; String callName; String tempatLahir; String tanggalLahir; String jenisKelamin; String status; String detail; String cek; User( {required this.ide, required this.fullName, required this.username, required this.callName, required this.tempatLahir, required this.tanggalLahir, required this.jenisKelamin, required this.status, required this.detail, required this.cek}); factory User.fromJson(json) { return User( ide: json['id'], username: json['username'].toString(), fullName: json['name'].toString(), callName: json['call_name'].toString(), tempatLahir: json['tempat_lahir'].toString(), tanggalLahir: json['tanggal_lahir'].toString(), jenisKelamin: json['jenis_kelamin'].toString(), status: json['status'].toString(), detail: json['detail'].toString(), cek: json['cek'].toString(), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/model/NilaiUser.dart
class NilaisUser { late List<NilaiUser> nilaiuser; NilaisUser({required this.nilaiuser}); factory NilaisUser.fromJson(json) { var list = List.generate(json.toList().length, (i) { return NilaiUser.fromJson(json[i]); }); return NilaisUser(nilaiuser: list); } } class NilaiUser { int? id; int? score; String? materi; NilaiUser({this.id, this.score, this.materi}); factory NilaiUser.fromJson(json) { return NilaiUser( id: json['id'], score: json['nilai'], materi: json['materi']['title'], ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/model/AllMateri.dart
class AllMateri { late List<Materis> allmateri; AllMateri({required this.allmateri}); factory AllMateri.fromJson(json) { var list = List.generate(json['data'].toList().length, (i) { return Materis.fromJson(json['data'][i]); }); return AllMateri(allmateri: list); } } class Materis { int? id; String? title; String? link_image; String? kesulitan; String? sinopsis; String? publish; late List<Nilai> nilai; Materis( {this.id, this.title, this.link_image, this.kesulitan, this.sinopsis, this.publish, required this.nilai}); factory Materis.fromJson(json) { var list = List.generate(1, (i) { return Nilai.fromJson(json['nilai'][i]); }); return Materis( id: json['id'], title: json['title'], link_image: json['link_image'], kesulitan: json['kesulitan'], sinopsis: json['sinopsis'], publish: json['publish'], nilai: list, ); } } class Nilai { int? id; int? score; List? materi; Nilai({this.id, this.score, this.materi}); factory Nilai.fromJson(json) { if (json == null) { return Nilai( id: 0, score: 102, ); } else { return Nilai( id: json['id'], score: json['nilai'], ); } } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/model/Materi.dart
class Materi { int id; String title; String link_image; String kesulitan; String sinopsis; List soal; Materi( {required this.id, required this.title, required this.link_image, required this.kesulitan, required this.sinopsis, required this.soal}); factory Materi.input(data) { return Materi( id: data[0]['id'], title: data[0]['title'].toString(), link_image: data[0]['link_image'].toString(), kesulitan: data[0]['kesulitan'].toString(), sinopsis: data[0]['sinopsis'].toString(), soal: data[1]); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/model/Soals.dart
class Soals { late List<Soal> soals; Soals({required this.soals}); factory Soals.fromJson(json) { var list = List.generate(json.toList().length, (i) => Soal.fromJson(json[i])); return Soals(soals: list); } } class Soal { int? id; int? materi_id; String? link_image; String? keyword; String? petunjuk; Soal({this.id, this.materi_id, this.link_image, this.keyword, this.petunjuk}); factory Soal.fromJson(json) { return Soal( id: json['id'], materi_id: json['materi_id'], link_image: json['link_image'], keyword: json['keyword'], petunjuk: json['petunjuk'], ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/API/MateriApi.dart
import 'dart:convert'; import 'package:abrakadabar/helper/dio.dart'; import 'package:abrakadabar/model/Materi.dart'; import 'package:abrakadabar/model/NilaiUser.dart'; import 'package:abrakadabar/model/Soals.dart'; import 'package:abrakadabar/model/User.dart'; import 'package:dio/dio.dart' as Dio; import 'package:abrakadabar/helper/Storage.dart'; import 'package:flutter/material.dart'; import 'package:abrakadabar/model/AllMateri.dart'; class MateriAPI extends ChangeNotifier { Future<AllMateri> fetchAll(credentials) async { final token = await Storage().readToken(); final res = await dio().post('materi/all', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { // print(res.data); return AllMateri.fromJson(res.data); } else { AllMateri list = AllMateri(allmateri: []); return list; } } Future<NilaisUser> fetchNilai(credentials) async { final token = await Storage().readToken(); final res = await dio().post('nilai', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return NilaisUser.fromJson(res.data); } else { NilaisUser list = NilaisUser(nilaiuser: []); return list; } } Future<Soals> fetchAllSoal(credentials) async { final token = await Storage().readToken(); final res = await dio().post('soal/all', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return Soals.fromJson(json.decode(res.data.toString())); } else { Soals list = Soals(soals: []); return list; } } Future<Users> fetchAllUsers(credentials) async { final token = await Storage().readToken(); final res = await dio().post('users', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return Users.fromJson(json.decode(res.data.toString())); } else { Users list = Users(users: []); return list; } } Future<Materi> fetchMateri(credentials) async { final token = await Storage().readToken(); final res = await dio().post('materi', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); return Materi.input(res.data); } Future<Soal> fetchSoal(credentials) async { final token = await Storage().readToken(); final res = await dio().post('soal', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); return Soal.fromJson(res.data); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/GuestDrawer.dart
import 'package:flutter/material.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:provider/provider.dart'; import 'package:abrakadabar/helper/Auth.dart'; class GuestDrawer extends StatefulWidget { @override _GuestDrawerState createState() => _GuestDrawerState(); } class _GuestDrawerState extends State<GuestDrawer> { Future submitLogout(context) async { // final response = context.read<Auth>().user; final res = await Provider.of<Auth>(context, listen: false).requestLogout(); if (res['status'] == true) { Navigator.pushNamed(context, '/login'); } } @override Widget build(BuildContext context) { return Drawer( child: Container( margin: EdgeInsets.only(top: 50), child: Column( children: [ ListTile( title: Text('Home'), onTap: () { Navigator.pushNamed(context, '/home'); }, ), AnimatedButton( text: "Keluar dari Akun", color: Colors.transparent, borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16, color: Colors.red), pressEvent: () { AwesomeDialog( context: context, dialogType: DialogType.WARNING, headerAnimationLoop: false, animType: AnimType.TOPSLIDE, showCloseIcon: false, closeIcon: Icon(Icons.close_fullscreen_outlined), title: 'Keluar dari Akun', desc: 'Apakah kamu yakin mau keluar dari Akun ini?', btnCancelOnPress: () { Navigator.pop(context); }, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }, btnOkOnPress: () { submitLogout(context); }) ..show(); }, ), SizedBox( height: 16, ), ], ), ), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/AppDrawer.dart
import 'package:flutter/material.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:provider/provider.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'daftar/DaftarGuruScreen.dart'; import 'daftar/DaftarSiswaScreen.dart'; class AppDrawer extends StatefulWidget { @override _AppDrawerState createState() => _AppDrawerState(); } class _AppDrawerState extends State<AppDrawer> { Future submitLogout(context) async { final res = await Provider.of<Auth>(context, listen: false).requestLogout(); if (res['status'] == true) { Navigator.pushNamed(context, '/login'); } } AnimatedButton logout() { return AnimatedButton( text: "Keluar dari Akun", color: Colors.transparent, borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16, color: Colors.red), pressEvent: () { AwesomeDialog( context: context, dialogType: DialogType.WARNING, headerAnimationLoop: false, animType: AnimType.TOPSLIDE, showCloseIcon: false, closeIcon: Icon(Icons.close_fullscreen_outlined), title: 'Keluar dari Akun', desc: 'Apakah kamu yakin mau keluar dari Akun ini?', btnCancelOnPress: () { Navigator.pop(context); }, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }, btnOkOnPress: () { submitLogout(context); }) ..show(); }, ); } Column menu(title, route) { return Column( children: [ ListTile( title: Text(title), onTap: () { Navigator.pushNamed(context, route); }, ), Container( height: 1, color: Colors.grey, margin: EdgeInsets.fromLTRB(15, 0, 15, 0), ), ], ); } var Guru = MaterialPageRoute( builder: (BuildContext context) => DaftarGuruScreen(status: 'Guru')); var Siswa = MaterialPageRoute( builder: (BuildContext context) => DaftarSiswaScreen(status: 'Siswa')); @override Widget build(BuildContext context) { var res = context.read<Auth>().user; var draw; if (res.status == "Guru") { draw = Drawer( child: Container( margin: EdgeInsets.only(top: 50), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.fromLTRB(0, 0, 0, 10), child: Column( children: [ Text("${res.fullName} - ${res.callName}"), Text( "Username : ${res.username}", style: TextStyle(fontSize: 12), textAlign: TextAlign.start, ), ], )), Container( height: 1, color: Colors.grey, margin: EdgeInsets.fromLTRB(50, 0, 50, 0), ), Container( margin: EdgeInsets.all(10), child: Text( res.status.toString(), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), ), ), menu('Beranda', '/home'), Column( children: [ ListTile( title: Text("Daftar Guru"), onTap: () { Navigator.pop(context); Navigator.of(context).push(Guru); }, ), Container( height: 1, color: Colors.grey, margin: EdgeInsets.fromLTRB(15, 0, 15, 0), ), ], ), Column( children: [ ListTile( title: Text("Daftar Siswa"), onTap: () { Navigator.pop(context); Navigator.of(context).push(Siswa); }, ), Container( height: 1, color: Colors.grey, margin: EdgeInsets.fromLTRB(15, 0, 15, 0), ), ], ), menu('Daftar Cerita', '/modeList'), menu('Profil Pengembang Media', '/profilPengembang'), logout(), SizedBox( height: 16, ), ], ), ), ); } else if (res.status == "Siswa") { draw = Drawer( child: Container( margin: EdgeInsets.only(top: 50), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.fromLTRB(0, 0, 0, 10), child: Column( children: [ Text("${res.fullName} - ${res.callName}"), Text( "Username : ${res.username}", style: TextStyle(fontSize: 12), textAlign: TextAlign.start, ), ], )), Container( height: 1, color: Colors.grey, margin: EdgeInsets.fromLTRB(50, 0, 50, 0), ), Container( margin: EdgeInsets.all(10), child: Text( res.status.toString(), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), ), ), menu('Beranda', '/home'), menu('Aturan Permainan', '/petunjukSiswa'), menu('Profil Pengembang Media', '/profilPengembang'), logout(), SizedBox( height: 16, ), ], ), ), ); } return draw; } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/RegisterScreen.dart
import 'package:flutter/material.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:provider/provider.dart'; class RegisterScreen extends StatefulWidget { @override _RegisterScreenState createState() => _RegisterScreenState(); } class _RegisterScreenState extends State<RegisterScreen> { final _nameCtrl = TextEditingController(); final _usernameCtrl = TextEditingController(); final _passwordCtrl = TextEditingController(); final _passwordConfirmCtrl = TextEditingController(); final _formKeySiswa = GlobalKey<FormState>(); final _formKeyGuru = GlobalKey<FormState>(); bool _hasError = false; String _errorMsg = ""; @override void dispose() { _nameCtrl.dispose(); _usernameCtrl.dispose(); _passwordCtrl.dispose(); _passwordConfirmCtrl.dispose(); super.dispose(); } TextFormField formInput(controller, label, hidden) { return TextFormField( controller: controller, obscureText: hidden, decoration: InputDecoration( border: OutlineInputBorder(), labelText: label, labelStyle: TextStyle(fontSize: 16), ), ); } Future submitRegisterMurid(BuildContext context) async { String _status = "2"; var result = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestRegister({ 'name': _nameCtrl.text, 'username': _usernameCtrl.text, 'password': _passwordCtrl.text, 'password_confirmation': _passwordConfirmCtrl.text, 'status': _status }))); if (result['status'] == true) { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Mendaftar", btnOkOnPress: () { Navigator.pushNamed(context, '/login'); debugPrint('OnClcik'); }, headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else { setState(() { _errorMsg = result['error_msg']; _hasError = true; }); } } Future submitRegisterGuru(BuildContext context) async { String _status = "1"; var result = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestRegister({ 'name': _nameCtrl.text, 'username': _usernameCtrl.text, 'password': _passwordCtrl.text, 'password_confirmation': _passwordConfirmCtrl.text, 'status': _status }))); if (result['status'] == true) { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Mendaftar", btnOkOnPress: () { Navigator.pushNamed(context, '/login'); debugPrint('OnClcik'); }, headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else { setState(() { _errorMsg = result['error_msg']; _hasError = true; }); } } @override Widget build(BuildContext context) { var isLoggedIn = context.watch<Auth>().isAuthenticated; if (!isLoggedIn) { return MaterialApp( home: DefaultTabController( length: 2, child: Scaffold( appBar: AppBar( title: Container( child: Image.asset( 'images/logo.png', width: 150, height: 150, ), ), centerTitle: true, toolbarHeight: 200, bottom: TabBar( tabs: [ Tab( child: Text("SISWA"), ), Tab( child: Text("GURU"), ) ], ), ), body: TabBarView( children: [ ListView( children: [ Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 5), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text("Daftar Sebagai")], ), ), Text( "SISWA", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), textAlign: TextAlign.center, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), child: Column( children: [ Form( key: _formKeySiswa, child: Column( children: [ formInput(_nameCtrl, "Nama Lengkap", false), Container(height: 10), formInput(_usernameCtrl, "Username", false), Container(height: 10), formInput(_passwordCtrl, "Kata Sandi", true), Container(height: 10), formInput(_passwordConfirmCtrl, "Ulangi Kata Sandi", true), Container(height: 10), Visibility( visible: _hasError, child: Column( children: [ Text("$_errorMsg", style: TextStyle(color: Colors.red)), ], ) ), Container(height: 10), Container( child: Column( children: [ AnimatedButton( text: 'Daftar', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16), pressEvent: () { submitRegisterMurid(context); }, ), SizedBox( height: 12, ), ], ), ), ], ), ) ], )), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 10, 20, 10), child: Row( children: [ Text("Sudah Punya Akun?"), TextButton( onPressed: () => Navigator.pushNamed(context, '/login'), child: Text("Klik Disini")) ], ), ) ], ), ListView( children: [ Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 5), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text("Daftar Sebagai")], ), ), Text( "GURU", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), textAlign: TextAlign.center, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), child: Column( children: [ Form( key: _formKeyGuru, child: Column( children: [ formInput(_nameCtrl, "Nama Lengkap", false), Container(height: 10), formInput(_usernameCtrl, "Username", false), Container(height: 10), formInput(_passwordCtrl, "Kata Sandi", true), Container(height: 10), formInput(_passwordConfirmCtrl, "Ulangi Kata Sandi", true), Container(height: 10), Visibility( visible: _hasError, child: Column( children: [ Text("$_errorMsg", style: TextStyle(color: Colors.red)), ], )), Container(height: 10), Container( child: Column( children: [ AnimatedButton( text: 'Daftar', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16), pressEvent: () { submitRegisterGuru(context); }, ), SizedBox( height: 12, ), ], ), ), ], ), ) ], )), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 10, 20, 10), child: Row( children: [ Text("Sudah Punya Akun?"), TextButton( onPressed: () => Navigator.pushNamed(context, '/login'), child: Text("Klik Disini")) ], ), ) ], ), ], ), ), ), theme: ThemeData(fontFamily: 'Spartan'), ); } else { Navigator.pushNamed(context, '/home'); return Scaffold(); } } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/WelcomeScreen.dart
import 'dart:async'; import 'package:abrakadabar/model/User.dart'; import 'package:flutter/material.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:provider/provider.dart'; class WelcomeScreen extends StatefulWidget { @override _WelcomeScreenState createState() => _WelcomeScreenState(); } class _WelcomeScreenState extends State<WelcomeScreen> { @override void initState() { super.initState(); checkIsLoggedIn(); } void checkIsLoggedIn() async { await Provider.of<Auth>(context, listen: false).requestCheckMe(); } Future push(BuildContext context, cek, res) { if (cek) { if (res == 'null') { return Navigator.pushNamed(context, '/detail'); } else { return Navigator.pushNamed(context, '/home'); } } else { return Navigator.pushNamed(context, '/login'); } } Future<User> cek() async { return await context.watch<Auth>().user; } @override Widget build(BuildContext context) { var _checkLoggedIn = context.watch<Auth>().isAuthenticated; return Scaffold( backgroundColor: Color.fromRGBO(29, 172, 234, 1), body: FutureBuilder<User>( future: cek(), builder: (context, ss) { if (ss.connectionState == ConnectionState.waiting) { return Container( child: Center( child: CircularProgressIndicator(), ), ); } else { if (ss.hasData) { return Container( child: InkWell( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column(), Column(), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'images/logo.png', width: 200, height: 200, ), ]), Text( 'ABRAKADABAR', style: TextStyle( color: Color.fromRGBO(254, 254, 254, 1), fontSize: 30, fontFamily: 'Handlee'), ), Text('Ayo Belajar Menulis Karangan Dari Gambar', style: TextStyle( color: Color.fromRGBO(254, 254, 254, 1), )), ], ), Column(), Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Text('KLIK LAYAR UNTUK MELANJUTKAN', style: TextStyle(color: Colors.white)), ], ), Column(), ], ), onTap: () { push(context, _checkLoggedIn, ss.data!.detail); }, ), ); } else if (ss.hasError) { return Container( child: InkWell( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column(), Column(), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'images/logo.png', width: 200, height: 200, ), ]), Text( 'ABRAKADABAR', style: TextStyle( color: Color.fromRGBO(254, 254, 254, 1), fontSize: 30, fontFamily: 'Handlee'), ), Text('Ayo Belajar Menulis Karangan Dari Gambar', style: TextStyle( color: Color.fromRGBO(254, 254, 254, 1), )), ], ), Column(), Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Silahkan Masuk Kembali \natau\n Tunggu beberapa saat jika kamu pernah login.', style: TextStyle( color: Colors.white, ), textAlign: TextAlign.center, ), ], ) ], ), Column(), ], ), onTap: () async { await Future.delayed(Duration(seconds: 1)); push(context, _checkLoggedIn, ss.data?.detail); }, ), ); } return Center(child: CircularProgressIndicator()); } }, ), // body: ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/ForgotPasswordScreen.dart
import 'package:flutter/material.dart'; class ForgotPasswordScreen extends StatefulWidget { @override _ForgotPasswordScreenState createState() => _ForgotPasswordScreenState(); } class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Lupa Password"), ), body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column(children: [ Text("Silahkan Menghubungi Admin", style: TextStyle( fontWeight: FontWeight.bold ),), Text("@Admin", style: TextStyle( fontWeight: FontWeight.bold )), ],) ], ) ], ), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/LoginScreen.dart
import 'package:flutter/material.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; import 'package:provider/provider.dart'; class LoginScreen extends StatefulWidget { @override _LoginScreenState createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> { final _usernameCtrl = TextEditingController(); final _passwordCtrl = TextEditingController(); final _formKeySiswa = GlobalKey<FormState>(); final _formKeyGuru = GlobalKey<FormState>(); bool _hasError = false; String _errorMsg = ""; @override void initState() { super.initState(); checkIsLoggedIn(); } void checkIsLoggedIn() async { await Provider.of<Auth>(context, listen: false).requestCheckMe(); } @override void dispose() { _usernameCtrl.dispose(); _passwordCtrl.dispose(); super.dispose(); } TextFormField formInput(controller, label, hidden) { return TextFormField( controller: controller, obscureText: hidden, decoration: InputDecoration( border: OutlineInputBorder(), labelText: label, labelStyle: TextStyle(fontSize: 16), ), ); } Future submitLoginMurid(BuildContext context) async { var result = await showDialog( context: context, builder: (context) => FutureProgressDialog( Provider.of<Auth>(context, listen: false).requestLogin({ 'username': _usernameCtrl.text, 'password': _passwordCtrl.text, }))); if (result['status'] == true) { var res = context.read<Auth>().user; AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Masuk", btnOkOnPress: () { // ignore: unnecessary_null_comparison if (res.detail != null) { Navigator.pushNamed(context, '/home'); } else { Navigator.pushNamed(context, '/detail'); } }, headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Check $type'); }) ..show(); } else { setState(() { _errorMsg = result['error_msg']; _hasError = true; }); } } Future submitLoginGuru(BuildContext context) async { var result = await showDialog( context: context, builder: (context) => FutureProgressDialog( Provider.of<Auth>(context, listen: false).requestLogin({ 'username': _usernameCtrl.text, 'password': _passwordCtrl.text, }))); if (result['status'] == true) { var res = context.read<Auth>().user; AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Masuk", btnOkOnPress: () { // ignore: unnecessary_null_comparison if (res.detail != null && res.detail != '') { Navigator.pushNamed(context, '/home'); } else { Navigator.pushNamed(context, '/detail'); } }, headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Check $type'); }) ..show(); } else { setState(() { _errorMsg = result['error_msg']; _hasError = true; }); } } @override Widget build(BuildContext context) { // check(_checkLoggedIn); return MaterialApp( home: DefaultTabController( length: 2, child: Scaffold( appBar: AppBar( title: Container( child: Image.asset( 'images/logo.png', width: 150, height: 150, ), ), centerTitle: true, toolbarHeight: 200, bottom: TabBar( tabs: [ Tab( child: Text("SISWA"), ), Tab( child: Text("GURU"), ) ], ), ), body: TabBarView( children: [ ListView( children: [ Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 5), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text("Masuk Sebagai")], ), ), Text( "SISWA", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), textAlign: TextAlign.center, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), child: Column( children: [ Form( key: _formKeySiswa, child: Column( children: [ formInput(_usernameCtrl, "Username", false), Container(height: 10), formInput(_passwordCtrl, "Kata Sandi", true), Container(height: 10), Visibility( visible: _hasError, child: Column( children: [ Row( children: [ Text( "$_errorMsg", style: TextStyle(color: Colors.red), textAlign: TextAlign.start, ), ], ) ], )), Container(height: 10), Container( child: Column( children: [ AnimatedButton( text: 'Masuk', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16, ), pressEvent: () { submitLoginMurid(context); }, ), SizedBox( height: 12, ), ], ), ), ], ), ) ], )), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 10, 20, 0), child: Row( children: [ Text("Belum Punya Akun?"), TextButton( onPressed: () => Navigator.pushNamed(context, '/register'), child: Text("Klik Disini")) ], ), ), Container( margin: EdgeInsets.fromLTRB(20, 0, 20, 10), child: Row( children: [ Text("Atau"), TextButton( onPressed: () => Navigator.pushNamed(context, '/forgotpassword'), child: Text("Lupa Password ?")) ], ), ) ], ), ListView( children: [ Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 5), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [Text("Masuk Sebagai")], ), ), Text( "GURU", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22), textAlign: TextAlign.center, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), child: Column( children: [ Form( key: _formKeyGuru, child: Column( children: [ formInput(_usernameCtrl, "Username", false), Container(height: 10), formInput(_passwordCtrl, "Kata Sandi", true), Container(height: 10), Visibility( visible: _hasError, child: Column( children: [ Row( children: [ Text( "$_errorMsg", style: TextStyle(color: Colors.red), textAlign: TextAlign.start, ), ], ) ], )), Container(height: 10), Container( child: Column( children: [ AnimatedButton( text: 'Masuk', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16), pressEvent: () { submitLoginGuru(context); }, ), SizedBox( height: 12, ), ], ), ), ], ), ) ], )), Container( margin: EdgeInsets.fromLTRB(20, 20, 20, 0), height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(20, 10, 20, 0), child: Row( children: [ Text("Belum Punya Akun?"), TextButton( onPressed: () => Navigator.pushNamed(context, '/register'), child: Text("Klik Disini")) ], ), ), Container( margin: EdgeInsets.fromLTRB(20, 0, 20, 10), child: Row( children: [ Text("Atau"), TextButton( onPressed: () => Navigator.pushNamed(context, '/forgotpassword'), child: Text("Lupa Password ?")) ], ), ) ], ), ], ), ), ), theme: ThemeData(fontFamily: 'Spartan'), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/ProfilPengembangMedia.dart
import 'package:abrakadabar/screen/AppDrawer.dart'; import 'package:flutter/material.dart'; class ProfilPengembangMediaScreen extends StatefulWidget { ProfilPengembangMediaScreen({Key? key}) : super(key: key); @override _ProfilPengembangMediaScreenState createState() => _ProfilPengembangMediaScreenState(); } class _ProfilPengembangMediaScreenState extends State<ProfilPengembangMediaScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Profil", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( height: 70, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "PROFIL PENGEMBANG MEDIA", style: TextStyle(fontSize: 18), ), ], ) ], )), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), child: Stack( alignment: Alignment.center, children: [ Container( height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(120, 0, 120, 0), color: Colors.grey[50], child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "DATA", style: TextStyle(fontSize: 10), ), ], )), ], ), ), Container( margin: EdgeInsets.fromLTRB(0, 10, 0, 10), child: Image( image: AssetImage('images/pp.png'), width: 225, )), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), width: 350, child: Column(mainAxisAlignment: MainAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.all(10), child: Text( "NAMA : FANY WAHYU FEBRIYANTI", style: TextStyle(fontSize: 12), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.all(10), child: Text( "TTL : SIDOARJO, 23 FEBRUARI 1999", style: TextStyle(fontSize: 12), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.all(10), child: Text( "USIA : 22 TAHUN", style: TextStyle(fontSize: 12), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.all(10), child: Text( "PEKERJAAN : MAHASISWI, GURU", style: TextStyle(fontSize: 12), ), ), ], ) ]), ) ], ), drawer: AppDrawer(), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/HomeScreen.dart
import 'package:abrakadabar/screen/AppDrawer.dart'; import 'package:abrakadabar/screen/GuestDrawer.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:abrakadabar/helper/Auth.dart'; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { Card listMenu(icon, text, route) { return Card( margin: EdgeInsets.fromLTRB(10, 5, 10, 5), child: ListTile( leading: Icon(icon), title: Container( child: Text( text, textAlign: TextAlign.start, )), onTap: () => Navigator.pushNamed(context, route), )); } void initState() { super.initState(); checkIsLoggedIn(); } void checkIsLoggedIn() async { await Provider.of<Auth>(context, listen: false).requestCheckMe(); } Future submitLogout(context) async { final res = await Provider.of<Auth>(context, listen: false).requestLogout(); if (res['status'] == true) { Navigator.pushNamed(context, '/login'); } } @override Widget build(BuildContext context) { var user, draw; final res = context.read<Auth>().user; if (res.cek == '0' && res.status == "Guru") { user = Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Sebagai Guru \nAnda harus konfirmasi dulu ke Admin", textAlign: TextAlign.center, ), ], ), ], ); draw = GuestDrawer(); } else { if (res.status == "Guru") { user = Column( children: [ Container( height: 70, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "SELAMAT DATANG", style: TextStyle(fontSize: 18), ), ], ) ], )), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), child: Stack( alignment: Alignment.center, children: [ Container( height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(120, 0, 120, 0), color: Colors.grey[50], child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "STATUS", style: TextStyle(fontSize: 10), ), ], )), ], ), ), Container( margin: EdgeInsets.fromLTRB(0, 10, 0, 10), child: Text( res.status.toString(), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), Container( child: listMenu(Icons.manage_accounts_outlined, "Petunjuk Pengisian", '/petunjukGuru'), ), Container( child: listMenu( Icons.score_outlined, "Melihat Skor", '/daftarSkorSiswa'), ), Container( child: listMenu( Icons.book_online_outlined, "Pengisian Materi", '/addMatery'), ), ], ); draw = AppDrawer(); } else if (res.status == "Siswa") { user = Column( children: [ Container( child: Column( children: [ Container( height: 70, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "SELAMAT DATANG", style: TextStyle(fontSize: 18), ), ], ) ], )), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), child: Stack( alignment: Alignment.center, children: [ Container( height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(120, 0, 120, 0), color: Colors.grey[50], child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "STATUS", style: TextStyle(fontSize: 10), ), ], )), ], ), ), Container( margin: EdgeInsets.fromLTRB(0, 10, 0, 10), child: Text( res.status.toString(), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), ], ), ), Container( child: Column( children: [ Container( child: listMenu(Icons.grading_sharp, "Aturan Permainan", '/petunjukSiswa'), ), Container( margin: EdgeInsets.fromLTRB(0, 100, 0, 0), height: 220, width: 220, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50.0), ), color: Colors.blueAccent, shadowColor: Colors.blueGrey, child: TextButton( style: TextButton.styleFrom(primary: Colors.white), child: Column( children: [ Container( margin: EdgeInsets.fromLTRB(0, 25, 0, 0), child: Icon( Icons.games, size: 100, ), ), Container( margin: EdgeInsets.all(20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Mulai Permainan", textAlign: TextAlign.start, ) ], )), ], ), onPressed: () => Navigator.pushNamed(context, '/modeGame'), )) ], ), ), ], ), ) ], ); draw = AppDrawer(); } else { user = Column( children: [ Container( child: listMenu(Icons.manage_accounts_outlined, "Daftar Guru", '/daftarGuruAdmin'), ), Container( child: listMenu(Icons.manage_accounts_outlined, "Daftar Siswa", '/daftarSiswaAdmin'), ), Container( child: listMenu(Icons.manage_accounts_outlined, "Daftar Guru Belum Verify", '/daftarGuruAdminUn'), ), Container( child: AnimatedButton( text: "Keluar dari Akun", color: Colors.transparent, borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16, color: Colors.red), pressEvent: () { AwesomeDialog( context: context, dialogType: DialogType.WARNING, headerAnimationLoop: false, animType: AnimType.TOPSLIDE, showCloseIcon: false, closeIcon: Icon(Icons.close_fullscreen_outlined), title: 'Keluar dari Akun', desc: 'Apakah kamu yakin mau keluar dari Akun ini?', btnCancelOnPress: () {}, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }, btnOkOnPress: () { submitLogout(context); }) ..show(); }, )) ], ); draw = GuestDrawer(); } } return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Abrakadabar", style: TextStyle(color: Colors.white), ), ) ], ), ), body: ListView( children: [user], ), drawer: draw, ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/screen/DetailScreen.dart
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:group_radio_button/group_radio_button.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:provider/provider.dart'; class DetailScreen extends StatefulWidget { @override _DetailScreenState createState() => _DetailScreenState(); } class _DetailScreenState extends State<DetailScreen> { final _panggilanCtrl = TextEditingController(); final _tempatLahirCtrl = TextEditingController(); final _tanggalLahirCtrl = TextEditingController(); final _detailCtrl = TextEditingController(); final _formKeySiswa = GlobalKey<FormState>(); String _genderCtrl = ""; List<String> _status = ["Laki-laki", "Perempuan"]; @override void dispose() { _panggilanCtrl.dispose(); _tempatLahirCtrl.dispose(); _tanggalLahirCtrl.dispose(); _detailCtrl.dispose(); super.dispose(); } bool _hasError = false; String _errorMsg = ""; TextFormField formInput(controller, label, hidden) { return TextFormField( controller: controller, obscureText: hidden, decoration: InputDecoration( border: OutlineInputBorder(), labelText: label, labelStyle: TextStyle(fontSize: 16), ), ); } DateTimeField dateInput(context, label){ return DateTimeField( controller: _tanggalLahirCtrl, format: DateFormat("dd-MM-yyyy"), onShowPicker: (context, currentValue) { return showDatePicker( context: context, firstDate: DateTime(1900), initialDate: currentValue ?? DateTime.now(), lastDate: DateTime(2100)); }, decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Tanggal Lahir", labelStyle: TextStyle(fontSize: 16), ), ); } Future submitDetail(BuildContext context) async{ var inputFormat = DateFormat('dd-MM-yyyy'); var inputDate = inputFormat.parse(_tanggalLahirCtrl.text); // <-- Incoming date var outputFormat = DateFormat('yyyy-MM-dd'); var outputDate = outputFormat.format(inputDate); // <-- Desired date var result = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestDetail({ 'call_name': _panggilanCtrl.text, 'tempat_lahir': _tempatLahirCtrl.text, 'tanggal_lahir': outputDate, 'jenis_kelamin': _genderCtrl.toString(), 'detail': _detailCtrl.text }))); if (result['status'] == true) { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Melengkapi Data", btnOkOnPress: () { Navigator.pushNamed(context, '/home'); }, headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dismiss from callback $type'); }) ..show(); } else { setState(() { _errorMsg = result['error_msg']; _hasError = true; }); } } @override Widget build(BuildContext context) { var res = context.read<Auth>().user; var status = ''; var detail = ''; if (res.status == "Siswa"){ status = "SISWA"; detail = "Asal Sekolah"; }else{ status = "GURU"; detail = "Tempat Mengajar"; } return Scaffold( appBar: AppBar( title: Container( child: Column(children: [ Image.asset( 'images/logo.png', width: 150, height: 150, ), Text("Lengkapi Data") ],) ), centerTitle: true, toolbarHeight: 200, leading: Container( ), ), body: ListView( children: [ Column( children: [ Container( margin: EdgeInsets.fromLTRB(20, 10, 20, 10), child: Column( children: [ Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 20), child: Text(status, style: TextStyle(fontWeight: FontWeight.bold)), ), Form( key: _formKeySiswa, child: Column( children: [ formInput(_panggilanCtrl, "Nama Panggilan", false), Container(height: 10), formInput(_tempatLahirCtrl, "Tempat Lahir", false), Container(height: 10), dateInput(context, "Tanggal Lahir"), Container(height: 10), Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin : EdgeInsets.fromLTRB(15, 0, 0, 0), child: Text("Jenis Kelamin"), ) ], ), RadioGroup<String>.builder( groupValue: _genderCtrl, onChanged: (value) => setState(() { _genderCtrl = value.toString(); }), items: _status, itemBuilder: (item) => RadioButtonBuilder( item, ), activeColor: Colors.blue, ), ], ), Container(height: 10), formInput(_detailCtrl, detail, false), Container(height: 10), Visibility( visible: _hasError, child: Column( children: [ Text("$_errorMsg", style: TextStyle(color: Colors.red)), ], ) ), Container(height: 10), AnimatedButton( text: "Lengkapi Data", color: Colors.blue, borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16, color: Colors.white), pressEvent: () { AwesomeDialog( context: context, dialogType: DialogType.QUESTION, headerAnimationLoop: false, animType: AnimType.TOPSLIDE, showCloseIcon: false, closeIcon: Icon(Icons.close_fullscreen_outlined), title: 'Lengkapi Data', desc: 'Simpan Informasi?', btnCancelOnPress: () { }, onDissmissCallback: (type) { }, btnOkOnPress: () { submitDetail(context); }) ..show(); }, ), SizedBox( height: 16, ), ] ), ), ], ), ), ], ) ], ), ); } } //Save // print(outputDate);
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/siswa/SkorSiswaScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/model/NilaiUser.dart'; import 'package:flutter/material.dart'; class SkorSiswaScreen extends StatefulWidget { SkorSiswaScreen({Key? key, this.user_id}) : super(key: key); final int? user_id; @override _SkorSiswaScreenState createState() => _SkorSiswaScreenState(); } class _SkorSiswaScreenState extends State<SkorSiswaScreen> { late Future<NilaisUser> nilaiBuffer; @override void initState() { super.initState(); nilaiBuffer = MateriAPI().fetchNilai({'user_id': widget.user_id}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Daftar Skor", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<NilaisUser>( future: nilaiBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return SkorWidget(skors: snapshot.data!.nilaiuser); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), ); } } class SkorWidget extends StatefulWidget { SkorWidget({Key? key, required this.skors}) : super(key: key); final skors; @override _SkorWidgetState createState() => _SkorWidgetState(); } class _SkorWidgetState extends State<SkorWidget> { late List<NilaiUser> _nilaiUserList; @override void initState() { super.initState(); _nilaiUserList = widget.skors; } @override Widget build(BuildContext context) { if (_nilaiUserList.length == 0) { return Center(child: Text("Tidak Ada Data")); } else { return Container( child: ListView.builder( itemCount: _nilaiUserList.length, itemBuilder: (ctx, index) { return Card( child: ListTile( leading: Icon( Icons.supervised_user_circle, size: 50, ), title: Text('${_nilaiUserList[index].materi}'), subtitle: Text('@${_nilaiUserList[index].score}'), onTap: () { // Navigator.of(context).push(MaterialPageRoute( // builder: (BuildContext context) => SkorSiswaScreen( // user_id: _userList[index].ide, // ))); }, ), ); }), ); } } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/siswa/DaftarSkorSiswaScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/model/User.dart'; import 'package:abrakadabar/screen/AppDrawer.dart'; import 'package:abrakadabar/screen/siswa/SkorSiswaScreen.dart'; import 'package:flutter/material.dart'; class DaftarSkorSiswaScreen extends StatefulWidget { DaftarSkorSiswaScreen({Key? key, required this.status}) : super(key: key); final String status; @override _DaftarSkorSiswaScreenState createState() => _DaftarSkorSiswaScreenState(); } class _DaftarSkorSiswaScreenState extends State<DaftarSkorSiswaScreen> { late Future<Users> usersBuffer; @override void initState() { super.initState(); usersBuffer = MateriAPI().fetchAllUsers({'status': widget.status}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Daftar Skor Siswa", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<Users>( future: usersBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return ShowUsersWidget( users: snapshot.data?.users, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), drawer: AppDrawer(), ); } } class ShowUsersWidget extends StatefulWidget { final users; ShowUsersWidget({Key? key, this.users}) : super(key: key); @override _ShowUsersWidgetState createState() => _ShowUsersWidgetState(); } class _ShowUsersWidgetState extends State<ShowUsersWidget> { late List<User> _userList; @override void initState() { super.initState(); _userList = widget.users; } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _userList.length, itemBuilder: (ctx, index) { return Card( child: ListTile( leading: Icon( Icons.supervised_user_circle, size: 50, ), title: Text('${_userList[index].fullName}'), subtitle: Text('@${_userList[index].username}'), onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => SkorSiswaScreen( user_id: _userList[index].ide, ))); }, ), ); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/siswa/AturanPermainanScreen.dart
import 'package:flutter/material.dart'; class AturanPermainanScreen extends StatefulWidget { AturanPermainanScreen({Key? key}) : super(key: key); @override _AturanPermainanScreenState createState() => _AturanPermainanScreenState(); } class _AturanPermainanScreenState extends State<AturanPermainanScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Petunjuk", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( height: 70, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "PETUNJUK PERMAINAN", style: TextStyle(fontSize: 18), ), ], ) ], )), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), child: Stack( alignment: Alignment.center, children: [ Container( height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(120, 0, 120, 0), color: Colors.grey[50], child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "", style: TextStyle(fontSize: 10), ), ], )), ], ), ), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), width: 350, height: 550, child: ListView( children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 300, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "1", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Masuk Ke Permainan", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 300, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "2", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Pilih Tingkat Kesulitan", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 300, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "3", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Baca Sinopsis dan Lanjutkan", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 300, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "4", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Lihat Gambar dan Masukkan Cerita", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 300, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "5", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Klik Petunjuk jika butuh bantuan", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 300, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "6", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Lengkapi cerita hingga selesai", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), ]), ], )) ], ), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi/ModeScreen.dart
import 'package:abrakadabar/screen/AppDrawer.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:abrakadabar/screen/materi/listmode/ListScreen.dart'; class ModeScreen extends StatefulWidget { @override _ModeScreenState createState() => _ModeScreenState(); } class _ModeScreenState extends State<ModeScreen> { Card listMenu(text) { return Card( margin: EdgeInsets.fromLTRB(10, 5, 10, 5), child: ListTile( title: Container( child: Text( text, textAlign: TextAlign.start, )), onTap: () => Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => ListScreen( mode: text, ))), )); } void initState() { super.initState(); checkIsLoggedIn(); } void checkIsLoggedIn() async { await Provider.of<Auth>(context, listen: false).requestCheckMe(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Pilih Mode", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Column( children: [ Container( margin: EdgeInsets.fromLTRB(0, 0, 0, 50), height: 70, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "DAFTAR MODE", style: TextStyle(fontSize: 18), ), ], ) ], )), Container( child: listMenu("Easy"), ), Container( child: listMenu("Medium"), ), Container( child: listMenu("Hard"), ) ], ), drawer: AppDrawer(), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi/ShowMateriScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:abrakadabar/model/AllMateri.dart'; import 'package:abrakadabar/screen/materi/SoalGambarScreen.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; import 'listmode/ListSoalScreen.dart'; class ShowMateriScreen extends StatefulWidget { ShowMateriScreen({Key? key, required this.id_materi, required this.mode}) : super(key: key); final int? id_materi; final String mode; @override _ShowMateriScreenState createState() => _ShowMateriScreenState(); } class _ShowMateriScreenState extends State<ShowMateriScreen> { late Future<AllMateri> materiBuffer; @override void initState() { materiBuffer = MateriAPI().fetchAll({'mode': widget.mode}); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Halaman Cerita", style: TextStyle(color: Colors.white), ), ) ], ), ), body: FutureBuilder<AllMateri>( future: materiBuffer, builder: (context, ss) { if (ss.hasData) { return ShowMateriWidget( materis: ss.data?.allmateri, id_materi: widget.id_materi, ); } else if (ss.hasError) { return Text("${ss.error}"); } return Center( child: CircularProgressIndicator(), ); }, )); } } class ShowMateriWidget extends StatefulWidget { final id_materi; final materis; ShowMateriWidget({Key? key, required this.materis, this.id_materi}) : super(key: key); @override _ShowMateriWidgetState createState() => _ShowMateriWidgetState(); } class _ShowMateriWidgetState extends State<ShowMateriWidget> { late List<Materis> _materiList; @override void initState() { super.initState(); _materiList = widget.materis; } Future hapusSoal(BuildContext context, id) async { var res = await showDialog( context: context, builder: (context) => FutureProgressDialog( Auth().requestHapusMateri(FormData.fromMap({'id': id})))); if (res['status'] == true) { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Dihapus", btnOkOnPress: () { Navigator.pushNamed(context, '/home'); }, btnOkText: "Lanjutkan", headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else {} } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _materiList.length, itemBuilder: (ctx, index) { if (_materiList[index].id == widget.id_materi) { return Container( child: Column(children: [ Card( margin: EdgeInsets.fromLTRB(10, 20, 10, 10), shadowColor: Colors.grey, borderOnForeground: true, child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 320, margin: EdgeInsets.all(10), child: Center( child: Text( _materiList[index].title.toString(), style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16), ), )), ], ) ], )), ), Card( margin: EdgeInsets.fromLTRB(10, 0, 10, 10), shadowColor: Colors.grey, borderOnForeground: true, child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 320, margin: EdgeInsets.all(10), child: Center( child: Image.network( 'https://abrakadabar.yokya.id/storage/${_materiList[index].link_image}', height: 300, ), )), Container( margin: EdgeInsets.all(10), child: Text( "Sinopsis :", style: TextStyle( fontSize: 16, ), ), ), Container( width: 350, margin: EdgeInsets.all(10), child: Text(_materiList[index].sinopsis.toString()), ) ], ) ], ))), Column( children: [ Card( margin: EdgeInsets.fromLTRB(10, 5, 10, 5), child: ListTile( tileColor: Colors.blue, title: Container( child: Text( "Daftar Soal", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white), textAlign: TextAlign.center, )), onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => ListSoalScreen( materi_id: _materiList[index].id))); })), Card( margin: EdgeInsets.fromLTRB(10, 5, 10, 5), child: ListTile( tileColor: Colors.blue, title: Container( child: Text( "Tambah Soal", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white), textAlign: TextAlign.center, )), onTap: () => Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => SoalGambarScreen( id: _materiList[index].id, num: 1))))), Card( margin: EdgeInsets.fromLTRB(10, 5, 10, 5), child: ListTile( tileColor: Colors.red, title: Container( child: Text( "Hapus Cerita", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white), textAlign: TextAlign.center, )), onTap: () => hapusSoal(context, widget.id_materi))), ], ), ])); } else { return Text(""); } }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi/AddMateriScreen.dart
import 'dart:io'; import 'package:abrakadabar/screen/materi/SoalGambarScreen.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:group_radio_button/group_radio_button.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:image_picker/image_picker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/src/widgets/basic.dart'; class AddMateriScreen extends StatefulWidget { const AddMateriScreen({Key? key, this.title}) : super(key: key); final String? title; @override _AddMateriScreenState createState() => _AddMateriScreenState(); } class _AddMateriScreenState extends State<AddMateriScreen> { final _titleCtrl = TextEditingController(); final _sinopsisCtrl = TextEditingController(); String _modeCtrl = ""; List<String> _mode = ["Easy", "Medium", "Hard"]; PickedFile? _imageFile; dynamic _pickImageError; String? _retrieveDataError; final _formKey = GlobalKey<FormState>(); final ImagePicker _picker = ImagePicker(); @override void dispose() { _titleCtrl.dispose(); _sinopsisCtrl.dispose(); super.dispose(); } void _onImageButtonPressed(ImageSource source, {BuildContext? context}) async { try { final pickedFile = await _picker.getImage( source: source, maxWidth: 1000, maxHeight: 1000, ); setState(() { _imageFile = pickedFile; }); } catch (e) { setState(() { _pickImageError = e; }); } } @override void initState() { super.initState(); checkIsLoggedIn(); } void checkIsLoggedIn() async { await Provider.of<Auth>(context, listen: false).requestCheckMe(); } bool _hasError = false; String _errorMsg = ""; TextFormField formInput(controller, label, hidden) { return TextFormField( controller: controller, obscureText: hidden, decoration: InputDecoration( border: OutlineInputBorder(), labelText: label, labelStyle: TextStyle(fontSize: 16), ), ); } Widget _previewImage() { final Text? retrieveError = _getRetrieveErrorWidget(); if (retrieveError != null) { return retrieveError; } if (_imageFile != null) { if (kIsWeb) { // Why network? // See https://pub.dev/packages/image_picker#getting-ready-for-the-web-platform return Image.network(_imageFile!.path); } else { return Semantics( child: Image.file(File(_imageFile!.path)), label: 'image_picker_example_picked_image'); } } else if (_pickImageError != null) { return Text( 'Pick image error: $_pickImageError', textAlign: TextAlign.center, ); } else { return const Text( 'You have not yet picked an image.', textAlign: TextAlign.center, ); } } Future<void> retrieveLostData() async { final LostData response = await _picker.getLostData(); if (response.isEmpty) { return; } if (response.file != null) { setState(() { _imageFile = response.file; }); } else { _retrieveDataError = response.exception!.code; } } Future<FormData> form() async { File _image = File(_imageFile!.path); String fileName = _image.path.split('/').last; return FormData.fromMap({ 'title': _titleCtrl.text, 'kesulitan': _modeCtrl.toString(), 'sinopsis': _sinopsisCtrl.text, 'link_image': await MultipartFile.fromFile( _image.path, filename: fileName, ), }); } Future checkIsGambar(id) async { await Provider.of<Auth>(context, listen: false) .requestCheckGambar({'id': id}); return true; } Future simpanMateri(BuildContext context) async { var res = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestAddMateri(form()))); if (res['status'] == true) { checkIsGambar(res['id']); var route = MaterialPageRoute( builder: (BuildContext context) => SoalGambarScreen(id: res['id'], num: 1,)); AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil ditambakan", btnOkOnPress: () { Navigator.of(context).push(route); }, btnOkText: "Lanjutkan", headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else { setState(() { _errorMsg = res['error_msg']; _hasError = true; }); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Pengisian Materi", style: TextStyle(color: Colors.white), ), ) ], ), ), body: ListView( children: [ Container( padding: EdgeInsets.all(15), color: Colors.white, child: Form( key: _formKey, child: Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 10), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.fromLTRB(10, 0, 10, 0), child: formInput(_titleCtrl, "Judul Cerita", false), ), Container(height: 10), Container( width: 200, height: 200, child: Center( child: !kIsWeb && defaultTargetPlatform == TargetPlatform.android ? FutureBuilder<void>( future: retrieveLostData(), builder: (BuildContext context, AsyncSnapshot<void> snapshot) { switch (snapshot.connectionState) { case ConnectionState.none: case ConnectionState.waiting: return const Text( 'You have not yet picked an image.', textAlign: TextAlign.center, ); case ConnectionState.done: return _previewImage(); default: if (snapshot.hasError) { return Text( 'Pick image error: ${snapshot.error}}', textAlign: TextAlign.center, ); } else { return const Text( 'You have not yet picked an image.', textAlign: TextAlign.center, ); } } }, ) : (_previewImage()), ), ), Container( alignment: Alignment.centerLeft, child: TextButton( onPressed: () { _onImageButtonPressed(ImageSource.gallery, context: context); }, child: Container( decoration: BoxDecoration( color: Colors.grey[400], borderRadius: BorderRadius.all(Radius.circular(5.0))), height: 50, child: Text( "Upload Gambar Judul", style: TextStyle(color: Colors.black), textAlign: TextAlign.center, ), alignment: Alignment.center, ), ), ), Container(height: 10), Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( margin: EdgeInsets.fromLTRB(15, 0, 0, 0), child: Text("Tingkat Kesulitan"), ) ], ), RadioGroup<String>.builder( groupValue: _modeCtrl, onChanged: (value) => setState(() { _modeCtrl = value.toString(); }), items: _mode, itemBuilder: (item) => RadioButtonBuilder( item, ), activeColor: Colors.blue, ), ], ), Container(height: 10), Container( margin: EdgeInsets.fromLTRB(10, 0, 10, 0), child: TextFormField( controller: _sinopsisCtrl, obscureText: false, style: TextStyle(fontSize: 12), decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Sinopsis", labelStyle: TextStyle(fontSize: 14), ), minLines: 4, maxLines: 10, ), ), Container(height: 10), Visibility( visible: _hasError, child: Column( children: [ Text("$_errorMsg", style: TextStyle(color: Colors.red)), ], )), Container( margin: EdgeInsets.all(10), child: AnimatedButton( text: 'Simpan dan Lanjutkan', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16), pressEvent: () async { await simpanMateri(context); }, ), ) ]), )), ), ], )); } Text? _getRetrieveErrorWidget() { if (_retrieveDataError != null) { final Text result = Text(_retrieveDataError!); _retrieveDataError = null; return result; } return null; } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi/SoalGambarScreen.dart
import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:image_picker/image_picker.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; // ignore: must_be_immutable class SoalGambarScreen extends StatefulWidget { SoalGambarScreen({Key? key, this.id, required this.num}) : super(key: key); final int? id; int num; @override _SoalGambarScreenState createState() => _SoalGambarScreenState(); } class _SoalGambarScreenState extends State<SoalGambarScreen> { final _keywordCtrl = TextEditingController(); final _petunjukCtrl = TextEditingController(); final _formKey = GlobalKey<FormState>(); PickedFile? _imageFile; dynamic _pickImageError; String? _retrieveDataError; final ImagePicker _picker = ImagePicker(); @override void initState() { super.initState(); checkIsGambar(); } @override void dispose() { _keywordCtrl.dispose(); _petunjukCtrl.dispose(); super.dispose(); } void _onImageButtonPressed(ImageSource source, {BuildContext? context}) async { try { final pickedFile = await _picker.getImage( source: source, maxWidth: 1000, maxHeight: 1000, ); setState(() { _imageFile = pickedFile; }); } catch (e) { setState(() { _pickImageError = e; }); } } Widget _previewImage() { final Text? retrieveError = _getRetrieveErrorWidget(); if (retrieveError != null) { return retrieveError; } if (_imageFile != null) { if (kIsWeb) { return Image.network(_imageFile!.path); } else { return Semantics( child: Image.file(File(_imageFile!.path)), label: 'image_picker_example_picked_image'); } } else if (_pickImageError != null) { return Text( 'Pick image error: $_pickImageError', textAlign: TextAlign.center, ); } else { return const Text( 'You have not yet picked an image.', textAlign: TextAlign.center, ); } } Future<void> retrieveLostData() async { final LostData response = await _picker.getLostData(); if (response.isEmpty) { return; } if (response.file != null) { setState(() { _imageFile = response.file; }); } else { _retrieveDataError = response.exception!.code; } } Future<FormData> form(id) async { File _image = File(_imageFile!.path); String fileName = _image.path.split('/').last; return FormData.fromMap({ 'materi_id': id, 'keyword': _keywordCtrl.text, 'petunjuk': _petunjukCtrl.text, 'link_image': await MultipartFile.fromFile( _image.path, filename: fileName, ), }); } Future<FormData> form3(id) async { return FormData.fromMap({'id': id}); } Future<FormData> form2(id) async { File _image = File(_imageFile!.path); String fileName = _image.path.split('/').last; return FormData.fromMap({ 'publish': 'Published', 'materi_id': id, 'keyword': _keywordCtrl.text, 'petunjuk': _petunjukCtrl.text, 'link_image': await MultipartFile.fromFile( _image.path, filename: fileName, ), }); } Future simpanGambar(BuildContext context, id, num) async { var res = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestAddSoal(form(id)))); if (res['status'] == true) { var route = MaterialPageRoute( builder: (BuildContext context) => SoalGambarScreen( id: id, num: num, )); AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil ditambakan", btnOkOnPress: () { Navigator.of(context).push(route); }, btnOkText: "Lanjutkan", headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else {} } Future simpanGambarPublished(BuildContext context, id) async { var res = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestAddSoal(form2(id)))); if (res['status'] == true) { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil ditambakan", btnOkOnPress: () { Navigator.pushNamed(context, '/home'); }, btnOkText: "Lanjutkan", headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else {} } Future hapusSoal(BuildContext context, id) async { var res = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestHapusMateri(form3(id)))); if (res['status'] == true) { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: true, title: 'Berhasil', desc: "Berhasil Dihapus", btnOkOnPress: () { Navigator.pushNamed(context, '/home'); }, btnOkText: "Lanjutkan", headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }) ..show(); } else {} } Future checkIsGambar() async { await Provider.of<Auth>(context, listen: false) .requestCheckGambar({'id': widget.id}); return true; } TextFormField formInput(controller, label, hidden) { return TextFormField( controller: controller, obscureText: hidden, decoration: InputDecoration( border: OutlineInputBorder(), labelText: label, labelStyle: TextStyle(fontSize: 16), ), ); } @override Widget build(BuildContext context) { var res = context.watch<Auth>().materi; var title; if (res.title.toString().isNotEmpty == true) { title = res.title.toString(); } else { title = "Load"; } return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Tambah Gambar", style: TextStyle(color: Colors.white), ), ) ], ), ), body: ListView( children: [ Container( color: Colors.white, padding: EdgeInsets.all(5), child: Column(children: [ Form( key: _formKey, child: Container( margin: EdgeInsets.all(20), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Row( children: [ Column( children: [ Text( "JUDUL : ", ) ], ), Column( children: [ Text(title), ], ) ], ), Container(height: 20), Container( child: Text( "Ke-${widget.num}", style: TextStyle(fontWeight: FontWeight.bold), ), ), Container(height: 10), // Gambar Container( width: 200, height: 200, child: Center( child: !kIsWeb && defaultTargetPlatform == TargetPlatform.android ? FutureBuilder<void>( future: retrieveLostData(), builder: (BuildContext context, AsyncSnapshot<void> snapshot) { switch (snapshot.connectionState) { case ConnectionState.none: case ConnectionState.waiting: return const Text( 'You have not yet picked an image.', textAlign: TextAlign.center, ); case ConnectionState.done: return _previewImage(); default: if (snapshot.hasError) { return Text( 'Pick image error: ${snapshot.error}}', textAlign: TextAlign.center, ); } else { return const Text( 'You have not yet picked an image.', textAlign: TextAlign.center, ); } } }, ) : (_previewImage()), ), ), // Input Gambar Container( alignment: Alignment.centerLeft, child: TextButton( onPressed: () { _onImageButtonPressed(ImageSource.gallery, context: context); }, child: Container( decoration: BoxDecoration( color: Colors.grey[400], borderRadius: BorderRadius.all(Radius.circular(5.0))), height: 50, child: Text( "Upload Gambar Soal", style: TextStyle(color: Colors.black), textAlign: TextAlign.center, ), alignment: Alignment.center, ), ), ), Container(height: 10), Container( margin: EdgeInsets.fromLTRB(10, 0, 10, 0), child: formInput(_keywordCtrl, "Keyword, Contoh : buku, papan, pensil", false), ), Container( margin: EdgeInsets.fromLTRB(0, 10, 0, 0), child: Text( "Pisahkan antara keyword dengan tanda ',' (Koma)", style: TextStyle(fontSize: 11), ), ), Container(height: 10), Container( margin: EdgeInsets.fromLTRB(10, 0, 10, 0), child: formInput(_petunjukCtrl, "Petunjuk", false), ), Container(height: 10), Container( margin: EdgeInsets.all(10), child: AnimatedButton( text: 'Simpan dan Tambahkan Gambar', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 14), pressEvent: () async { await simpanGambar( context, widget.id, ++widget.num); }, ), ), Container( color: Colors.green, margin: EdgeInsets.all(10), child: AnimatedButton( text: 'Simpan dan Terbitkan', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 14), pressEvent: () async { await simpanGambarPublished(context, widget.id); }, ), ), Container( margin: EdgeInsets.all(10), child: AnimatedButton( color: Colors.red, text: 'Batalkan dan Hapus', borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 14), pressEvent: () async { await hapusSoal(context, widget.id); }, ), ) ], ), )), ]), ), ], )); } Text? _getRetrieveErrorWidget() { if (_retrieveDataError != null) { final Text result = Text(_retrieveDataError!); _retrieveDataError = null; return result; } return null; } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi/listmode/ListSoalScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/model/Soals.dart'; import 'package:flutter/material.dart'; class ListSoalScreen extends StatefulWidget { ListSoalScreen({Key? key, this.materi_id}) : super(key: key); final materi_id; @override _ListSoalScreenState createState() => _ListSoalScreenState(); } class _ListSoalScreenState extends State<ListSoalScreen> { late Future<Soals> soalsBuffer; @override void initState() { super.initState(); soalsBuffer = MateriAPI().fetchAllSoal({'materi_id': widget.materi_id}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Halaman Soal", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<Soals>( future: soalsBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return ShowSoalWidget( soals: snapshot.data?.soals, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), ); } } class ShowSoalWidget extends StatefulWidget { final soals; ShowSoalWidget({Key? key, this.soals}) : super(key: key); @override _ShowSoalWidgetState createState() => _ShowSoalWidgetState(); } class _ShowSoalWidgetState extends State<ShowSoalWidget> { late List<Soal> _soalList; @override void initState() { super.initState(); _soalList = widget.soals; } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _soalList.length, itemBuilder: (ctx, index) { return Card( margin: EdgeInsets.fromLTRB(10, 0, 10, 10), shadowColor: Colors.grey, borderOnForeground: true, child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 320, margin: EdgeInsets.all(10), child: Center( child: Image.network( 'https://abrakadabar.yokya.id/storage/${_soalList[index].link_image}', height: 200, ), )), Container( margin: EdgeInsets.all(10), child: Text( "Keyword : ${_soalList[index].keyword}", style: TextStyle( fontSize: 12, ), ), ), Container( margin: EdgeInsets.all(10), child: Text( "Petunjuk : ${_soalList[index].petunjuk}", style: TextStyle( fontSize: 12, ), ), ), ], ), ], ))); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi
mirrored_repositories/Abrakadabar-Flutter/lib/screen/materi/listmode/ListScreen.dart
import 'package:abrakadabar/model/AllMateri.dart'; import 'package:flutter/material.dart'; import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/screen/materi/ShowMateriScreen.dart'; import 'dart:core'; class ListScreen extends StatefulWidget { ListScreen({Key? key, required this.mode}) : super(key: key); final String mode; @override _ListScreenState createState() => _ListScreenState(); } class _ListScreenState extends State<ListScreen> { late Future<AllMateri> materiBuffer; @override void initState() { materiBuffer = MateriAPI().fetchAll({'mode': widget.mode}); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "${widget.mode} Mode", style: TextStyle(color: Colors.white), ), ) ], ), ), body: FutureBuilder<AllMateri>( future: materiBuffer, builder: (context, ss) { if (ss.hasData) { return DaftarCeritaWidget( materis: ss.data?.allmateri, mode: widget.mode); } else if (ss.hasError) { return Text("${ss.error}"); } return Center( child: CircularProgressIndicator(), ); }, )); } } class DaftarCeritaWidget extends StatefulWidget { final materis; final String mode; DaftarCeritaWidget({Key? key, required this.materis, required this.mode}) : super(key: key); @override _DaftarCeritaWidgetState createState() => _DaftarCeritaWidgetState(); } class _DaftarCeritaWidgetState extends State<DaftarCeritaWidget> { late List<Materis> _materiList; @override void initState() { super.initState(); _materiList = widget.materis; } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _materiList.length, itemBuilder: (ctx, index) { return ListTile( leading: Container( width: 50, height: 50, child: Image.network( 'https://abrakadabar.yokya.id/storage/${_materiList[index].link_image}', width: 50, height: 50, ), ), title: Text('${_materiList[index].title}'), isThreeLine: true, subtitle: Text('${_materiList[index].sinopsis}'), onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => ShowMateriScreen( id_materi: _materiList[index].id, mode: widget.mode))); }, trailing: Icon(Icons.lens_blur_outlined), ); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/guru/PetunjukPengisianScreen.dart
import 'package:flutter/material.dart'; class PetunjukPengisianScreen extends StatefulWidget { PetunjukPengisianScreen({Key? key}) : super(key: key); @override _PetunjukPengisianScreenState createState() => _PetunjukPengisianScreenState(); } class _PetunjukPengisianScreenState extends State<PetunjukPengisianScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Petunjuk", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( height: 70, child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "PETUNJUK PENGISIAN", style: TextStyle(fontSize: 18), ), ], ) ], )), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), child: Stack( alignment: Alignment.center, children: [ Container( height: 1, color: Colors.grey, ), Container( margin: EdgeInsets.fromLTRB(120, 0, 120, 0), color: Colors.grey[50], child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "", style: TextStyle(fontSize: 10), ), ], )), ], ), ), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 0), width: 350, height: 550, child: ListView( children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "1", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 200, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Masukkan judul Cerita", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "2", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 200, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Masukkan Gambar Judul", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "3", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 200, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Pilih Tingkat Kesulitan", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "4", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 200, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Isi Sinopsis", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "5", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 200, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Klik simpan dan lanjutkan", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "6", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 200, height: 30, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Tambahkan Gambar", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "7", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 60, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Masukkan Keyword\n(Pisahkan dengan tanda koma)", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "8", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 60, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Masukkan Petunjuk\n(Petunjuk untuk siswa)", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), Container( width: 200, height: 30, color: Colors.blueGrey[500], child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "9", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ) ], ) ], ) ], ), ), Container( margin: EdgeInsets.all(25), width: 300, height: 120, child: Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Ada 3 Pilihan\n1. Simpan dan Tambah\n2.Simpan dan Terbitkan\n3.Batalkan dan Hapus", style: TextStyle( color: Colors.black, ), ) ], ) ], ) ], ), ), ]), ], )) ], ), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/game/GameDuaScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:abrakadabar/model/Soals.dart'; import 'package:abrakadabar/screen/game/GameTigaScreen.dart'; import 'package:flutter/material.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; class GameDuaScreen extends StatefulWidget { GameDuaScreen( {Key? key, required this.materi_id, required this.list, required this.index}) : super(key: key); final materi_id; final List list; late final int index; @override _GameDuaScreenState createState() => _GameDuaScreenState(); } class _GameDuaScreenState extends State<GameDuaScreen> { late Future<Soal> soalBuffer; final _jawabanCtrl = TextEditingController(); @override void dispose() { _jawabanCtrl.dispose(); super.dispose(); } @override void initState() { soalBuffer = MateriAPI().fetchSoal( {'materi_id': widget.materi_id, 'soal_id': widget.list[widget.index]}); super.initState(); } Future nextQuestion(BuildContext context) async { var result = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestAddJawaban({ 'materi_id': widget.materi_id, 'soal_id': widget.list[widget.index], 'jawaban': _jawabanCtrl.text }))); if (result['status'] == true) { if (widget.list.length == (widget.index + 1)) { var res = await Auth().requestNilai({ 'materi_id': widget.materi_id, }); Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => GameTigaScreen(res: res['nilai']))); } else { AwesomeDialog( context: context, animType: AnimType.TOPSLIDE, dialogType: DialogType.NO_HEADER, showCloseIcon: false, title: 'Selanjutnya', btnOkOnPress: () { Navigator.pushAndRemoveUntil( context, MaterialPageRoute( builder: (BuildContext context) => GameDuaScreen( materi_id: widget.materi_id, list: widget.list, index: widget.index + 1)), (Route<dynamic> route) => false); }, headerAnimationLoop: false, btnOkIcon: Icons.check_circle, onDissmissCallback: (type) { debugPrint('Dialog Dismiss from callback $type'); }) ..show(); } } } @override Widget build(BuildContext context) { var text; if (widget.list.length == widget.index + 1) { text = "SELESAI DAN SIMPAN"; } else { text = "LANJUTKAN"; } return FutureBuilder<Soal>( future: soalBuffer, builder: (context, ss) { if (ss.hasData) { var help = 5; return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Gambar Ke-${widget.index + 1}", style: TextStyle(color: Colors.white), ), ) ], ), ), body: GridView.count(crossAxisCount: 1, children: [ Image.network( 'https://abrakadabar.yokya.id/storage/${ss.data!.link_image}', ), Container( padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ Container( margin: EdgeInsets.fromLTRB(50, 10, 50, 0), width: 200, child: Column( children: [ AnimatedButton( text: 'Petunjuk', color: Colors.cyan, pressEvent: () { if (help > 0) { AwesomeDialog( context: context, headerAnimationLoop: false, dialogType: DialogType.NO_HEADER, title: ss.data!.petunjuk, desc: "Petunjuk anda tinggal ${help - 1}", btnOkOnPress: () { debugPrint('OnClcik'); }, btnOkIcon: Icons.check_circle, )..show(); help--; } else { AwesomeDialog( context: context, headerAnimationLoop: false, dialogType: DialogType.NO_HEADER, title: "Petunjuk Sudah Habis", btnOkOnPress: () { debugPrint('OnClcik'); }, btnOkIcon: Icons.check_circle, )..show(); } }, ), SizedBox( height: 16, ), ], ), ), Container( margin: EdgeInsets.all(10), width: 350, child: Form( child: TextFormField( minLines: 5, maxLines: 10, controller: _jawabanCtrl, decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Text Cerita", labelStyle: TextStyle(fontSize: 14), ), ), ), ), Container( margin: EdgeInsets.all(10), width: 350, child: Column( children: [ AnimatedButton( text: text, borderRadius: BorderRadius.circular(5), buttonTextStyle: TextStyle(fontSize: 16), pressEvent: () { nextQuestion(context); }, ), SizedBox( height: 12, ), ], )) ], ) ], )), ]), ); } else if (ss.hasError) { return Text("${ss.error}"); } return Center( child: CircularProgressIndicator(), ); }, ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/game/ModeGameScreen.dart
import 'package:abrakadabar/screen/game/ListModeGameScreen.dart'; import 'package:flutter/material.dart'; class ModeGameScreen extends StatefulWidget { ModeGameScreen({Key? key}) : super(key: key); @override _ModeGameScreenState createState() => _ModeGameScreenState(); } class _ModeGameScreenState extends State<ModeGameScreen> { Card listMenu(text) { return Card( color: Colors.blueAccent, margin: EdgeInsets.all(10), child: ListTile( title: Container( height: 100, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( text, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 20), ) ], ) ], )), onTap: () => Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => ListModeGameScreen( mode: text, ))), )); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Pilih Mode", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Center( child: Column( children: [ listMenu("EASY"), listMenu("MEDIUM"), listMenu("HARD"), ], )) ], )), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/game/GameTigaScreen.dart
import 'package:flutter/material.dart'; class GameTigaScreen extends StatefulWidget { GameTigaScreen({Key? key, this.res}) : super(key: key); final int? res; @override _GameTigaScreenState createState() => _GameTigaScreenState(); } class _GameTigaScreenState extends State<GameTigaScreen> { Row cek(nilai) { if (nilai > 75) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.star, color: Colors.white, size: 40, ), Icon( Icons.star, color: Colors.white, size: 40, ), Icon( Icons.star, color: Colors.white, size: 40, ) ], ); } else if (nilai == 75) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.star, color: Colors.white, size: 40, ), Icon( Icons.star, color: Colors.white, size: 40, ), Icon( Icons.star_border, color: Colors.white, size: 40, ) ], ); } else { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.star, color: Colors.white, size: 40, ), Icon( Icons.star_border, color: Colors.white, size: 40, ), Icon( Icons.star_border, color: Colors.white, size: 40, ) ], ); } } @override Widget build(BuildContext context) { return Scaffold( body: Container( color: Colors.blue, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.all(20), child: Text( "Kamu telah selesai mengisi cerita", style: TextStyle(color: Colors.white, fontSize: 18), ), ), Container( margin: EdgeInsets.all(20), child: Text( "Skor Kamu saat ini", style: TextStyle(color: Colors.white, fontSize: 16), ), ), Container( child: cek(widget.res), ), Container( margin: EdgeInsets.all(20), child: TextButton( style: TextButton.styleFrom( primary: Colors.blue, backgroundColor: Colors.white, onSurface: Colors.grey, ), onPressed: () { Navigator.pushNamed(context, '/home'); }, child: Text( "Kembali Ke Beranda", style: TextStyle( color: Colors.blue, fontSize: 16, decoration: TextDecoration.underline), ))), ], )), ), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/game/GameSatuScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/model/Materi.dart'; import 'package:abrakadabar/screen/game/GameDuaScreen.dart'; import 'package:flutter/material.dart'; class GameSatuScreen extends StatefulWidget { GameSatuScreen({Key? key, required this.materi_id}) : super(key: key); final materi_id; @override _GameSatuScreenState createState() => _GameSatuScreenState(); } class _GameSatuScreenState extends State<GameSatuScreen> { late Future<Materi> materiBuffer; @override void initState() { materiBuffer = MateriAPI().fetchMateri({'id': widget.materi_id}); super.initState(); } @override Widget build(BuildContext context) { return FutureBuilder<Materi>( future: materiBuffer, builder: (context, ss) { if (ss.hasData) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "${ss.data!.title}", style: TextStyle(color: Colors.white), ), ) ], ), ), body: GridView.count( crossAxisCount: 1, children: [ Image.network( 'https://abrakadabar.yokya.id/storage/${ss.data!.link_image}', ), Container( padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ Container( width: 350, child: Text( ss.data!.title, style: TextStyle(fontSize: 20), textAlign: TextAlign.center, ), ), Container( width: 350, margin: EdgeInsets.fromLTRB(0, 15, 0, 15), child: Text( "Sinopsis :", textAlign: TextAlign.left, ), ), Container( width: 350, child: Text( ss.data!.sinopsis, style: TextStyle(fontSize: 16), ), ), Container( margin: EdgeInsets.fromLTRB(0, 20, 0, 20), width: 350, color: Colors.blueAccent, child: TextButton( onPressed: () => { Navigator.pushAndRemoveUntil( context, MaterialPageRoute( builder: (BuildContext context) => GameDuaScreen( materi_id: ss.data!.id, list: ss.data!.soal, index: 0)), (Route<dynamic> route) => false) }, child: Text( "Masuk ke quiz", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), ))), ], ) ], )) ], )); } else if (ss.hasError) { return Text("${ss.error}"); } return Center( child: CircularProgressIndicator(), ); }, ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/game/ListModeGameScreen.dart
import 'package:abrakadabar/model/AllMateri.dart'; import 'package:abrakadabar/screen/game/GameSatuScreen.dart'; import 'package:flutter/material.dart'; import 'package:abrakadabar/API/MateriApi.dart'; import 'dart:core'; class ListModeGameScreen extends StatefulWidget { ListModeGameScreen({Key? key, required this.mode}) : super(key: key); final String mode; @override _ListModeGameScreenState createState() => _ListModeGameScreenState(); } class _ListModeGameScreenState extends State<ListModeGameScreen> { late Future<AllMateri> materiBuffer; @override void initState() { materiBuffer = MateriAPI().fetchAll({'mode': widget.mode}); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Mode ${widget.mode} ", style: TextStyle(color: Colors.white), ), ) ], ), ), body: FutureBuilder<AllMateri>( future: materiBuffer, builder: (context, ss) { if (ss.hasData) { return DaftarCeritaWidget( materis: ss.data?.allmateri, mode: widget.mode); } else if (ss.hasError) { return Text("${ss.error}"); } return Center( child: CircularProgressIndicator(), ); }, )); } } class DaftarCeritaWidget extends StatefulWidget { final materis; final String mode; DaftarCeritaWidget({Key? key, required this.materis, required this.mode}) : super(key: key); @override _DaftarCeritaWidgetState createState() => _DaftarCeritaWidgetState(); } class _DaftarCeritaWidgetState extends State<DaftarCeritaWidget> { late List<Materis> _materiList; @override void initState() { super.initState(); _materiList = widget.materis; } Row nilaiLock(nilai) { if (nilai == 101) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.lock)], ); } else if (nilai == 102) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.star_border, ), Icon( Icons.star_border, ), Icon( Icons.star_border, ), ], ); } else { if (nilai > 75) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.star), Icon(Icons.star), Icon(Icons.star)], ); } else if (nilai == 75) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.star), Icon(Icons.star), Icon(Icons.star_border) ], ); } else if (nilai < 75) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.star), Icon(Icons.star_border), Icon(Icons.star_border) ], ); } else { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [Icon(Icons.lock)], ); } } } Center materiGrid(judul, nilai) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: EdgeInsets.all(5), child: Text( judul, style: TextStyle(color: Colors.white, fontSize: 12), ), ), Container( child: nilaiLock(nilai), ) ], )); } cek(List<Materis> data, index) { if (index == 0 && data[index].nilai[0].score == 102) { return Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => GameSatuScreen(materi_id: data[index].id))); } else if (index == 0) { return Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => GameSatuScreen(materi_id: data[index].id))); } else if (data[index - 1].nilai[0].score! != 102 && data[index - 1].nilai[0].score! >= 75) { return Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => GameSatuScreen(materi_id: data[index].id))); } else { return print("Ga Oke"); } } cekNilai(List<Materis> data, index) { if (index == 0 && data[index].nilai[0].score == 102) { return materiGrid(data[index].title, 102); } else if (index == 0) { return materiGrid(data[index].title, data[index].nilai[0].score); } else if (data[index - 1].nilai[0].score! != 102 && data[index - 1].nilai[0].score! >= 75) { return materiGrid(data[index].title, data[index].nilai[0].score); } else { return materiGrid(data[index].title, 101); } } @override Widget build(BuildContext context) { _materiList.removeWhere((element) => element.publish == "Draft"); if (_materiList.length == 0) { return Text("Data Tidak Ada"); } else { return Container( child: GridView.builder( itemCount: _materiList.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), itemBuilder: (ctx, index) { print(index); // ignore: unnecessary_null_comparison return TextButton( onPressed: () { cek(_materiList, index); }, child: Stack(children: [ Image.network( 'https://abrakadabar.yokya.id/storage/${_materiList[index].link_image}', ), Container(color: Colors.black45), cekNilai(_materiList, index), ])); }, )); } } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/daftar/DaftarGuruScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/model/User.dart'; import 'package:abrakadabar/screen/AppDrawer.dart'; import 'package:flutter/material.dart'; class DaftarGuruScreen extends StatefulWidget { DaftarGuruScreen({Key? key, required this.status}) : super(key: key); final String status; @override _DaftarGuruScreenState createState() => _DaftarGuruScreenState(); } class _DaftarGuruScreenState extends State<DaftarGuruScreen> { late Future<Users> usersBuffer; @override void initState() { super.initState(); usersBuffer = MateriAPI().fetchAllUsers({'status': widget.status}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Daftar Guru", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<Users>( future: usersBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return ShowUsersWidget( users: snapshot.data?.users, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), drawer: AppDrawer(), ); } } class ShowUsersWidget extends StatefulWidget { final users; ShowUsersWidget({Key? key, this.users}) : super(key: key); @override _ShowUsersWidgetState createState() => _ShowUsersWidgetState(); } class _ShowUsersWidgetState extends State<ShowUsersWidget> { late List<User> _userList; @override void initState() { super.initState(); _userList = widget.users; } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _userList.length, itemBuilder: (ctx, index) { return Card( child: ListTile( leading: Icon( Icons.supervised_user_circle, size: 50, ), title: Text('${_userList[index].fullName}'), subtitle: Text('@${_userList[index].username}'), ), ); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/daftar/DaftarSiswaScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/model/User.dart'; import 'package:abrakadabar/screen/AppDrawer.dart'; import 'package:flutter/material.dart'; class DaftarSiswaScreen extends StatefulWidget { DaftarSiswaScreen({Key? key, required this.status}) : super(key: key); final String status; @override _DaftarSiswaScreenState createState() => _DaftarSiswaScreenState(); } class _DaftarSiswaScreenState extends State<DaftarSiswaScreen> { late Future<Users> usersBuffer; @override void initState() { super.initState(); usersBuffer = MateriAPI().fetchAllUsers({'status': widget.status}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Daftar Siswa", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<Users>( future: usersBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return ShowUsersWidget( users: snapshot.data?.users, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), drawer: AppDrawer(), ); } } class ShowUsersWidget extends StatefulWidget { final users; ShowUsersWidget({Key? key, this.users}) : super(key: key); @override _ShowUsersWidgetState createState() => _ShowUsersWidgetState(); } class _ShowUsersWidgetState extends State<ShowUsersWidget> { late List<User> _userList; @override void initState() { super.initState(); _userList = widget.users; } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _userList.length, itemBuilder: (ctx, index) { return Card( child: ListTile( leading: Icon( Icons.supervised_user_circle, size: 50, ), title: Text('${_userList[index].fullName}'), subtitle: Text('@${_userList[index].username}'), ), ); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/daftar/DaftarGuruAdminScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:abrakadabar/model/User.dart'; import 'package:abrakadabar/screen/GuestDrawer.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:flutter/material.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; class DaftarGuruAdminScreen extends StatefulWidget { DaftarGuruAdminScreen({Key? key, required this.status}) : super(key: key); final String status; @override _DaftarGuruAdminScreenState createState() => _DaftarGuruAdminScreenState(); } class _DaftarGuruAdminScreenState extends State<DaftarGuruAdminScreen> { late Future<Users> usersBuffer; @override void initState() { super.initState(); usersBuffer = MateriAPI().fetchAllUsers({'status': widget.status}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Daftar", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<Users>( future: usersBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return ShowUsersWidget( users: snapshot.data?.users, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), drawer: GuestDrawer(), ); } } class ShowUsersWidget extends StatefulWidget { final users; ShowUsersWidget({Key? key, this.users}) : super(key: key); @override _ShowUsersWidgetState createState() => _ShowUsersWidgetState(); } class _ShowUsersWidgetState extends State<ShowUsersWidget> { late List<User> _userList; @override void initState() { super.initState(); _userList = widget.users; } Future delUser(BuildContext context, id) async { var result = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestDelUser({'id': id}))); if (result['status'] == true) { Navigator.pushNamed(context, '/home'); } } @override Widget build(BuildContext context) { return Container( child: ListView.builder( itemCount: _userList.length, itemBuilder: (ctx, index) { return Card( child: ListTile( leading: Icon( Icons.supervised_user_circle, size: 50, ), title: Text('${_userList[index].fullName}'), subtitle: Text('@${_userList[index].username}'), trailing: TextButton( child: Text( "Hapus", style: TextStyle(color: Colors.red), ), onPressed: () { AwesomeDialog( context: context, dialogType: DialogType.WARNING, headerAnimationLoop: false, animType: AnimType.TOPSLIDE, showCloseIcon: false, closeIcon: Icon(Icons.close_fullscreen_outlined), title: 'Hapus Akun ini?', desc: '${_userList[index].fullName}', btnCancelOnPress: () {}, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }, btnOkOnPress: () { delUser(context, _userList[index].ide); }) ..show(); }, )), ); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib/screen
mirrored_repositories/Abrakadabar-Flutter/lib/screen/daftar/DaftarGuruAdminUnScreen.dart
import 'package:abrakadabar/API/MateriApi.dart'; import 'package:abrakadabar/helper/Auth.dart'; import 'package:abrakadabar/model/User.dart'; import 'package:abrakadabar/screen/GuestDrawer.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; import 'package:flutter/material.dart'; import 'package:future_progress_dialog/future_progress_dialog.dart'; class DaftarGuruAdminUnScreen extends StatefulWidget { DaftarGuruAdminUnScreen({Key? key, required this.status}) : super(key: key); final String status; @override _DaftarGuruAdminUnScreenState createState() => _DaftarGuruAdminUnScreenState(); } class _DaftarGuruAdminUnScreenState extends State<DaftarGuruAdminUnScreen> { late Future<Users> usersBuffer; @override void initState() { super.initState(); usersBuffer = MateriAPI().fetchAllUsers({'status': widget.status}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( iconTheme: IconThemeData(color: Colors.white), title: Stack( alignment: Alignment.center, children: [ Container( alignment: Alignment.centerRight, color: Color.fromRGBO(29, 172, 234, 1), child: Image.asset( 'images/logo.png', width: 50, height: 50, ), ), Container( alignment: Alignment.centerLeft, margin: EdgeInsets.fromLTRB(0, 5, 0, 0), child: Text( "Daftar", style: TextStyle(color: Colors.white), ), ) ], ), ), body: Container( child: FutureBuilder<Users>( future: usersBuffer, builder: (context, snapshot) { if (snapshot.hasData) { return ShowUsersWidget( users: snapshot.data?.users, ); } else if (snapshot.hasError) { return Text("${snapshot.error}"); } return Center( child: CircularProgressIndicator(), ); })), drawer: GuestDrawer(), ); } } class ShowUsersWidget extends StatefulWidget { final users; ShowUsersWidget({Key? key, this.users}) : super(key: key); @override _ShowUsersWidgetState createState() => _ShowUsersWidgetState(); } class _ShowUsersWidgetState extends State<ShowUsersWidget> { late List<User> _userList; @override void initState() { super.initState(); _userList = widget.users; } Future accGuru(BuildContext context, id) async { var result = await showDialog( context: context, builder: (context) => FutureProgressDialog(Auth().requestAccGuru({'id': id}))); if (result['status'] == true) { Navigator.pushNamed(context, '/home'); } } @override Widget build(BuildContext context) { _userList.removeWhere((element) => element.cek == '1'); return Container( child: ListView.builder( itemCount: _userList.length, itemBuilder: (ctx, index) { return Card( child: ListTile( leading: Icon( Icons.supervised_user_circle, size: 50, ), title: Text('${_userList[index].fullName}'), subtitle: Text('@${_userList[index].username}'), trailing: TextButton( child: Text("Terima"), onPressed: () { AwesomeDialog( context: context, dialogType: DialogType.WARNING, headerAnimationLoop: false, animType: AnimType.TOPSLIDE, showCloseIcon: false, closeIcon: Icon(Icons.close_fullscreen_outlined), title: 'Terima Akun ini?', desc: 'Apakah kamu yakin mau Verifikasi akun ini sebagai guru?', btnCancelOnPress: () {}, onDissmissCallback: (type) { debugPrint('Dialog Dissmiss from callback $type'); }, btnOkOnPress: () { accGuru(context, _userList[index].ide); }) ..show(); }, )), ); }), ); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/helper/dio.dart
import 'package:dio/dio.dart'; Dio dio() { return new Dio(BaseOptions( baseUrl: "https://abrakadabar.yokya.id/api/", headers: { 'accept': 'application/json', 'Content-Type': 'multipart/form-data' })); }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/helper/Storage.dart
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class Storage { final storage = new FlutterSecureStorage(); final keyAuth = 'auth'; Future readToken() async { return await storage.read(key: keyAuth); } Future saveToken(token) async { await storage.write(key: keyAuth, value: token); } Future deleteToken() async { await storage.delete(key: keyAuth); } }
0
mirrored_repositories/Abrakadabar-Flutter/lib
mirrored_repositories/Abrakadabar-Flutter/lib/helper/Auth.dart
import 'package:abrakadabar/model/Materi.dart'; import 'package:dio/dio.dart' as Dio; import 'dio.dart'; import 'dart:convert'; import 'package:abrakadabar/helper/Storage.dart'; import 'package:flutter/material.dart'; import 'package:abrakadabar/model/User.dart'; class Auth extends ChangeNotifier { late User _user; late Materi _materi; bool _isAuthenticated = false; User get user => _user; Materi get materi => _materi; bool get isAuthenticated => _isAuthenticated; Future requestCheckMe() async { try { final token = await Storage().readToken(); final res = await dio().get('me', options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { _user = User.fromJson(json.decode(res.data)); _isAuthenticated = true; notifyListeners(); } } on Dio.DioError { _isAuthenticated = false; notifyListeners(); } } Future requestRegister(credentials) async { try { final res = await dio().post('register', data: credentials); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestLogin(credentials) async { try { final res = await dio().post('login', data: credentials); if (res.statusCode == 200) { final token = await json.decode(res.toString())['token']; await Storage().saveToken(token); final res2 = await dio().get('me', options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); _user = User.fromJson(json.decode(res2.data.toString())); notifyListeners(); _isAuthenticated = true; notifyListeners(); return { 'status': true, }; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestLogout() async { try { final token = await Storage().readToken(); final res = await dio().post('logout', options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { await Storage().deleteToken(); _isAuthenticated = false; notifyListeners(); return { 'status': true, }; } } on Dio.DioError catch (e) { return { 'status': false, 'error_msg': e.response, }; } } Future requestDetail(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('detail', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); final res2 = await dio().get('me', options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); _user = User.fromJson(json.decode(res2.data.toString())); notifyListeners(); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestAccGuru(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('accGuru', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); print(res.data); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestDelUser(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('user/del', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); print(res.data); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } // Materi Future requestAddMateri(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('materi/add', data: await credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { final res2 = await dio().post('materi', data: {'id': res.data['materi']}, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); _materi = Materi.input(res2.data); notifyListeners(); return {'status': true, 'id': res.data['materi']}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestCheckGambar(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('materi', data: credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { _materi = Materi.input(res.data); notifyListeners(); return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestAddSoal(credentials) async { try { print(credentials.toString()); final token = await Storage().readToken(); final res = await dio().post('soal/add', data: await credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } Future requestHapusMateri(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('materi/del', data: await credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } // Soal Future requestAddJawaban(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('jawaban/add', data: await credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return {'status': true}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } // Nilai Future requestNilai(credentials) async { try { final token = await Storage().readToken(); final res = await dio().post('nilai/add', data: await credentials, options: Dio.Options(headers: {'Authorization': 'Bearer $token'})); if (res.statusCode == 200) { return {'status': true, 'nilai': res.data['nilai']}; } } on Dio.DioError catch (e) { var _resError = ""; final _res = jsonDecode(e.response.toString())['errors']; _res.forEach((key, val) { _resError += "* " + val[0] + "\n"; }); return { 'status': false, 'error_msg': _resError, }; } } }
0
mirrored_repositories/Dictionary-App
mirrored_repositories/Dictionary-App/lib/main.dart
import 'package:flutter/material.dart'; import 'pages/homepage.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Dictionary', theme: ThemeData( primarySwatch: Colors.blueGrey ), home: Homepage(), ); } }
0
mirrored_repositories/Dictionary-App/lib
mirrored_repositories/Dictionary-App/lib/pages/about.dart
import 'package:flutter/material.dart'; class AboutPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xFF21BFBD), appBar: AppBar( title:Text("About Dictionary",style:TextStyle(color: Colors.white)), backgroundColor: Color(0xFF21BFBD), iconTheme: IconThemeData(color: Colors.white), elevation: 0, ), body: Stack( children: <Widget>[ Positioned( child: Center( child: Container( height: MediaQuery.of(context).size.height/2, width: MediaQuery.of(context).size.width-100, child: Card( color: Colors.white, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), child: Column( children: <Widget>[ SizedBox(height: 120,), Padding( padding: const EdgeInsets.symmetric(horizontal:30), child: Text("One of the first few apps I made while on my journey to learn flutter.", textAlign: TextAlign.center, ), ), SizedBox(height: 50,), Text("You can find the whole source code on",style:TextStyle(fontSize: 12,fontStyle: FontStyle.normal)), Text("github.com/ishandeveloper",style:TextStyle(fontSize: 14,fontWeight: FontWeight.bold)), SizedBox(height: 50,), Text("Made with ❤ by",style:TextStyle(fontSize: 12,fontStyle: FontStyle.normal)), Text("@ishandeveloper",style:TextStyle(fontSize: 20,fontWeight: FontWeight.bold)), Padding( padding: const EdgeInsets.symmetric(horizontal:25.0,vertical: 8.0), child: Text("A passionate learner and obsessive seeker of IT knowledge.", style:TextStyle(), textAlign: TextAlign.center,), ) ], ), ) ), ),), Align( alignment:Alignment.topCenter, child:Padding( padding: const EdgeInsets.symmetric(vertical:80.0), child: Container( height: 200, width: 200, child: CircleAvatar( backgroundImage: NetworkImage("http://www.ishandeveloper.com/2020%20[old]/assets/img/profile.JPG",), ), ), ), ) ], ), ); } }
0
mirrored_repositories/Dictionary-App/lib
mirrored_repositories/Dictionary-App/lib/pages/homepage.dart
import 'dart:async'; import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:http/http.dart'; import 'about.dart'; class Homepage extends StatefulWidget { @override _HomepageState createState() => _HomepageState(); } class _HomepageState extends State<Homepage> { TextEditingController searchcontroller=TextEditingController(); String token="0528f62586f9a7ba9af61d39314e0cc3bac1655b"; String url="https://owlbot.info/api/v4/dictionary/"; StreamController _streamController; Stream _stream; Timer typing; @override void initState(){ super.initState(); _streamController = StreamController(); _stream = _streamController.stream; } search() async { if (searchcontroller.text == null || searchcontroller.text.length == 0) { _streamController.add(null); return; } _streamController.add("waiting"); Response response = await get(url + searchcontroller.text.trim(), headers: {"Authorization": "Token " + token}); print(response.body); // if(json.decode(response.body)[0]["message"].!=null){ // print("Ouch"); // return; // } // print(json.decode(response.body)); _streamController.add(json.decode(response.body)); } Widget build(BuildContext context) { return Scaffold ( appBar: AppBar( elevation: 10, title: Text(" Dictionary",style: TextStyle(fontSize: 20),), actions: <Widget>[ Container( margin:EdgeInsets.only(right:10), child: Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( child: Icon(Icons.info), onTap: (){ Navigator.push(context, MaterialPageRoute(builder: (context)=>AboutPage() )); }, ), ), ) ], backgroundColor: Color(0xFF21BFBD), bottom: PreferredSize( preferredSize: Size.fromHeight(60), child: Row(children: <Widget>[ Expanded( child: Container( margin:EdgeInsets.only(left:15,right:10,bottom:10), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(50) ), child: TextFormField( decoration: InputDecoration( hintText: "Search for any word", contentPadding: EdgeInsets.only(left:24), border:InputBorder.none, ), onChanged: (String word){ if(typing?.isActive ?? false) typing.cancel(); typing=Timer(Duration(milliseconds: 1000),(){ search(); }); }, controller: searchcontroller, ), ), ), IconButton(icon: Icon(Icons.search,color: Colors.white,), onPressed: (){ search(); }, ) ], ), ), ), body:Container( margin:EdgeInsets.fromLTRB(0, 10, 0, 0), child: StreamBuilder( stream:_stream, builder: (BuildContext context, AsyncSnapshot snapshot){ if(snapshot.data==null){ return Center( child: Text("Come On, Search Something..."), ); } if (snapshot.data == "waiting") { return Center( child: CircularProgressIndicator( backgroundColor: Color(0xFF21BFBD), valueColor: AlwaysStoppedAnimation<Color>(Colors.white), ), ); } if(snapshot.data=="error"){ print("Error"); return Center(child: Text("Error"),); } if(snapshot.data["definitions"].length==0){ return Center(child: Text("Oops, couldn't find that word"),); } return ListView.builder( itemCount: snapshot.data["definitions"].length, itemBuilder: (context,int index){ return ListBody(children: <Widget>[ Container( color:Colors.grey[200], child: ListTile( leading: snapshot.data["definitions"][index]["image_url"]==null ? null : CircleAvatar(backgroundImage: NetworkImage(snapshot.data["definitions"][index]["image_url"]), ), title: Text(searchcontroller.text.trim() + " (" + snapshot.data["definitions"][index]["type"] + ")"), ) ), Padding( padding: const EdgeInsets.all(12.0), child: Text( snapshot.data["definitions"][index]["definition"],textAlign: TextAlign.justify ), ) ],); }); }, ), ) ); } }
0
mirrored_repositories/flutter_randomize
mirrored_repositories/flutter_randomize/lib/main.dart
import 'package:flutter/material.dart'; import 'package:shake/shake.dart'; import 'dart:math'; import 'package:english_words/english_words.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget {Widget build(c) => MaterialApp(home: Page());} class Page extends StatefulWidget {_PageState createState() => _PageState();} class _PageState extends State<Page> { int maxDepth = 15; initState() { super.initState(); ShakeDetector.autoStart(onPhoneShake: () {setState(() {});}); } @override Widget build(c) { return Scaffold( appBar: AppBar( backgroundColor: getRandColor(), title: Text("Randomize"), actions: <Widget>[ DropdownButton( onChanged: (v) { setState(() { maxDepth = v; }); }, items: List.generate(30, (v) { return DropdownMenuItem(child: Text("Allowed Depth: " + (v + 1).toString()), value: v + 1); }), value: maxDepth, ), InkWell( onTap: () => setState(() {}), child: Padding(padding: const EdgeInsets.all(8.0), child: Icon(Icons.refresh), ), ) ], ), body: ListView(children: [buildTopNode()]), floatingActionButton: FloatingActionButton.extended(onPressed: () {}, icon: buildIcon(0), label: buildText(0)), ); } buildTopNode() { var list = [buildListView, buildGridView, buildNode, buildPgView]; return Center(child: list[getRandNum(list.length)](getRandNum(list.length))); } buildNode(int i) { if (i > maxDepth) return buildText(i); var list = [buildHorizontalWrap, buildVertWrap, buildContainer, buildCPI, buildText, buildButton, buildCA, buildCard, buildIcon]; return Padding( padding: const EdgeInsets.all(8.0), child: Center(child: list[getRandNum(list.length)](i)), ); } buildPgView(int i) { int rand = getRandNum(10); return LayoutBuilder(builder: (c, constraints) { return Container( height: constraints.hasBoundedHeight ? null : MediaQuery.of(c).size.height - 70.0, child: PageView.builder( itemBuilder: (context, position) { return Padding( padding: const EdgeInsets.all(8.0), child: Card( elevation: 8.0, child: buildNode(i + 1), ), ); }, itemCount: rand == 0 ? 2 : rand, ), ); }); } buildListView(i) { int rand = getRandNum(10, zeroAllowed: false); return ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemBuilder: (c, p) => buildNode(i + 1), itemCount: rand == 0 ? 5 : rand, ); } buildGridView(i) { int gridColCnt = getRandNum(4, zeroAllowed: false); return GridView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemBuilder: (c, p) => buildNode(i + 1), itemCount: getRandNum(10, zeroAllowed: false), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: gridColCnt), ); } buildHorizontalWrap(i) { int num = getRandNum(5, zeroAllowed: false); List<Widget> list = []; for (int i = 0; i < num; i++) {list.add(buildNode(i + 1));} return FittedBox(child: Wrap(children: list)); } buildVertWrap(i) { int num = getRandNum(5, zeroAllowed: false); List<Widget> list = []; for (int i = 0; i < num; i++) { list.add(buildNode(i + 1)); } return FittedBox( child: Wrap(children: list, direction: Axis.vertical), ); } buildContainer(i) => Container(color: getRandColor(), child: buildNode(i + 1)); buildButton(i) => FlatButton(onPressed: () {}, child: buildNode(i + 1), color: getRandColor()); buildCPI(i) { if (i < 3) { return buildNode(i + 1); } return CircularProgressIndicator(backgroundColor: getRandColor()); } buildText(i) => Text(nouns[getRandNum(nouns.length)]); buildCard(i) { return Card( child: buildNode(i + 1), elevation: 8.0, color: getRandColor(), ); } buildCA(i) => CircleAvatar(backgroundColor: getRandColor(), child: buildNode(i + 1)); buildIcon(int i) { return Icon(IconData( OMIcons.codePoints.values.toList()[getRandNum(OMIcons.codePoints.values.toList().length)], fontFamily: 'outline_material_icons', fontPackage: 'outline_material_icons'), color: getRandColor()); } getRandNum(int max, {bool zeroAllowed = true}) { var num = Random().nextInt(max); return zeroAllowed ? num : num != 0 ? num : num + 1; } getRandColor() => Colors.primaries[getRandNum(Colors.primaries.length)]; }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/fasting_status_model.dart
// @todo needs test coverage class FastingStatus { FastingStatus(this._fastStartHour, this._fastStartMinute, this._fastEndHour, this._fastEndMinute); DateTime _dateTime = new DateTime.now(); final int _fastStartHour; final int _fastStartMinute; final int _fastEndHour; final int _fastEndMinute; DateTime get dateTime => _dateTime; DateTime get fastStart => new DateTime( _dateTime.year, _dateTime.month, _dateTime.day, _fastStartHour, _fastStartMinute ); DateTime get fastEnd => new DateTime( _dateTime.year, _dateTime.month, _dateTime.day, _fastEndHour, _fastEndMinute ); tick() => _dateTime = new DateTime.now(); isFasting() { if (_dateTime.isAfter(fastStart)) { return true; } if (dateTime.isBefore(fastEnd)) { return true; } return false; } // @todo this specifically needs coverage. Duration get timeUntilFastStarts => fastStart.difference(_dateTime); // @todo this specifically needs coverage. Duration get timeUntilFastEnds { if (_dateTime.hour < 12) { return fastEnd.difference(_dateTime); } return fastEnd.add(Duration(days: 1)).difference(_dateTime); } }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/profile_widget.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fasttrack/app_user.dart'; import 'package:fasttrack/time_picker_formfield.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; class ProfileWidget extends StatefulWidget { @override ProfileWidgetState createState() { return new ProfileWidgetState(); } } // @todo Convert to streambuilder. class ProfileWidgetState extends State<ProfileWidget> { final timeFormat = DateFormat("h:mm a"); final TextEditingController fastEndTextController = new TextEditingController(); final TextEditingController fastStartTextController = new TextEditingController(); TimeOfDay fastEnd; TimeOfDay fastStart; DocumentSnapshot account; @override void initState() { _loadData(); super.initState(); } // @todo this is broken from prefs -> firestore, move to FutureBuilder _loadData() async { QuerySnapshot accountDocuments = await Firestore.instance .collection('accounts') .where( "owner", isEqualTo: AppUser.currentUser.uid ) .getDocuments(); account = accountDocuments.documents.first; SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { fastEnd = new TimeOfDay( hour: account.data['fastEnd']['hour'] ?? 12, minute: account.data['fastEnd']['minute'] ?? 00, ); fastEndTextController.text = timeFormat.format(DateTime(0).add(Duration(hours: fastEnd.hour, minutes: fastEnd.minute))); fastStart = new TimeOfDay( hour: account.data['fastStart']['hour'] ?? 20, minute: account.data['fastStart']['minute'] ?? 00, ); fastStartTextController.text = timeFormat.format(DateTime(0).add(Duration(hours: fastStart.hour, minutes: fastStart.minute))); }); } _updateFastingTimeSetting(key, TimeOfDay value) async { SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { Firestore.instance.document(account.documentID).updateData({ '$key': { 'hour': value.hour, 'minute': value.minute }, }); }); } @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 20, ), Text( 'Profile', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 28), ), Form( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox(height: 20.0,), Text( "Eating schedule", style: TextStyle(fontWeight: FontWeight.bold) ), Row( children: <Widget>[ Expanded( child: TimePickerFormField( controller: fastEndTextController, format: timeFormat, decoration: InputDecoration(labelText: 'Start'), onChanged: (t) => setState(() { if (t != null) { fastEnd = t; _updateFastingTimeSetting('fastEnd', fastEnd); } }), ), ), SizedBox(width: 20,), Expanded( child: TimePickerFormField( controller: fastStartTextController, format: timeFormat, decoration: InputDecoration(labelText: 'End'), onChanged: (t) => setState(() { if (t != null) { fastStart = t; _updateFastingTimeSetting('fastStart', fastStart); } }), ), ), ], ), ], ), ) ], ), ); } }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/journal_widget.dart
import 'package:fasttrack/app_user.dart'; import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:intl/intl.dart'; class JournalWidget extends StatelessWidget { final whenDate = DateFormat.yMd().add_jm(); Widget _buildListItem(DocumentSnapshot data) { final record = Record.fromSnapshot(data); return ListTile( title: Text(record.weight.toString()), trailing: Text(whenDate.format(record.when.toLocal())), onLongPress: () => data.reference.delete(), ); } Widget _buildListView(List<DocumentSnapshot> snapshot) { return ListView( children: snapshot.map((data) => _buildListItem(data)).toList(), ); } Widget _buildList() { return StreamBuilder<QuerySnapshot>( stream: Firestore.instance .collection('testweights') .where( "owner", isEqualTo: AppUser.currentUser.uid ) .orderBy("when", descending: true) .snapshots(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) return new Text('Error: ${snapshot.error}'); if (snapshot.connectionState == ConnectionState.waiting) return LinearProgressIndicator(); return Expanded( child: _buildListView(snapshot.data.documents), ); }, ); } @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(8.0), child: Column( children: <Widget>[ SizedBox( height: 20, ), Text( 'Journal', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 28), ), _buildList() ], )); } } class Record { final double weight; final DateTime when; final String owner; final DocumentReference reference; Record.fromMap(Map<String, dynamic> map, {this.reference}) : assert(map['weight'] != null), assert(map['when'] != null), assert(map['owner'] != null), weight = map['weight'], when = map['when'], owner = map['owner']; Record.fromSnapshot(DocumentSnapshot snapshot) : this.fromMap(snapshot.data, reference: snapshot.reference); @override String toString() => "Record<$weight:$when:$owner>"; }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/time_picker_formfield.dart
// Taken from https://github.com/jifalops/datetime_picker_formfield // @todo make planned adjustments. Not 100% happy with how it works. import 'dart:async'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart' show DateFormat; import 'package:flutter/services.dart' show TextInputFormatter; DateFormat toDateFormat(TimeOfDayFormat format) { switch (format) { case TimeOfDayFormat.a_space_h_colon_mm: return DateFormat('a h:mm'); case TimeOfDayFormat.frenchCanadian: return DateFormat("HH 'h' mm"); case TimeOfDayFormat.H_colon_mm: return DateFormat('H:mm'); case TimeOfDayFormat.h_colon_mm_space_a: return DateFormat('h:mm a'); case TimeOfDayFormat.HH_colon_mm: return DateFormat('HH:mm'); case TimeOfDayFormat.HH_dot_mm: return DateFormat('HH.mm'); } return null; } /// A [FormField<TimeOfDay>] that uses a [TextField] to manage input. /// If it gains focus while empty, the time picker will be shown to the user. class TimePickerFormField extends FormField<TimeOfDay> { /// For representing the time as a string e.g. /// `DateFormat("h:mma")` (9:24pm). You can also use the helper function /// [toDateFormat(TimeOfDayFormat)]. final DateFormat format; /// If defined the TextField [decoration]'s [suffixIcon] will be /// overridden to reset the input using the icon defined here. /// Set this to `null` to stop that behavior. Defaults to [Icons.close]. final IconData resetIcon; /// Allow manual editing of the date/time. Defaults to true. If false, the /// picker(s) will be shown every time the field gains focus. final bool editable; /// For validating the [TimeOfDay]. The value passed will be `null` if /// [format] fails to parse the text. final FormFieldValidator<TimeOfDay> validator; /// Called when an enclosing form is saved. The value passed will be `null` /// if [format] fails to parse the text. final FormFieldSetter<TimeOfDay> onSaved; /// Called when an enclosing form is submitted. The value passed will be /// `null` if [format] fails to parse the text. final ValueChanged<TimeOfDay> onFieldSubmitted; final TextEditingController controller; final FocusNode focusNode; final InputDecoration decoration; final TextInputType keyboardType; final TextStyle style; final TextAlign textAlign; /// The initial value of the text field before user interaction. final TimeOfDay initialValue; /// The initial time prefilled in the picker dialog when it is shown. /// Defaults to noon. Explicitly set this to `null` to use the current time. final TimeOfDay initialTime; final bool autofocus; final bool obscureText; final bool autocorrect; final bool maxLengthEnforced; final int maxLines; final int maxLength; final List<TextInputFormatter> inputFormatters; final bool enabled; /// Called whenever the state's value changes, e.g. after the picker value /// has been selected or when the field loses focus. To listen for all text /// changes, use the [controller] and [focusNode]. final ValueChanged<TimeOfDay> onChanged; TimePickerFormField({ Key key, @required this.format, this.editable: true, this.onChanged, this.resetIcon: Icons.close, this.initialTime: const TimeOfDay(hour: 12, minute: 0), this.validator, this.onSaved, this.onFieldSubmitted, bool autovalidate: false, // TextField properties TextEditingController controller, FocusNode focusNode, this.initialValue, this.decoration: const InputDecoration(), this.keyboardType: TextInputType.text, this.style, this.textAlign: TextAlign.start, this.autofocus: false, this.obscureText: false, this.autocorrect: true, this.maxLengthEnforced: true, this.enabled, this.maxLines: 1, this.maxLength, this.inputFormatters, }) : controller = controller ?? TextEditingController(text: _toString(initialValue, format)), focusNode = focusNode ?? FocusNode(), super( key: key, autovalidate: autovalidate, validator: validator, onSaved: onSaved, builder: (FormFieldState<TimeOfDay> field) { // final _TimePickerTextFormFieldState state = field; }); @override _TimePickerTextFormFieldState createState() => _TimePickerTextFormFieldState(this); } class _TimePickerTextFormFieldState extends FormFieldState<TimeOfDay> { final TimePickerFormField parent; bool showResetIcon = false; String _previousValue = ''; _TimePickerTextFormFieldState(this.parent); @override void setValue(TimeOfDay value) { super.setValue(value); if (parent.onChanged != null) parent.onChanged(value); } @override void initState() { super.initState(); parent.focusNode.addListener(inputChanged); parent.controller.addListener(inputChanged); } @override void dispose() { parent.controller.removeListener(inputChanged); parent.focusNode.removeListener(inputChanged); super.dispose(); } void inputChanged() { final bool requiresInput = parent.controller.text.isEmpty && _previousValue.isEmpty && parent.focusNode.hasFocus; if (requiresInput) { getTimeInput(context, parent.initialTime).then(_setValue); } else if (parent.resetIcon != null && parent.controller.text.isEmpty == showResetIcon) { setState(() => showResetIcon = !showResetIcon); // parent.focusNode.unfocus(); } _previousValue = parent.controller.text; if (!parent.focusNode.hasFocus) { setValue(_toTime(_previousValue, parent.format)); } else if (!requiresInput && !parent.editable) { getTimeInput(context, _toTime(_previousValue, parent.format) ?? parent.initialTime) .then(_setValue); } } void _setValue(TimeOfDay time) { parent.focusNode.unfocus(); // When Cancel is tapped, retain the previous value if present. if (time == null && _previousValue.isNotEmpty) { time = _toTime(_previousValue, parent.format); } setState(() { parent.controller.text = _toString(time, parent.format); setValue(time); }); } Future<TimeOfDay> getTimeInput( BuildContext context, TimeOfDay initialTime) async { return await showTimePicker( context: context, initialTime: initialTime ?? TimeOfDay.now(), ); } @override Widget build(BuildContext context) { return TextFormField( controller: parent.controller, focusNode: parent.focusNode, decoration: parent.resetIcon == null ? parent.decoration : parent.decoration.copyWith( suffixIcon: showResetIcon ? IconButton( icon: Icon(parent.resetIcon), onPressed: () { parent.focusNode.unfocus(); _previousValue = ''; parent.controller.clear(); }, ) : Container(width: 0.0, height: 0.0), ), keyboardType: parent.keyboardType, style: parent.style, textAlign: parent.textAlign, autofocus: parent.autofocus, obscureText: parent.obscureText, autocorrect: parent.autocorrect, maxLengthEnforced: parent.maxLengthEnforced, maxLines: parent.maxLines, maxLength: parent.maxLength, inputFormatters: parent.inputFormatters, enabled: parent.enabled, onFieldSubmitted: (value) { if (parent.onFieldSubmitted != null) { return parent.onFieldSubmitted(_toTime(value, parent.format)); } }, validator: (value) { if (parent.validator != null) { return parent.validator(_toTime(value, parent.format)); } }, onSaved: (value) { if (parent.onSaved != null) { return parent.onSaved(_toTime(value, parent.format)); } }, ); } } String _toString(TimeOfDay time, DateFormat formatter) { if (time != null) { try { return formatter.format( DateTime(0).add(Duration(hours: time.hour, minutes: time.minute))); } catch (e) { debugPrint('Error formatting time: $e'); } } return ''; } TimeOfDay _toTime(String string, DateFormat formatter) { if (string != null && string.isNotEmpty) { try { var date = formatter.parse(string); return TimeOfDay(hour: date.hour, minute: date.minute); } catch (e) { debugPrint('Error parsing time: $e'); } } return null; }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/fasting_status_widget.dart
import 'dart:async'; import 'package:fasttrack/fasting_status_model.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; class FastingStatusWidget extends StatefulWidget { @override FastingStatusWidgetState createState() { return new FastingStatusWidgetState(); } } class FastingStatusWidgetState extends State<FastingStatusWidget> { Timer _timer; FastingStatus _fastingStatus; @override void initState() { _loadData(); super.initState(); } void callback(Timer timer) { setState(() { _fastingStatus.tick(); }); } void _loadData() async { SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { // @todo this moved to the account document for the user. _fastingStatus = new FastingStatus( prefs.getInt('fastStartHour') ?? 20, prefs.getInt('fastStartMinute') ?? 00, prefs.getInt('fastEndHour') ?? 12, prefs.getInt('fastEndMinute') ?? 00 ); _timer = new Timer.periodic(new Duration(seconds: 1), callback); }); } String twoDigits(int n) => (n >= 10) ? "$n" : "0$n"; String formatDuration(Duration d) { return "${d.inHours}:${twoDigits(d.inMinutes.remainder(Duration.minutesPerHour))}:${twoDigits(d.inSeconds.remainder(Duration.secondsPerMinute))}"; } @override Widget build(BuildContext context) { if (_fastingStatus == null) { return Center( child: Text("Loading..."), ); } double getProgressIndicatorValue() { Duration _entireDuration; double value; if (_fastingStatus.isFasting()) { _entireDuration = _fastingStatus.fastEnd.add(Duration(days: 1)).difference(_fastingStatus.fastStart); value = _fastingStatus.timeUntilFastEnds.inSeconds / _entireDuration.inSeconds; } else { _entireDuration = _fastingStatus.fastStart.difference(_fastingStatus.fastEnd); value = _fastingStatus.timeUntilFastStarts.inSeconds / _entireDuration.inSeconds; } return 1 - value; } return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Padding( padding: EdgeInsets.only(top: 10.0, bottom: 5.0), child: Text( 'Currently ${_fastingStatus.isFasting() ? 'fasting' : 'nosh time'}', style: Theme.of(context).textTheme.display1, ), ), Text( _fastingStatus.isFasting() ? 'Fast ends in ${formatDuration(_fastingStatus.timeUntilFastEnds)}' : 'Fasting begins in ${formatDuration(_fastingStatus.timeUntilFastStarts)}', style: Theme.of(context).textTheme.title, ), SizedBox( height: 50, ), SizedBox( child: CircularProgressIndicator( value: getProgressIndicatorValue(), strokeWidth: 15.0, valueColor: new AlwaysStoppedAnimation<Color>(_fastingStatus.isFasting() ? Colors.red : Colors.green), ), width: 200, height: 200, ) ] ), ); } @override void dispose() { _timer?.cancel(); _timer = null; super.dispose(); } }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/app_user.dart
import 'package:firebase_auth/firebase_auth.dart'; // @todo Find a better way to "share" the current user across widget tree. class AppUser { static FirebaseUser currentUser; }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/fast_track_icons_icons.dart
/// Flutter icons FastTrackIcons /// Copyright (C) 2019 by original authors @ fluttericon.com, fontello.com /// This font was generated by FlutterIcon.com, which is derived from Fontello. /// /// To use this font, place it in your fonts/ directory and include the /// following in your pubspec.yaml /// /// flutter: /// fonts: /// - family: FastTrackIcons /// fonts: /// - asset: fonts/FastTrackIcons.ttf /// /// /// import 'package:flutter/widgets.dart'; class FastTrackIcons { FastTrackIcons._(); static const _kFontFam = 'FastTrackIcons'; static const IconData fasting = const IconData(0xe800, fontFamily: _kFontFam); static const IconData journal = const IconData(0xe801, fontFamily: _kFontFam); static const IconData profile = const IconData(0xe802, fontFamily: _kFontFam); }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/lib/main.dart
import 'package:fasttrack/app_user.dart'; import 'package:fasttrack/fast_track_icons_icons.dart'; import 'package:fasttrack/fasting_status_widget.dart'; import 'package:fasttrack/journal_widget.dart'; import 'package:fasttrack/profile_widget.dart'; import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; final FirebaseAuth _auth = FirebaseAuth.instance; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { static FirebaseAnalytics analytics = FirebaseAnalytics(); static FirebaseAnalyticsObserver observer = FirebaseAnalyticsObserver(analytics: analytics); Widget _handleCurrentScreen() { return new StreamBuilder<FirebaseUser>( stream: _auth.onAuthStateChanged, builder: (BuildContext context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Scaffold( body: Center( child: Text('Loading!'), ), ); } else { if (snapshot.hasData) { print("Logged in ${snapshot.data.uid}"); AppUser.currentUser = snapshot.data; return FastingPage( title: 'Fast Track', analytics: analytics, observer: observer, ); } else { return Scaffold( body: Container( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 20, ), Text( 'Set up your profile', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 28), ), RaisedButton( child: Text("Save and get started"), onPressed: () { FirebaseAuth.instance.signInAnonymously().then((FirebaseUser firebaseUser) { Firestore.instance.collection('accounts').add({ 'startingWeight': 252.6, 'owner': firebaseUser.uid, 'fastStart': { 'hour': 20, 'minute': 00 }, 'fastEnd': { 'hour': 12, 'minute': 00 }, }); Firestore.instance.collection('testweights').add({ 'weight': 252.6, 'when': DateTime.now(), 'owner': firebaseUser.uid }); }); print("Sign in in as anonymous"); }, ) ], ), ), ); } } } ); } // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.indigo, ), home: _handleCurrentScreen(), ); } } class FastingPage extends StatefulWidget { FastingPage({Key key, this.title, this.analytics, this.observer}) : super(key: key); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect // how it looks. final String title; final FirebaseAnalytics analytics; final FirebaseAnalyticsObserver observer; @override _FastingPageState createState() => _FastingPageState(analytics, observer); } class _FastingPageState extends State<FastingPage> { _FastingPageState(this.analytics, this.observer); double _currentWeight = 252.6; int _currentIndex = 0; final List<Widget> _children = [ FastingStatusWidget(), JournalWidget(), ProfileWidget() ]; final FirebaseAnalyticsObserver observer; final FirebaseAnalytics analytics; @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return Scaffold( bottomNavigationBar: BottomNavigationBar( currentIndex: _currentIndex, iconSize: 28, items: [ BottomNavigationBarItem( icon: const Icon(FastTrackIcons.fasting), title: const Text('Fasting'), ), BottomNavigationBarItem( icon: const Icon(FastTrackIcons.journal), title: const Text('Journal'), ), const BottomNavigationBarItem( icon: const Icon(FastTrackIcons.profile), title: const Text('Profile')) ], onTap: (int index) { setState(() { List<String> _screenNames = [ 'Fasting', 'Journal', 'Profile', ]; analytics.setCurrentScreen( screenName: _screenNames[index] ); _currentIndex = index; }); }, ), body: SafeArea( child: _children[_currentIndex], ), floatingActionButtonAnimator: NoScalingAnimation(), floatingActionButton: _currentIndex == 2 ? null : Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Padding( padding: EdgeInsets.only(bottom: 8.0), child: FloatingActionButton( heroTag: 'logFood', tooltip: 'Log food', mini: true, child: Icon(Icons.add), backgroundColor: Theme.of(context).accentColor, onPressed: () async { await showDialog( context: context, builder: (BuildContext buildContext) => new AlertDialog( title: const Text('Log food?'), content: const Text( "Track when you eat during the day, and if track if you break your fast."), actions: <Widget>[ new FlatButton( onPressed: () { Navigator.of(buildContext) .pop('cancel'); }, child: const Text("Cancel")), new FlatButton( onPressed: () => Navigator.of(buildContext).pop('food'), child: Text("I ate!",)) ], )).then((value) => {}); }, ), ), FloatingActionButton( heroTag: 'logWeight', tooltip: 'Log weight', child: Icon(Icons.assessment), onPressed: () async { await showDialog( context: context, builder: (BuildContext buildContext) => new NumberPickerDialog.decimal( title: const Text('Log weight'), minValue: 100, maxValue: 500, decimalPlaces: 1, initialDoubleValue: _currentWeight, )).then((value) { if (value != null) { if (value is double) { setState(() { _currentWeight = value; Firestore.instance.collection('testweights').add({ 'weight': value, 'when': DateTime.now(), 'owner': AppUser.currentUser.uid }); }); } } }); }), ], )); } } class NoScalingAnimation extends FloatingActionButtonAnimator{ double _x; double _y; @override Offset getOffset({Offset begin, Offset end, double progress}) { _x = begin.dx +(end.dx - begin.dx)*progress ; _y = begin.dy +(end.dy - begin.dy)*progress; return Offset(_x,_y); } @override Animation<double> getRotationAnimation({Animation<double> parent}) { return Tween<double>(begin: 1.0, end: 1.0).animate(parent); } @override Animation<double> getScaleAnimation({Animation<double> parent}) { return Tween<double>(begin: 1.0, end: 1.0).animate(parent); } }
0
mirrored_repositories/fasttrack
mirrored_repositories/fasttrack/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:fasttrack/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Cu-urls
mirrored_repositories/Cu-urls/lib/main.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:loading/indicator/line_scale_pulse_out_indicator.dart'; import 'package:loading/loading.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() => runApp(MaterialApp( theme: ThemeData(brightness: Brightness.light, fontFamily: 'Oxygen'), debugShowCheckedModeBanner: false, home: Splash_Screen(), )); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> with WidgetsBindingObserver { @override String _phoneNumber = "", _email = "", _devFolio = "", _github = "", _linkedIn = "", _stackOverflow = "", _resume = "", _website = "", _address = ""; final globalKey = GlobalKey<ScaffoldState>(); void initState() { super.initState(); fetchValues(); } Future<String> fetchValues() async { SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { _devFolio = prefs.getString('_devFolio'); _github = prefs.getString('_github'); _linkedIn = prefs.getString('_linkedIn'); _stackOverflow = prefs.getString('_stackOverflow'); _email = prefs.getString('_email'); _phoneNumber = prefs.getString('_phoneNumber'); _resume = prefs.getString('_resume'); _website = prefs.getString('_website'); _address = prefs.getString('_address'); }); } void addStringToSP(String _df, String _gh, String _ll, String _so, String _e, String _p, String _r, String _w, String _a) async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('_devFolio', _df); prefs.setString('_github', _gh); prefs.setString('_linkedIn', _ll); prefs.setString('_stackOverflow', _so); prefs.setString('_email', _e); prefs.setString('_phoneNumber', _p); prefs.setString('_resume', _r); prefs.setString('_website', _w); prefs.setString('_address', _a); } Widget build(BuildContext context) { return Scaffold( key: globalKey, body: CustomScrollView(slivers: <Widget>[ SliverAppBar( expandedHeight: 220.0, backgroundColor: Colors.transparent, flexibleSpace: FlexibleSpaceBar( background: Container( width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(30.0), bottomRight: Radius.circular(30.0)), gradient: LinearGradient( begin: Alignment.topCenter, colors: [ Colors.blue[900], Colors.blue[800], Colors.blue[400] ], ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 80.0, ), Padding( padding: EdgeInsets.all(30.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( 'Cu-urls', style: TextStyle( color: Colors.white, fontSize: 40.0, fontWeight: FontWeight.w900), ), SizedBox( height: 10.0, ), Text( 'Keep all of your profile links handy ! ', style: TextStyle(color: Colors.white, fontSize: 18.0), ), ], ), ), ]), ), ), ), Container( child: SliverFixedExtentList( itemExtent: 950, delegate: SliverChildListDelegate([ Form( child: Container( width: double.infinity, decoration: BoxDecoration( color: Colors.white, ), child: Padding( padding: EdgeInsets.all(20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ SizedBox( height: 20.0, ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _devFolio), decoration: InputDecoration( hintText: 'Dev Folio', border: InputBorder.none, hintStyle: TextStyle( fontSize: 23.0, color: Colors.grey)), onChanged: (val) { // setState(() { // // }); _devFolio = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _github), decoration: InputDecoration( hintText: 'Github', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _github = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _linkedIn), decoration: InputDecoration( hintText: 'LinkedIn', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _linkedIn = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _stackOverflow), decoration: InputDecoration( hintText: 'Stack Overflow', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _stackOverflow = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( keyboardType: TextInputType.emailAddress, style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _email), decoration: InputDecoration( hintText: 'Email', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0)), onChanged: (val) { _email = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( keyboardType: TextInputType.phone, style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _phoneNumber), decoration: InputDecoration( hintText: 'Phone', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _phoneNumber = val.toString(); }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _resume), decoration: InputDecoration( hintText: 'Resume Link', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _resume = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _website), decoration: InputDecoration( hintText: 'Website', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _website = val; }, ), ), Container( margin: EdgeInsets.only(bottom: 10.0), padding: EdgeInsets.all(15.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: Colors.blue[100], blurRadius: 20.0, offset: Offset(0, 10)) ]), child: TextField( style: TextStyle( color: Colors.black, fontSize: 23.0), controller: TextEditingController(text: _address), decoration: InputDecoration( hintText: 'Address', border: InputBorder.none, hintStyle: TextStyle( color: Colors.grey, fontSize: 23.0, )), onChanged: (val) { _address = val; }, ), ), ], ), ), ), ), ])), ), ]), floatingActionButton: Container( decoration: BoxDecoration( color: Colors.blue[900], borderRadius: BorderRadius.all(Radius.circular(30.0))), child: FlatButton.icon( label: Text( 'Update', style: TextStyle(color: Colors.white, fontSize: 17.0), ), onPressed: () async { var snackBar; SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { addStringToSP(_devFolio, _github, _linkedIn, _stackOverflow, _email, _phoneNumber, _resume, _website, _address); if (prefs.get('_devFolio') == _devFolio && prefs.get('_github') == _github && prefs.get('_linkedIn') == _linkedIn && prefs.get('_stackOverflow') == _stackOverflow && prefs.get('_email') == _email && prefs.get('_phoneNumber') == _phoneNumber && prefs.get('_resume') == _resume && prefs.get('_address') == _address && prefs.get('_website') == _website) { snackBar = SnackBar( backgroundColor: Colors.grey[900], content: Text( 'You did not update any new data', style: TextStyle(color: Colors.white, fontSize: 15.0), )); } else { snackBar = SnackBar( backgroundColor: Colors.grey[900], content: Text( 'Awesome urls updated !', style: TextStyle(color: Colors.white, fontSize: 15.0), )); } globalKey.currentState.showSnackBar(snackBar); }); }, icon: Icon( Icons.sync, color: Colors.white, ), ), ), ); } } class Splash_Screen extends StatefulWidget { @override _Splash_ScreenState createState() => _Splash_ScreenState(); } class _Splash_ScreenState extends State<Splash_Screen> { void initState() { super.initState(); Future.delayed(Duration(seconds: 4), () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (BuildContext context) => MyApp())); }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( child: Image( image: AssetImage('assets/images/splash.png'), ), ), SizedBox( height: 20.0, ), Text( 'Welcome to ', style: TextStyle(fontSize: 36.0, color: Colors.grey[900]), ), Text( 'Cu-urls', style: TextStyle(fontSize: 40.0, color: Colors.blue[900]), ), Text( 'All your digital links at one place !', style: TextStyle( fontSize: 20.0, color: Colors.grey[700], ), ), SizedBox( height: 20.0, ), Loading( indicator: LineScalePulseOutIndicator(), size: 60.0, color: Colors.blue[900]), ], ), ); } }
0
mirrored_repositories/Cu-urls
mirrored_repositories/Cu-urls/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:my_url_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib/main.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import './providers/movieprovider.dart'; import './screens/dashboard.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (_) => MovieProvider(), child: MaterialApp( title: 'Asssignment1', debugShowCheckedModeBanner: false, theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.grey, fontFamily: 'Oswald', ), home: Dashboard(), ), ); } }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib/widgets/moviecard.dart
import 'package:flutter/material.dart'; // import '../providers/movieprovider.dart'; import '../models/moviemodel.dart'; class MovieCard extends StatelessWidget { final List<MovieModel> movies; final bool isPortraid; final double height; final double width; MovieCard({ required this.movies, required this.isPortraid, required this.height, required this.width, }); @override Widget build(BuildContext context) { return ListView.builder( itemBuilder: (_, idx) { String genre = movies[idx].genre.join(' | '); double rating = double.parse(movies[idx].imdbstar); return Column( children: [ Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all( Radius.circular(10), ), ), elevation: 8, child: Padding( padding: EdgeInsets.all(15), child: Row( children: [ Image( image: NetworkImage( movies[idx].imageuri, ), fit: BoxFit.cover, width: isPortraid ? width * 0.3 : width * 0.23, height: isPortraid ? height * 0.15 : height * 0.25, ), SizedBox( width: width * 0.05, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: width * 0.41, child: Text( movies[idx].name, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, ), overflow: TextOverflow.fade, // softWrap: true, ), ), Container( width: width * 0.41, child: Text( genre, style: TextStyle( color: Colors.black45, fontSize: 12, ), overflow: TextOverflow.fade, ), ), Container( width: isPortraid ? width * 0.18 : width * 0.09, height: isPortraid ? height * 0.02 : height * 0.045, child: Text( '${movies[idx].imdbstar} IMDB', textAlign: TextAlign.center, style: TextStyle(color: Colors.white), ), decoration: BoxDecoration( color: rating > 6.9 ? Colors.green : Colors.blue, borderRadius: BorderRadius.all(Radius.circular(20)), ), ), ], ), ], ), ), ), SizedBox( height: height * 0.01, ), ], ); }, itemCount: movies.length, ); } }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib/widgets/searchbar.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/movieprovider.dart'; // import '../models/moviemodel.dart'; class SearchBar extends StatelessWidget { final TextEditingController textEditingController; SearchBar({ required this.textEditingController, }); @override Widget build(BuildContext context) { final moviehandle = Provider.of<MovieProvider>(context, listen: false); return TextField( // autofocus: true, decoration: InputDecoration( contentPadding: EdgeInsets.all(0), border: OutlineInputBorder( borderSide: BorderSide( color: Colors.black12, )), prefix: SizedBox( width: 20, ), suffixIcon: InkWell( onTap: () { try { moviehandle.loadStateHandler(false); moviehandle.errorStateHandler(false); moviehandle.getData(textEditingController.text).then((value) { moviehandle.loadStateHandler(true); moviehandle.errorStateHandler(false); }, onError: (e) { moviehandle.loadStateHandler(true); moviehandle.errorStateHandler(true); }); } catch (e) { moviehandle.loadStateHandler(true); moviehandle.errorStateHandler(true); } }, child: Icon(Icons.search)), filled: true, fillColor: Colors.white10, hintText: 'Search for movies', ), controller: textEditingController, onSubmitted: (val) { try { moviehandle.loadStateHandler(false); moviehandle.errorStateHandler(false); moviehandle.getData(textEditingController.text).then((value) { moviehandle.loadStateHandler(true); moviehandle.errorStateHandler(false); }, onError: (e) { moviehandle.loadStateHandler(true); moviehandle.errorStateHandler(true); }); } catch (e) { moviehandle.loadStateHandler(true); moviehandle.errorStateHandler(true); } }, ); } }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib/models/moviemodel.dart
class MovieModel { final String name; final String imageuri; final String imdbstar; final List<dynamic> genre; MovieModel({ required this.name, required this.imageuri, required this.imdbstar, required this.genre, }); }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib/screens/dashboard.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import '../models/moviemodel.dart'; import '../providers/movieprovider.dart'; import '../widgets/moviecard.dart'; import '../widgets/searchbar.dart'; class Dashboard extends StatefulWidget { Dashboard({Key? key}) : super(key: key); @override _DashboardState createState() => _DashboardState(); } class _DashboardState extends State<Dashboard> { late double height, width; late TextEditingController textEditingController; late var isPortraid; void snackBar(String msg, int seconds) { try { final snackBar = SnackBar( duration: Duration(seconds: seconds), content: Text( msg, style: TextStyle(fontSize: 15), // textAlign: TextAlign.center, ), action: SnackBarAction( label: 'Hide', onPressed: () { ScaffoldMessenger.of(context).hideCurrentSnackBar(); }, ), ); ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of( context, ).showSnackBar( snackBar, ); } catch (e) { print('snackbar context not found'); } } @override void initState() { textEditingController = TextEditingController(); textEditingController.text = ''; SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]); SystemChrome.setEnabledSystemUIOverlays([]); Future.delayed(Duration.zero, () { try { snackBar('Loaded dummy data', 2); } catch (e) { print(e); } }); super.initState(); } @override void dispose() { SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); super.dispose(); } @override Widget build(BuildContext context) { final moviehandle = Provider.of<MovieProvider>(context); final List<MovieModel> movies = moviehandle.items; var mq = MediaQuery.of(context); isPortraid = mq.orientation == Orientation.portrait; height = mq.size.height; width = mq.size.width; bool _loaded = moviehandle.loadState; bool _error = moviehandle.errorState; return Scaffold( // appBar: AppBar( // title: Text('Home'), // ), body: SingleChildScrollView( child: Padding( padding: EdgeInsets.only( top: height * 0.04, left: width * 0.07, right: width * 0.07, ), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( 'Home', style: TextStyle( fontSize: 25, fontWeight: FontWeight.bold, ), ), ), SizedBox( height: height * 0.03, ), _loaded ? SearchBar( textEditingController: textEditingController, ) : Container(), SizedBox( height: height * 0.03, ), _loaded ? Container( height: isPortraid ? height * 0.8 : height * 0.69, width: double.infinity, child: movies.length > 0 ? MovieCard( movies: movies, isPortraid: isPortraid, height: height, width: width, ) : _error ? Center( child: Text( 'Error occured', style: TextStyle( color: Colors.black45, fontWeight: FontWeight.bold, fontSize: 25, ), ), ) : Center( child: Text( 'No content available', style: TextStyle( color: Colors.black45, fontWeight: FontWeight.bold, fontSize: 25, ), ), ), ) : Container( height: height * 0.8, child: Center( child: CircularProgressIndicator(), ), ), ], ), ), ), ); } }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib
mirrored_repositories/flutter-movie-recommendation-app/assignment1/lib/providers/movieprovider.dart
import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '../models/moviemodel.dart'; class MovieProvider with ChangeNotifier { bool _error = false; bool _loaded = true; List<MovieModel> _movies = [ //dummy data MovieModel( name: 'Shaadi Mein Zaroor Aana', imageuri: 'https://m.media-amazon.com/images/M/MV5BODFkMDRjMWQtNDllMC00NjMwLWFlYzQtMWY5YWFkM2Y1NzhlXkEyXkFqcGdeQXVyNzkxOTEyMjI@._V1_.jpg', imdbstar: '7.6', genre: ["Drama", "Romance"], ), MovieModel( name: 'Shaadisthan', imageuri: 'https://m.media-amazon.com/images/M/MV5BMWZjMjk5YWQtNTFkOC00N2VmLWJlOTUtYWU5MGFkZTc1MGI5XkEyXkFqcGdeQXVyMTI1NDAzMzM0._V1_.jpg', imdbstar: '5.8', genre: ["Drama", "Musical"], ), MovieModel( name: 'Band Baaja Baaraat', imageuri: 'https://m.media-amazon.com/images/M/MV5BOTJlMWYwYTYtZGFjYS00NmY1LWFhNGEtNWMxZTVmZGY1N2MwXkEyXkFqcGdeQXVyNTkzNDQ4ODc@._V1_.jpg', imdbstar: '7.2', genre: ["Comedy", "Drama", "Romance"], ), MovieModel( name: 'Shaadi Mubarak', imageuri: 'https://m.media-amazon.com/images/M/MV5BZTQ3MWQzNTgtNTAwZC00MmVhLThlZTktZmYwM2M2NzIyMTAxXkEyXkFqcGdeQXVyNTgxODY5ODI@._V1_.jpg', imdbstar: '7.1', genre: ["Comedy", "Romance"], ), ]; List<MovieModel> get items { return [..._movies]; } bool get loadState { return _loaded; } bool get errorState { return _error; } void errorStateHandler(bool val) { _error = val; notifyListeners(); } void loadStateHandler(bool val) { _loaded = val; notifyListeners(); } Future<void> getData(String query) async { var url = Uri.parse('http://breezing.me:8000/getinfo'); try { final resp = await http.post(url, headers: {'Content-Type': 'application/json; charset=UTF-8'}, body: json.encode({ 'movie': query, })); final decodedResp = json.decode(resp.body); List<MovieModel> retrived = []; decodedResp.forEach((elem) { List genres = elem['moviedata']['genre']; int till = 3; if (genres.length <= 3) { till = genres.length; } retrived.add(MovieModel( name: elem['name'], imageuri: elem['imgurl'], imdbstar: elem['moviedata']['imdb'], genre: genres.sublist(0, till), )); }); _movies = retrived; notifyListeners(); } catch (e) { // print(e); throw 'error occured'; } } }
0
mirrored_repositories/flutter-movie-recommendation-app/assignment1
mirrored_repositories/flutter-movie-recommendation-app/assignment1/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:assignment1/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/wastewizardpp
mirrored_repositories/wastewizardpp/lib/routes.dart
import 'package:myapp/about/about.dart'; import 'package:myapp/articles/article1.dart'; import 'package:myapp/articles/article2.dart'; import 'package:myapp/articles/article3.dart'; import 'package:myapp/drawerScreens/help.dart'; import 'package:myapp/drawerScreens/notifications.dart'; import 'package:myapp/drawerScreens/privacy.dart'; import 'package:myapp/drawerScreens/statistics.dart'; import 'package:myapp/profile/profile.dart'; import 'package:myapp/login/login.dart'; import 'package:myapp/sideFunctions/calendar.dart'; import 'package:myapp/sideFunctions/carbon.dart'; import 'package:myapp/sideFunctions/depot_map.dart'; import 'package:myapp/topics/topics.dart'; import 'package:myapp/topics/scanHistoryFull.dart'; import 'package:myapp/home/home.dart'; import 'drawerScreens/settings.dart'; var appRoutes = { '/': (context) => const HomeScreen(), '/login': (context) => const LoginScreen(), '/topics': (context) => const TopicsScreen(), '/profile': (context) => const ProfileScreen(), '/about': (context) => const AboutScreen(), '/scanHistory': (context) => const ScanHistoryFull(), '/Local Waste Depots': (context) => const MapScreen(), '/Pickup Schedule': (context) => const Calendar(), '/settings': (context) => const SettingsScreen(), '/statistics': (context) => const StatScreen(), '/noti': (context) => const NotificationScreen(), '/privacy': (context) => const PrivacyScreen(), '/help': (context) => const HelpScreen(), '/assets/cover1.jpg': (context) => const Article1(), '/assets/cover2.jpg': (context) => const Article2(), '/assets/cover3.jpg': (context) => const Article3(), '/My Carbon Savings': (context) => const CarbonScreen(), };
0
mirrored_repositories/wastewizardpp
mirrored_repositories/wastewizardpp/lib/theme.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; var appTheme = ThemeData( fontFamily: GoogleFonts.nunito().fontFamily, bottomAppBarTheme: const BottomAppBarTheme( color: Colors.black87, ), brightness: Brightness.light, textTheme: const TextTheme( bodyText1: TextStyle(fontSize: 18), bodyText2: TextStyle(fontSize: 16), button: TextStyle( letterSpacing: 1.5, fontWeight: FontWeight.bold, ), headline1: TextStyle( fontWeight: FontWeight.bold, ), subtitle1: TextStyle( color: Colors.grey, ), ), buttonTheme: const ButtonThemeData(), );
0
mirrored_repositories/wastewizardpp
mirrored_repositories/wastewizardpp/lib/main.dart
import 'package:flutter/material.dart'; // Import the firebase_core plugin import 'package:firebase_core/firebase_core.dart'; import 'package:myapp/routes.dart'; import 'package:myapp/services/firestore.dart'; import 'package:myapp/services/models.dart'; import 'package:myapp/theme.dart'; import 'package:provider/provider.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(App()); } /// We are using a StatefulWidget such that we only create the [Future] once, /// no matter how many times our widget rebuild. /// If we used a [StatelessWidget], in the event where [App] is rebuilt, that /// would re-initialize FlutterFire and make our application re-enter loading state, /// which is undesired. class App extends StatefulWidget { // Create the initialization Future outside of `build`: @override _AppState createState() => _AppState(); } class _AppState extends State<App> { /// The future is part of the state of our widget. We should not call `initializeApp` /// directly inside [build]. final Future<FirebaseApp> _initialization = Firebase.initializeApp(); @override Widget build(BuildContext context) { return FutureBuilder( // Initialize FlutterFire: future: _initialization, builder: (context, snapshot) { // Check for errors if (snapshot.hasError) { return const Directionality( textDirection: TextDirection.ltr, child: Text('error'), ); } // Once complete, show your application if (snapshot.connectionState == ConnectionState.done) { return StreamProvider( create: (_) => FirestoreService().streamReport(), initialData: Report(), child: MaterialApp( routes: appRoutes, theme: appTheme, ), ); } // Otherwise, show something whilst waiting for initialization to complete return const Directionality( textDirection: TextDirection.ltr, child: Text('loading'), ); }, ); } }
0
mirrored_repositories/wastewizardpp/lib
mirrored_repositories/wastewizardpp/lib/shared/loading.dart
import 'package:flutter/material.dart'; class Loader extends StatelessWidget { const Loader({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const SizedBox( width: 250, height: 250, child: CircularProgressIndicator(), ); } } class LoadingScreen extends StatelessWidget { const LoadingScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Scaffold( body: Center( child: Loader(), ), ); } }
0