repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/model/mail_model.dart
// ignore_for_file: non_constant_identifier_names import 'package:json_annotation/json_annotation.dart'; part 'mail_model.g.dart'; @JsonSerializable() class MailModel { String? message; String? userid; List<Emails>? emails; MailModel({this.message, this.userid, this.emails}); factory MailModel.fromJson(Map<String, dynamic> json) => _$MailModelFromJson(json); Map<String, dynamic> toJson() => _$MailModelToJson(this); } @JsonSerializable() class Emails { String? user_id; String? user_name; String? user_email; String? user_photo; String ? my_id; String? id; String? read_it; String? title; String? content; String? date; Emails( {this.user_id, this.user_name, this.user_email, this.user_photo, this.my_id, this.id, this.read_it, this.title, this.content, this.date}); factory Emails.fromJson(Map<String, dynamic> json) => _$EmailsFromJson(json); Map<String, dynamic> toJson() => _$EmailsToJson(this); }
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/model/mail_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'mail_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** MailModel _$MailModelFromJson(Map<String, dynamic> json) { return MailModel( message: json['message'] as String?, userid: json['userid'] as String?, emails: (json['emails'] as List<dynamic>?) ?.map((e) => Emails.fromJson(e as Map<String, dynamic>)) .toList(), ); } Map<String, dynamic> _$MailModelToJson(MailModel instance) => <String, dynamic>{ 'message': instance.message, 'userid': instance.userid, 'emails': instance.emails, }; Emails _$EmailsFromJson(Map<String, dynamic> json) { return Emails( user_id: json['user_id'] as String?, user_name: json['user_name'] as String?, user_email: json['user_email'] as String?, user_photo: json['user_photo'] as String?, my_id: json['my_id'] as String?, id: json['id'] as String?, read_it: json['read_it'] as String?, title: json['title'] as String?, content: json['content'] as String?, date: json['date'] as String?, ); } Map<String, dynamic> _$EmailsToJson(Emails instance) => <String, dynamic>{ 'user_id': instance.user_id, 'user_name': instance.user_name, 'user_email': instance.user_email, 'user_photo': instance.user_photo, 'my_id': instance.my_id, 'id': instance.id, 'read_it': instance.read_it, 'title': instance.title, 'content': instance.content, 'date': instance.date, };
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/service/mail_service.dart
import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import '../model/mail_model.dart'; import 'i_mail_service.dart'; import 'mail_service_end_points.dart'; class MailService extends IMailService { MailService(Dio dio) : super(dio); @override Future<MailModel> fetchAllTask(String token, String category) async { if (category == "") { final response = await dio.get(MailServiceEndPoints.send.rawValue(token, category)); if (response.statusCode == HttpStatus.ok) { return MailModel.fromJson(jsonDecode(response.data)); } } else { final response = await dio.get(MailServiceEndPoints.email.rawValue(token, category)); if (response.statusCode == HttpStatus.ok) { return MailModel.fromJson(jsonDecode(response.data)); } } return MailModel(); } }
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/service/i_mail_service.dart
import 'package:dio/dio.dart'; import '../model/mail_model.dart'; abstract class IMailService { final Dio dio; IMailService(this.dio); Future<MailModel> fetchAllTask(String token,String category); }
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/service/mail_service_end_points.dart
enum MailServiceEndPoints { email,send } extension MailServiceExtension on MailServiceEndPoints { String rawValue(String token,String category) { switch (this) { case MailServiceEndPoints.email: return 'Email/get_incoming_email?token=$token&category=$category'; case MailServiceEndPoints.send: return 'Email/get_send_email?token=$token'; } } }
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/viewmodel/mail_view_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'mail_view_model.dart'; // ************************************************************************** // StoreGenerator // ************************************************************************** // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$MailViewModel on _MailViewModelBase, Store { final _$isContainerHeightChangeAtom = Atom(name: '_MailViewModelBase.isContainerHeightChange'); @override bool get isContainerHeightChange { _$isContainerHeightChangeAtom.reportRead(); return super.isContainerHeightChange; } @override set isContainerHeightChange(bool value) { _$isContainerHeightChangeAtom .reportWrite(value, super.isContainerHeightChange, () { super.isContainerHeightChange = value; }); } final _$itemsAtom = Atom(name: '_MailViewModelBase.items'); @override MailModel get items { _$itemsAtom.reportRead(); return super.items; } @override set items(MailModel value) { _$itemsAtom.reportWrite(value, super.items, () { super.items = value; }); } final _$fetchItemsAsyncAction = AsyncAction('_MailViewModelBase.fetchItems'); @override Future<void> fetchItems(String token, String category) { return _$fetchItemsAsyncAction.run(() => super.fetchItems(token, category)); } final _$_MailViewModelBaseActionController = ActionController(name: '_MailViewModelBase'); @override void changeContainerHeight() { final _$actionInfo = _$_MailViewModelBaseActionController.startAction( name: '_MailViewModelBase.changeContainerHeight'); try { return super.changeContainerHeight(); } finally { _$_MailViewModelBaseActionController.endAction(_$actionInfo); } } @override String toString() { return ''' isContainerHeightChange: ${isContainerHeightChange}, items: ${items} '''; } }
0
mirrored_repositories/crm_app/lib/feature/home/mail
mirrored_repositories/crm_app/lib/feature/home/mail/viewmodel/mail_view_model.dart
import '../../../../core/init/network/network_manager.dart'; import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import '../model/mail_model.dart'; import '../service/i_mail_service.dart'; import '../service/mail_service.dart'; part 'mail_view_model.g.dart'; class MailViewModel = _MailViewModelBase with _$MailViewModel; abstract class _MailViewModelBase with Store { BuildContext? context; late IMailService mailService; @observable bool isContainerHeightChange = true; @observable MailModel items = MailModel(); _MailViewModelBase() { mailService = MailService(NetworkManager.instance!.dio); } void setContext(BuildContext context) { this.context = context; } @action Future<void> fetchItems(String token, String category) async { items = await mailService.fetchAllTask(token, category); } @action void changeContainerHeight() { isContainerHeightChange = !isContainerHeightChange; } }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/view/bottomtab_view.dart
// ignore_for_file: prefer_const_constructors import 'package:crm_app/feature/home/company/tab/view/company_tab.dart'; import 'package:crm_app/feature/home/project/tab/project_tab.dart'; import '../../../../core/components/text/subtitle1_copy.dart'; import '../viewmodel/notification_view_model.dart'; import 'package:flutter_html/flutter_html.dart'; import '../../dashboards/view/dashboard_view.dart'; import '../../../../core/components/card/card_icon_text.dart'; import '../../../../core/components/row/row_flag_text.dart'; import '../../../../core/components/text/body_text1_copy.dart'; import '../../../../core/components/text/body_text2_copy.dart'; import '../../../../core/constants/app/app_constants.dart'; import '../../profile/viewmodel/profile/profile_view_model.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:kartal/kartal.dart'; import '../../contact/view/contact_view.dart'; import '../../mail/view/tab/view/mail_tab_view.dart'; import '../../profile/view/profile_tabbar_view.dart'; import '../model/bottomtab_model.dart'; class BottomTabView extends StatelessWidget { final ProfileViewModel viewModel = ProfileViewModel(); final NotificationViewModel notificationViewModel = NotificationViewModel(); BottomTabView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final List<BottomTabModel> items = [ BottomTabModel( title: "Proje", icon: Icons.assignment, child: ProjectTab()), BottomTabModel( title: "Katmanlar", icon: Icons.inventory_2, child: const DashboardView()), BottomTabModel( title: "Rehber", icon: Icons.contacts_sharp, child: const ContactView()), BottomTabModel( title: "Email", icon: Icons.email, child: const MailTabView()), BottomTabModel( title: "Şirket", icon: Icons.business, child: CompanyTab()), ]; MediaQueryData mediaQuery = MediaQuery.of(context); double height = mediaQuery.size.height; double radius = height * 0.02; viewModel.fetchItems(ApplicationConstants.instance!.token, ""); return DefaultTabController( length: items.length, child: Scaffold( appBar: _buildAppBar(context, items), body: _buildTabBarView(items), drawer: _buildDrawer(context, radius), ), ); } AppBar _buildAppBar(BuildContext context, List<BottomTabModel> items) => AppBar( title: Image.network( "http://192.168.3.53/assets/images/logo-light.png", width: context.dynamicWidth(0.28), ), centerTitle: true, bottom: _buildTabBar(items, context)); Widget _buildDrawer(BuildContext context, double radius) => Observer( builder: (context) { return Drawer( child: Column( children: [ Expanded( child: _buildProfileContainer(context, radius), ), Expanded( flex: 2, child: Container( color: context.colorScheme.secondary, child: Column( children: [ _buildLanguageCard(context), ], ), ), ), ], ), ); }, ); Container _buildProfileContainer(BuildContext context, double radius) => Container( color: context.colorScheme.background, child: Padding( padding: context.paddingLow, child: _buildProfileColumn(context, radius), ), ); Column _buildProfileColumn(BuildContext context, double radius) => Column( children: [ Padding( padding: context.paddingLow, child: Row( children: [ CircleAvatar( backgroundImage: NetworkImage(viewModel.items.photo ?? "http://192.168.3.53/assets/images/users/user0.jpg"), ), context.emptySizedWidthBoxLow3x, BodyText2Copy( data: viewModel.items.full_name ?? "asfsaf", color: context.colorScheme.onSurface) ], ), ), context.emptySizedHeightBoxLow, Expanded( child: GestureDetector( onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => const ProfileTabbarView())); }, child: CardIconText( cardColor: context.colorScheme.background, text: "Profilim", icon: Icons.account_circle, ), ), ), Expanded( child: GestureDetector( onTap: () { _showModalBottomSheet(context, radius, notificationViewModel); }, child: CardIconText( cardColor: context.colorScheme.background, text: "Bildirimler", icon: Icons.notifications, ), ), ), Expanded( child: GestureDetector( onTap: () async { Dio dio = Dio(); dio.post( "http://192.168.3.53/api/Foreign/log_out?token=${ApplicationConstants.instance!.token}"); Navigator.pop(context); Navigator.pop(context); ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: context.colorScheme.secondaryVariant, duration: context.durationSlow, content: BodyText2Copy( data: "Başarıyla çıkış yapıldı !", color: context.colorScheme.onSurface, ), ), ); _showDialog(context); }, child: CardIconText( cardColor: context.colorScheme.background, text: "Çıkış Yap", icon: Icons.exit_to_app, ), ), ), ], ); Card _buildLanguageCard(BuildContext context) => Card( child: ExpansionTile( title: const RowFlagText( url: "http://192.168.3.53/assets/users_assets/images/flags/tr.png", text: "Dil", ), children: [ _buildFlagCard(context), ], ), ); SizedBox _buildFlagCard(BuildContext context) { return SizedBox( height: context.dynamicHeight(0.25), child: Padding( padding: context.horizontalPaddingNormal, child: _buildFlagCardColumn, ), ); } Column get _buildFlagCardColumn => Column( // ignore: prefer_const_literals_to_create_immutables children: [ const Expanded( child: RowFlagText( url: "http://192.168.3.53/assets/users_assets/images/flags/germany.jpg", text: "German"), ), const Expanded( child: RowFlagText( url: "http://192.168.3.53/assets/users_assets/images/flags/italy.jpg", text: "Italian"), ), const Expanded( child: RowFlagText( url: "http://192.168.3.53/assets/users_assets/images/flags/spain.jpg", text: "Spanish"), ), const Expanded( child: RowFlagText( url: "http://192.168.3.53/assets/users_assets/images/flags/russia.jpg", text: "Russian"), ), ], ); TabBar _buildTabBar(List<BottomTabModel> items, BuildContext context) => TabBar( labelPadding: context.paddingLow, tabs: _buildTabs(items), indicatorColor: context.colorScheme.primary, ); List<Widget> _buildTabs(List<BottomTabModel> items) => List.generate( items.length, (index) => Tab( text: items[index].title, icon: Icon(items[index].icon), ), ); TabBarView _buildTabBarView(List<BottomTabModel> items) => TabBarView( children: items.map((e) => e.child).toList(), ); _showModalBottomSheet( context, double radius, NotificationViewModel viewModel) { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius), ), builder: (BuildContext context) { return Container( height: context.dynamicHeight(0.6), padding: context.paddingNormal, decoration: BoxDecoration( color: context.colorScheme.onSurface, borderRadius: BorderRadius.only( topLeft: context.highadius, topRight: context.highadius, ), ), child: Column( children: [ Center( child: Container( height: context.dynamicWidth(0.03), width: context.dynamicWidth(0.2), decoration: BoxDecoration( borderRadius: context.lowBorderRadius, color: Colors.grey), ), ), context.emptySizedHeightBoxLow3x, Padding( padding: context.paddingLow, child: const BodyText1Copy(data: "Bildirimler"), ), context.emptySizedHeightBoxLow3x, Expanded( child: GridView.builder( physics: const BouncingScrollPhysics(), itemCount: viewModel.items.emails?.length, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 0.65), itemBuilder: (context, index) { String htmlData = """ ${viewModel.items.emails?[index].content} """; return Padding( padding: context.paddingLow, child: Card( shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), color: context.colorScheme.secondary, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ListTile( leading: const CircleAvatar( backgroundImage: NetworkImage( "http://192.168.3.53/assets/images/users/user0.jpg"), ), title: Subtitle1Copy( data: viewModel .items.emails?[index].user_name ?? "")), Padding( padding: context.paddingNormal, child: Html( data: htmlData, ), ), Center( child: Text( viewModel.items.emails?[index].date ?? "")), ], ), ), ); }, ), ) ], ), ); }, ); } _showDialog(BuildContext context) { showDialog( context: context, builder: (context) => AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(context.lowValue), ), title: const BodyText1Copy(data: "Çıkış işlemi başarılı !"), content: const BodyText2Copy(data: "Başarıyla çıkış yapıldı."), actions: [ ElevatedButton( child: Text("Evet", style: TextStyle(color: context.colorScheme.onSurface)), style: ElevatedButton.styleFrom(primary: context.colorScheme.surface), onPressed: () { Navigator.pop(context); }, ), ], ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/model/notification_model.dart
// ignore_for_file: non_constant_identifier_names import 'package:json_annotation/json_annotation.dart'; part 'notification_model.g.dart'; @JsonSerializable() class NotificationModel { String? message; String? userid; List<Emails>? emails; NotificationModel({this.message, this.userid, this.emails}); factory NotificationModel.fromJson(Map<String, dynamic> json) => _$NotificationModelFromJson(json); Map<String, dynamic> toJson() => _$NotificationModelToJson(this); } @JsonSerializable() class Emails { String? user_name; String? readIt; String? title; String? content; String? date; Emails({this.user_name, this.readIt, this.title, this.content, this.date}); factory Emails.fromJson(Map<String, dynamic> json) => _$EmailsFromJson(json); Map<String, dynamic> toJson() => _$EmailsToJson(this); }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/model/bottomtab_model.dart
import 'package:flutter/material.dart'; class BottomTabModel { final String title; final IconData icon; final Widget child; BottomTabModel( {required this.title, required this.icon, required this.child}); }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/model/notification_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'notification_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** NotificationModel _$NotificationModelFromJson(Map<String, dynamic> json) { return NotificationModel( message: json['message'] as String?, userid: json['userid'] as String?, emails: (json['emails'] as List<dynamic>?) ?.map((e) => Emails.fromJson(e as Map<String, dynamic>)) .toList(), ); } Map<String, dynamic> _$NotificationModelToJson(NotificationModel instance) => <String, dynamic>{ 'message': instance.message, 'userid': instance.userid, 'emails': instance.emails, }; Emails _$EmailsFromJson(Map<String, dynamic> json) { return Emails( user_name: json['user_name'] as String?, readIt: json['readIt'] as String?, title: json['title'] as String?, content: json['content'] as String?, date: json['date'] as String?, ); } Map<String, dynamic> _$EmailsToJson(Emails instance) => <String, dynamic>{ 'user_name': instance.user_name, 'readIt': instance.readIt, 'title': instance.title, 'content': instance.content, 'date': instance.date, };
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/service/notification_service.dart
import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import '../model/notification_model.dart'; import 'i_notification_service.dart'; import 'notification_service_end_points.dart'; class NotificationService extends INotificationService { NotificationService(Dio dio) : super(dio); @override Future<NotificationModel> fetchAllTask(String token) async { final response = await dio .get(NotificationServiceEndPoints.notifications.rawValue(token)); if (response.statusCode == HttpStatus.ok) { return NotificationModel.fromJson(jsonDecode(response.data)); } return NotificationModel(); } }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/service/notification_service_end_points.dart
enum NotificationServiceEndPoints { notifications } extension NotificationServiceExtension on NotificationServiceEndPoints { String rawValue(String token) { switch (this) { case NotificationServiceEndPoints.notifications: return 'Foreign/get_notification?token=$token'; } } }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/service/i_notification_service.dart
import 'package:dio/dio.dart'; import '../model/notification_model.dart'; abstract class INotificationService { final Dio dio; INotificationService(this.dio); Future<NotificationModel> fetchAllTask(String token); }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/viewmodel/notification_view_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'notification_view_model.dart'; // ************************************************************************** // StoreGenerator // ************************************************************************** // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$NotificationViewModel on _NotificationViewModelBase, Store { final _$itemsAtom = Atom(name: '_NotificationViewModelBase.items'); @override NotificationModel get items { _$itemsAtom.reportRead(); return super.items; } @override set items(NotificationModel value) { _$itemsAtom.reportWrite(value, super.items, () { super.items = value; }); } final _$fetchItemsAsyncAction = AsyncAction('_NotificationViewModelBase.fetchItems'); @override Future<void> fetchItems(String token) { return _$fetchItemsAsyncAction.run(() => super.fetchItems(token)); } @override String toString() { return ''' items: ${items} '''; } }
0
mirrored_repositories/crm_app/lib/feature/home/bottomtab
mirrored_repositories/crm_app/lib/feature/home/bottomtab/viewmodel/notification_view_model.dart
import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import '../../../../core/constants/app/app_constants.dart'; import '../../../../core/init/network/network_manager.dart'; import '../model/notification_model.dart'; import '../service/i_notification_service.dart'; import '../service/notification_service.dart'; part 'notification_view_model.g.dart'; class NotificationViewModel = _NotificationViewModelBase with _$NotificationViewModel; abstract class _NotificationViewModelBase with Store { BuildContext? context; late INotificationService notificationService; @observable NotificationModel items = NotificationModel(); _NotificationViewModelBase() { notificationService = NotificationService(NetworkManager.instance!.dio); fetchItems(ApplicationConstants.instance!.token); } void setContext(BuildContext context) { this.context = context; } @action Future<void> fetchItems(String token) async { items = await notificationService.fetchAllTask(token); } }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards
mirrored_repositories/crm_app/lib/feature/home/dashboards/view/dashboard_view.dart
// ignore_for_file: prefer_const_constructors import 'package:crm_app/core/components/row/row_icon_text.dart'; import 'package:crm_app/core/components/text/body_text1_copy.dart'; import 'package:crm_app/core/components/text/bold_text.dart'; import 'package:crm_app/feature/home/dashboards/dashboard_detail/view/dashboard_detail_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:kartal/kartal.dart'; class DashboardView extends StatelessWidget { const DashboardView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( "Katmanlar", style: TextStyle(color: context.colorScheme.onSecondary), ), automaticallyImplyLeading: false, backgroundColor: Colors.transparent, elevation: 0, ), body: Padding( padding: context.paddingLow, child: Column( children: [ Expanded(child: _buildListViewBuilder), const Text("Katmanları silmek için sağa kaydırın.") ], ), ), ); } Widget get _buildListViewBuilder => ListView.builder( itemCount: 5, physics: const BouncingScrollPhysics(), itemBuilder: (context, index) => _buildProjectCard(context, index), ); Widget _buildProjectCard(BuildContext context, int index) => Padding( padding: context.paddingLow, child: Slidable( actionPane: const SlidableDrawerActionPane(), actions: [ IconSlideAction( color: context.colorScheme.primaryVariant, caption: 'Sil', icon: Icons.delete, onTap: () {}, ), IconSlideAction( color: context.colorScheme.onPrimary, foregroundColor: context.colorScheme.onSurface, caption: 'Düzenle', icon: Icons.edit, onTap: () {}, ), ], child: Card( elevation: 5, shape: RoundedRectangleBorder( borderRadius: context.normalBorderRadius), child: ListTile( onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => DashboardDetailView())); }, title: Padding( padding: context.verticalPaddingLow, child: BodyText1Copy(data: "Katman ismi"), ), subtitle: _buildSubtitle(context, index), trailing: const Icon(Icons.keyboard_arrow_right), ), ), ), ); Widget _buildSubtitle(BuildContext context, int index) => Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildRowIconText(index), context.emptySizedHeightBoxLow3x, Text("Katman içeriği"), Row( children: [ _buildRowIconTextText( context, index, Icons.list, "0", "Alt Katman"), context.emptySizedWidthBoxLow3x, _buildRowIconTextText( context, index, Icons.chat_bubble_outline, "0", "Yorum"), ], ), SizedBox( height: context.dynamicHeight(0.05), child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: 5, itemBuilder: (context, indexV2) { return GestureDetector( onTap: () {}, child: CircleAvatar( backgroundImage: NetworkImage( "http://192.168.3.53/assets/images/users/user0.jpg"), ), ); }, ), ), context.emptySizedHeightBoxLow3x, ], ); Widget _buildRowIconText(int index) => RowIconText( icon: Icons.account_circle_rounded, text: "Kullanıcı adı", sizedBox: const SizedBox( height: 0, width: 2, ), ); Row _buildRowIconTextText(BuildContext context, int index, IconData icon, String firstData, String secondData) => Row( children: [ Icon(icon), context.emptySizedWidthBoxLow, BoldText(data: firstData), context.emptySizedWidthBoxLow, Text( secondData, ), context.emptySizedHeightBoxHigh ], ); }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail/view/dashboard_detail_view.dart
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables import 'package:crm_app/core/components/text/body_text1_copy.dart'; import 'package:crm_app/core/components/text/body_text2_copy.dart'; import 'package:crm_app/feature/home/bottomtab/model/bottomtab_model.dart'; import 'package:crm_app/feature/home/dashboards/dashboard_detail/view/access_view.dart'; import 'package:crm_app/feature/home/dashboards/dashboard_detail/view/comments_view.dart'; import 'package:crm_app/feature/home/dashboards/dashboard_detail/view/log_records_view.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; class DashboardDetailView extends StatelessWidget { const DashboardDetailView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { List<Color> gradientColors = [ const Color(0xff23b6e6), const Color(0xff02d39a), ]; return Scaffold( appBar: AppBar( title: Image.network( "http://192.168.3.53/assets/images/logo-light.png", width: context.dynamicWidth(0.28), ), centerTitle: true, ), body: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: SizedBox( height: context.dynamicHeight(2.2), child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ BodyText1Copy( data: "Katmanlar", fontWeight: FontWeight.bold, ), ElevatedButton( onPressed: () { _showModalBottomSheet(context, context.lowValue); }, child: Icon( Icons.settings, color: context.colorScheme.onSurface, ), style: ElevatedButton.styleFrom( primary: context.colorScheme.secondaryVariant, ), ), ], ), context.emptySizedHeightBoxLow3x, Expanded( flex: 3, child: Card( child: Padding( padding: context.paddingNormal, child: PieChart( PieChartData( sections: [ PieChartSectionData( color: context.colorScheme.primaryVariant, value: 30, title: "30", radius: 50, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), PieChartSectionData( color: context.colorScheme.onPrimary, value: 40, title: "40", radius: 50, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), PieChartSectionData( color: context.colorScheme.onError, value: 50, title: "50", radius: 50, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), // PieChartSectionData( // color: context.colorScheme.error, // value: 25, // title: "25", // radius: 50, // titleStyle: // TextStyle(color: context.colorScheme.onSurface), // ), ], ), ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 3, child: Card( child: Padding( padding: context.paddingNormal, child: PieChart( PieChartData( centerSpaceRadius: 0, sections: [ PieChartSectionData( color: context.colorScheme.primaryVariant, value: 30, title: "30", radius: 100, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), PieChartSectionData( color: context.colorScheme.onPrimary, value: 40, title: "40", radius: 100, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), PieChartSectionData( color: context.colorScheme.onError, value: 50, title: "50", radius: 100, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), PieChartSectionData( color: context.colorScheme.error, value: 25, title: "25", radius: 100, titleStyle: TextStyle( color: context.colorScheme.onSurface), ), ], ), ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 3, child: Card( child: Padding( padding: context.paddingNormal, child: BarChart( BarChartData( barGroups: [ BarChartGroupData( x: 1, barRods: [ BarChartRodData(y: 1, colors: [ context.colorScheme.primaryVariant, ]), BarChartRodData(y: 2, colors: [ context.colorScheme.primaryVariant, ]), BarChartRodData(y: 3, colors: [ context.colorScheme.primaryVariant, ]), ], ), BarChartGroupData( x: 2, barRods: [ BarChartRodData(y: 4, colors: [ context.colorScheme.onPrimary, ]), BarChartRodData(y: 5, colors: [ context.colorScheme.onPrimary, ]), BarChartRodData(y: 6, colors: [ context.colorScheme.onPrimary, ]), ], ), BarChartGroupData( x: 3, barRods: [ BarChartRodData(y: -1), BarChartRodData(y: -2), BarChartRodData(y: -3), ], ), ], ), ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 3, child: Card( child: Padding( padding: context.paddingNormal, child: LineChart( LineChartData( gridData: FlGridData( show: true, drawVerticalLine: true, // getDrawingHorizontalLine: (value) { // return FlLine( // color: const Color(0xff37434d), // strokeWidth: 1, // ); // }, // getDrawingVerticalLine: (value) { // return FlLine( // color: const Color(0xff37434d), // strokeWidth: 1, // ); // }, ), titlesData: FlTitlesData( show: true, rightTitles: SideTitles(showTitles: false), topTitles: SideTitles(showTitles: false), bottomTitles: SideTitles( showTitles: true, reservedSize: 22, interval: 1, getTextStyles: (context, value) => const TextStyle( color: Color(0xff68737d), fontWeight: FontWeight.bold, fontSize: 16), getTitles: (value) { switch (value.toInt()) { case 2: return 'Çalışanlar'; case 5: return 'Görevler'; case 8: return 'Kişiler'; } return ''; }, margin: 8, ), leftTitles: SideTitles( showTitles: true, interval: 1, getTextStyles: (context, value) => const TextStyle( color: Color(0xff67727d), fontWeight: FontWeight.bold, fontSize: 15, ), getTitles: (value) { switch (value.toInt()) { case 1: return '500'; case 3: return '300'; case 5: return '200'; } return ''; }, reservedSize: 32, margin: 12, ), ), minX: 0, maxX: 11, minY: 0, maxY: 6, lineBarsData: [ LineChartBarData( spots: [ FlSpot(0, 3), FlSpot(2.6, 2), FlSpot(4.9, 5), FlSpot(6.8, 3), FlSpot(8, 4), FlSpot(9.5, 3), FlSpot(11, 4), ], isCurved: true, colors: gradientColors, barWidth: 5, isStrokeCapRound: true, dotData: FlDotData( show: false, ), belowBarData: BarAreaData( show: true, colors: gradientColors .map((color) => color.withOpacity(0.3)) .toList(), ), ), ], ), ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 2, child: SizedBox( width: double.infinity, child: Card( child: SingleChildScrollView( physics: BouncingScrollPhysics(), child: DataTable( columns: [ DataColumn(label: BodyText2Copy(data: "İsim")), DataColumn( label: BodyText2Copy(data: "Aktif Görev")) ], rows: List.generate( 4, (index) => DataRow( color: MaterialStateColor.resolveWith( (states) => index % 2 == 0 ? context.colorScheme.secondary : context.colorScheme.onSurface), cells: [ DataCell(Text("data")), DataCell(Text("data")), ]), ), ), ), ), ), ) ], ), ), ), ), ); } _showModalBottomSheet(context, double radius) { final List<BottomTabModel> items = [ BottomTabModel( title: "Yorumlar", icon: Icons.comment, child: CommentsView()), BottomTabModel( title: "Erişim Sahipleri", icon: Icons.people, child: AccesView()), BottomTabModel( title: "Ayarlar", icon: Icons.settings, child: const Scaffold()), BottomTabModel( title: "Log Kayıtları", icon: Icons.save, child: const LogRecordsView()), ]; showModalBottomSheet( isScrollControlled: true, context: context, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius), ), builder: (BuildContext context) { return DefaultTabController( length: items.length, child: Scaffold( bottomNavigationBar: BottomAppBar( child: Container( color: context.colorScheme.secondaryVariant, child: TabBar( labelPadding: context.horizontalPaddingLow, tabs: List.generate( items.length, (index) => Tab( text: items[index].title, icon: Icon(items[index].icon), ), ), ), ), ), body: TabBarView(children: items.map((e) => e.child).toList()), ), ); }); } }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail/view/access_view.dart
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables import 'package:crm_app/core/constants/app/app_constants.dart'; import 'package:crm_app/feature/home/contact/viewmodel/contact_view_model.dart'; import 'package:crm_app/feature/home/dashboards/dashboard_detail/viewmodel/acces_view_model.dart'; import 'package:crm_app/product/widgets/card/check_box_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:kartal/kartal.dart'; class AccesView extends StatefulWidget { final AccessViewModel _viewModel = AccessViewModel(); final ContactViewModel _contactViewModel = ContactViewModel(); AccesView({Key? key}) : super(key: key); @override State<AccesView> createState() => _AccesViewState(); } class _AccesViewState extends State<AccesView> { late final AccessViewModel _viewModel; late final ContactViewModel _contactViewModel; String firstDropdownValue = 'Görüntüleyebilir'; String secondDropdownValue = 'Görüntüleyebilir'; String token = ApplicationConstants.instance!.token; @override void initState() { super.initState(); _viewModel = widget._viewModel; _contactViewModel = widget._contactViewModel; _contactViewModel.fetchItems(token); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Erişim Sahipleri"), ), body: Observer( builder: (_) => Column( children: [ Padding( padding: context.paddingLow, child: Card( elevation: 5, shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(_viewModel.isSwitch ? "Paylaşım açık" : "Paylaşılabilir link al"), Row( children: [ Switch( value: _viewModel.isSwitch, onChanged: (value) => _viewModel.changeSwitch(), ), Text(_viewModel.isSwitch ? "Aktif" : "Pasif") ], ), ], ), AnimatedOpacity( opacity: _viewModel.isSwitch ? 1.0 : 0.0, duration: context.durationLow, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Text("Erişim:"), context.emptySizedWidthBoxLow3x, DropdownButton<String>( value: firstDropdownValue, onChanged: (String? newValue) { setState( () => firstDropdownValue = newValue!); }, items: <String>[ 'Görüntüleyebilir', 'Yorum Atabilir', 'Düzenleyebilir', 'Paylaşabilir', 'Tam Erişim', 'Erişimi Kaldır' ].map<DropdownMenuItem<String>>( (String value) { return DropdownMenuItem<String>( value: value, child: Text(value), ); }, ).toList(), ), ], ), Row( children: [ Text("Paylaş:"), context.emptySizedWidthBoxLow, IconButton( onPressed: () {}, icon: Icon(Icons.share)) ], ) ], ), ) ], ), ), ), ), Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: ListView.builder( itemCount: _contactViewModel.items.users?.length ?? 0, itemBuilder: (context, index) => index < _contactViewModel.items.users!.length ? CheckBoxCard( isSelect: _contactViewModel.items.users![index].isSelect, data: _contactViewModel.items.users?[index].full_name ?? "", userId: _contactViewModel.items.users?[index].id ?? "0", child: Padding( padding: context.horizontalPaddingNormal, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Text("Erişim:"), context.emptySizedWidthBoxLow3x, DropdownButton<String>( value: secondDropdownValue, onChanged: (String? newValue) { setState(() => secondDropdownValue = newValue!); }, items: <String>[ 'Görüntüleyebilir', 'Yorum Atabilir', 'Düzenleyebilir', 'Paylaşabilir', 'Tam Erişim', 'Erişimi Kaldır' ].map<DropdownMenuItem<String>>( (String value) { return DropdownMenuItem<String>( value: value, child: Text(value), ); }, ).toList(), ), ], ), context.emptySizedWidthBoxLow3x, ElevatedButton( onPressed: () {}, child: Icon( Icons.add, color: context.colorScheme.onSurface, ), ) ], ), ), ) : const SizedBox(), ), ), ) ], ), ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail/view/log_records_view.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; class LogRecordsView extends StatelessWidget { const LogRecordsView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Log Kayıtları"), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Expanded( child: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (context, index) => Column( // ignore: prefer_const_literals_to_create_immutables children: [ ListTile( leading: Icon(Icons.done), title: Text( "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", maxLines: 4, ), ), Divider( thickness: 2, ) ], ), ), ), ], ), ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail/view/comments_view.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; class CommentsView extends StatelessWidget { const CommentsView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: context.colorScheme.onSurface, appBar: AppBar( title: const Text("Yorumlar"), ), body: Column( children: [ Expanded( child: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (context, index) => Row( mainAxisAlignment: index % 2 == 0 ? MainAxisAlignment.start : MainAxisAlignment.end, children: [ index % 2 == 0 ? Row( children: [ context.emptySizedWidthBoxLow3x, Column( // ignore: prefer_const_literals_to_create_immutables children: [ index == 0 ? Padding( padding: EdgeInsets.only( top: context.normalValue), child: CircleAvatar( backgroundImage: NetworkImage( "http://192.168.3.53/assets/images/users/user0.jpg"), ), ) : CircleAvatar( backgroundImage: NetworkImage( "http://192.168.3.53/assets/images/users/user0.jpg"), ), context.emptySizedHeightBoxLow, Text("datetime") ], ), Container( margin: context.paddingLow, padding: context.paddingNormal, child: Column( // ignore: prefer_const_literals_to_create_immutables children: [ Text("Dışarıdan Erişim"), Text("message") ], ), decoration: BoxDecoration( color: Color(0xffF9F7E8), borderRadius: BorderRadius.circular(context.lowValue)), ), ], ) : Container( margin: context.paddingLow, padding: context.paddingNormal, child: Column( children: [ Text("Username"), context.emptySizedHeightBoxLow, Text("content"), context.emptySizedHeightBoxLow, Text("datetime"), ], ), decoration: BoxDecoration( color: Color(0xffFFDFD3), borderRadius: BorderRadius.circular(context.lowValue)), ), ], ), ), ), Container( color: context.colorScheme.secondaryVariant, padding: context.paddingLow, child: Row( children: [ Expanded( child: Container( decoration: BoxDecoration( color: context.colorScheme.onSurface, borderRadius: BorderRadius.all(context.lowRadius)), child: TextField( decoration: InputDecoration( prefixIcon: const Icon(Icons.chat), hintText: 'Lütfen mesajınızı buraya giriniz.', enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ), context.emptySizedWidthBoxLow3x, SizedBox( height: context.dynamicHeight(0.07), child: ElevatedButton( onPressed: () {}, child: Icon( Icons.send, color: context.colorScheme.onSurface, ), ), ) ], ), ), ], ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail/viewmodel/acces_view_model.dart
import 'package:mobx/mobx.dart'; part 'acces_view_model.g.dart'; class AccessViewModel = _AccessViewModelBase with _$AccessViewModel; abstract class _AccessViewModelBase with Store { @observable bool isSwitch = false; @action void changeSwitch() { isSwitch = !isSwitch; } }
0
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail
mirrored_repositories/crm_app/lib/feature/home/dashboards/dashboard_detail/viewmodel/acces_view_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'acces_view_model.dart'; // ************************************************************************** // StoreGenerator // ************************************************************************** // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$AccessViewModel on _AccessViewModelBase, Store { final _$isSwitchAtom = Atom(name: '_AccessViewModelBase.isSwitch'); @override bool get isSwitch { _$isSwitchAtom.reportRead(); return super.isSwitch; } @override set isSwitch(bool value) { _$isSwitchAtom.reportWrite(value, super.isSwitch, () { super.isSwitch = value; }); } final _$_AccessViewModelBaseActionController = ActionController(name: '_AccessViewModelBase'); @override void changeSwitch() { final _$actionInfo = _$_AccessViewModelBaseActionController.startAction( name: '_AccessViewModelBase.changeSwitch'); try { return super.changeSwitch(); } finally { _$_AccessViewModelBaseActionController.endAction(_$actionInfo); } } @override String toString() { return ''' isSwitch: ${isSwitch} '''; } }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/view/company_view.dart
// ignore_for_file: must_be_immutable, duplicate_ignore, prefer_const_constructors import 'package:crm_app/core/components/text/body_text1_copy.dart'; import 'package:crm_app/core/components/text/body_text2_copy.dart'; import 'package:crm_app/core/components/text/bold_text.dart'; import 'package:crm_app/core/constants/app/app_constants.dart'; import 'package:dio/dio.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import '../viewmodel/company_view_model.dart'; import '../company_detail/view/company_detail_view.dart'; import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; import 'package:popup_card/popup_card.dart'; // ignore: must_be_immutable class CompanyView extends StatelessWidget { final CompanyViewModel _viewModel = CompanyViewModel(); CompanyView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { _viewModel.fetchItems(ApplicationConstants.instance!.token); return Scaffold( appBar: AppBar( title: Text( "Firma Yönetimi", style: TextStyle(color: context.colorScheme.onSecondary), ), backgroundColor: Colors.transparent, automaticallyImplyLeading: false, elevation: 0, ), floatingActionButton: PopupItemLauncher( tag: 'Proje Ekle', child: Material( color: context.colorScheme.onError, elevation: 2, shape: RoundedRectangleBorder(borderRadius: context.highBorderRadius), child: Icon( Icons.add_rounded, size: 48, color: context.colorScheme.onSurface, ), ), popUp: PopUpItem( padding: EdgeInsets.zero, color: context.colorScheme.onSurface, shape: RoundedRectangleBorder(borderRadius: context.normalBorderRadius), elevation: 2, tag: 'Proje Ekle', child: PopUpItemBody( viewModel: _viewModel, ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.miniEndDocked, body: Observer( builder: (context) => Padding( padding: context.paddingLow, child: ListView.builder( physics: const BouncingScrollPhysics(), itemCount: _viewModel.items.company?.length ?? 0, itemBuilder: (context, index) => Observer( builder: (context) => Column( children: [ Card( shape: RoundedRectangleBorder( borderRadius: context.normalBorderRadius), elevation: 5, child: GestureDetector( onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => CompanyDetailView( id: _viewModel.items.company?[index].id ?? "", ), ), ); }, child: ExpansionTile( title: BodyText2Copy( data: _viewModel.items.company?[index].name ?? "Geçerli firma adı bulunamadı."), leading: CircleAvatar( backgroundImage: NetworkImage(_viewModel .items.company?[index].photo ?? "http://192.168.3.53/assets/images/companies/company.png"), backgroundColor: context.colorScheme.onSurface, ), expandedAlignment: Alignment.centerLeft, children: [ context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Email :", ), context.emptySizedWidthBoxLow3x, Text(_viewModel.items.company?[index].email ?? "Geçerli email adresi bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Telefon : ", ), context.emptySizedWidthBoxLow3x, Text(_viewModel .items.company?[index].telephone ?? "Geçerli telefon numarası bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Webisite :", ), context.emptySizedWidthBoxLow3x, Text( _viewModel.items.company?[index].web_site ?? "Geçerli web sitesi bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Konum :", ), context.emptySizedWidthBoxLow3x, Text( _viewModel.items.company?[index].location ?? "Geçerli konum bilgisi bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow3x, ], ), ), ), context.emptySizedHeightBoxLow, ], ), ), ), ), ), ); } } class PopUpItemBody extends StatefulWidget { final CompanyViewModel viewModel; const PopUpItemBody({Key? key, required this.viewModel}) : super(key: key); @override State<PopUpItemBody> createState() => _PopUpItemBodyState(); } class _PopUpItemBodyState extends State<PopUpItemBody> { late final CompanyViewModel viewModel; @override void initState() { super.initState(); viewModel = widget.viewModel; } var nameController = TextEditingController(); var mailController = TextEditingController(); var phoneController = TextEditingController(); var webSiteController = TextEditingController(); var taxNumberController = TextEditingController(); var taxDepartmentController = TextEditingController(); var detailController = TextEditingController(); var locationController = TextEditingController(); @override Widget build(BuildContext context) { return Center( child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Align( alignment: Alignment.topRight, child: GestureDetector( onTap: () { Navigator.pop(context); }, child: CircleAvatar( backgroundColor: context.colorScheme.primaryVariant, child: Icon( Icons.close, color: context.colorScheme.onSurface, ), ), ), ), Center( child: Padding( padding: context.paddingLow, child: const BodyText1Copy(data: "Firma Ekle")), ), Padding( padding: context.paddingLow, child: const Text("Firma İsmi"), ), context.emptySizedHeightBoxLow, TextField( controller: nameController, decoration: InputDecoration( prefixIcon: const Icon(Icons.business), hintText: 'Firma ismi giriniz.', labelText: 'Firma ismi', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Eposta Adresi"), ), context.emptySizedHeightBoxLow, TextField( controller: mailController, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( prefixIcon: const Icon(Icons.mail), hintText: 'Eposta adresi giriniz.', labelText: 'Eposta adresi', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Telefon"), ), context.emptySizedHeightBoxLow, TextField( controller: phoneController, keyboardType: TextInputType.phone, decoration: InputDecoration( prefixIcon: const Icon(Icons.phone), hintText: 'Telefon numarası giriniz.', labelText: 'Telefon numarası', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Web Sayfanız"), ), context.emptySizedHeightBoxLow, TextField( controller: webSiteController, decoration: InputDecoration( prefixIcon: const Icon(Icons.public), hintText: 'Web sayfanızı giriniz.', labelText: 'Web sayfası', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Vergi Numarası"), ), context.emptySizedHeightBoxLow, TextField( controller: taxNumberController, keyboardType: TextInputType.number, decoration: InputDecoration( prefixIcon: const Icon(Icons.tag), hintText: 'Veri numarası giriniz.', labelText: 'Vergi numarası', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Vergi Dairesi"), ), context.emptySizedHeightBoxLow, TextField( controller: taxDepartmentController, decoration: InputDecoration( prefixIcon: const Icon(Icons.store), hintText: 'Veri dairesi giriniz.', labelText: 'Vergi dairesi', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Detay"), ), context.emptySizedHeightBoxLow, TextField( controller: detailController, decoration: InputDecoration( prefixIcon: const Icon(Icons.description), hintText: 'Detay giriniz.', labelText: 'Detay', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Konum"), ), context.emptySizedHeightBoxLow, TextField( controller: locationController, decoration: InputDecoration( prefixIcon: const Icon(Icons.location_on), hintText: 'Konum giriniz.', labelText: 'Konum', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow3x, Divider( color: context.colorScheme.secondaryVariant, thickness: 0.4, ), Padding( padding: context.paddingLow, child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ ElevatedButton( onPressed: () { Navigator.of(context).pop(); }, child: BodyText2Copy( data: "Vazgeç", color: context.colorScheme.onSurface), style: ElevatedButton.styleFrom( primary: context.colorScheme.secondaryVariant), ), context.emptySizedWidthBoxLow, ElevatedButton( onPressed: () async { String token = ApplicationConstants.instance!.token; Dio dio = Dio(); await dio.post( "http://192.168.3.53/api/Companys/new_company?token=$token&name=${nameController.text}&email=${mailController.text}&telephone=${phoneController.text}&web_site=${webSiteController.text}&tax_number=${taxNumberController.text}&tax_department=${taxDepartmentController.text}&detail=${detailController.text}&location=${locationController.text}"); ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: context.colorScheme.secondaryVariant, duration: context.durationSlow, content: BodyText2Copy( data: "Firma başarıyla eklendi !", color: context.colorScheme.onSurface, ), ), ); setState(() { viewModel.fetchItems(token); }); Navigator.of(context).pop(); }, child: BodyText2Copy( data: "Ekle", color: context.colorScheme.onSurface), style: ElevatedButton.styleFrom( primary: context.colorScheme.surface), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/model/company_model.dart
// ignore_for_file: non_constant_identifier_names import 'package:json_annotation/json_annotation.dart'; part 'company_model.g.dart'; @JsonSerializable() class CompanyModel { String? message; String? userid; List<Company>? company; CompanyModel({this.message, this.userid, this.company}); factory CompanyModel.fromJson(Map<String, dynamic> json) => _$CompanyModelFromJson(json); Map<String, dynamic> toJson() => _$CompanyModelToJson(this); } @JsonSerializable() class Company { String? id; String? name; String? c_name; String? is_active; String? email; String? telephone; String? web_site; String? address; String? detail; String? photo; String? tax_number; String? tax_department; String? location; Company( {this.id, this.name, this.c_name, this.is_active, this.email, this.telephone, this.web_site, this.address, this.detail, this.photo, this.tax_number, this.tax_department, this.location}); factory Company.fromJson(Map<String, dynamic> json) => _$CompanyFromJson(json); Map<String, dynamic> toJson() => _$CompanyToJson(this); }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/model/company_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'company_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** CompanyModel _$CompanyModelFromJson(Map<String, dynamic> json) { return CompanyModel( message: json['message'] as String?, userid: json['userid'] as String?, company: (json['company'] as List<dynamic>?) ?.map((e) => Company.fromJson(e as Map<String, dynamic>)) .toList(), ); } Map<String, dynamic> _$CompanyModelToJson(CompanyModel instance) => <String, dynamic>{ 'message': instance.message, 'userid': instance.userid, 'company': instance.company, }; Company _$CompanyFromJson(Map<String, dynamic> json) { return Company( id: json['id'] as String?, name: json['name'] as String?, c_name: json['c_name'] as String?, is_active: json['is_active'] as String?, email: json['email'] as String?, telephone: json['telephone'] as String?, web_site: json['web_site'] as String?, address: json['address'] as String?, detail: json['detail'] as String?, photo: json['photo'] as String?, tax_number: json['tax_number'] as String?, tax_department: json['tax_department'] as String?, location: json['location'] as String?, ); } Map<String, dynamic> _$CompanyToJson(Company instance) => <String, dynamic>{ 'id': instance.id, 'name': instance.name, 'c_name': instance.c_name, 'is_active': instance.is_active, 'email': instance.email, 'telephone': instance.telephone, 'web_site': instance.web_site, 'address': instance.address, 'detail': instance.detail, 'photo': instance.photo, 'tax_number': instance.tax_number, 'tax_department': instance.tax_department, 'location': instance.location, };
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/service/company_service_end_points.dart
enum CompanyServiceEndPoints { company } extension CompanyServiceExtension on CompanyServiceEndPoints { String rawValue(String token) { switch (this) { case CompanyServiceEndPoints.company: return 'Companys/get_company?token=$token'; } } }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/service/company_service.dart
import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import '../model/company_model.dart'; import 'company_service_end_points.dart'; import 'i_company_service.dart'; class CompanyService extends ICompanyService { CompanyService(Dio dio) : super(dio); @override Future<CompanyModel> fetchAllTask(String token) async { final response = await dio.get(CompanyServiceEndPoints.company.rawValue(token)); if (response.statusCode == HttpStatus.ok) { return CompanyModel.fromJson(jsonDecode(response.data)); } return CompanyModel(); } }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/service/i_company_service.dart
import 'package:dio/dio.dart'; import '../model/company_model.dart'; abstract class ICompanyService { final Dio dio; ICompanyService(this.dio); Future<CompanyModel> fetchAllTask(String token); }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/view/company_detail_view.dart
// ignore_for_file: must_be_immutable, prefer_const_constructors import 'package:crm_app/core/components/text/body_text1_copy.dart'; import 'package:crm_app/core/components/text/body_text2_copy.dart'; import 'package:crm_app/core/components/text/bold_text.dart'; import 'package:crm_app/core/constants/app/app_constants.dart'; import 'package:crm_app/core/init/theme/light/color_scheme_light.dart'; import 'package:crm_app/feature/home/company/viewmodel/company_view_model.dart'; import 'package:crm_app/feature/home/contact/model/contact_model.dart'; import 'package:crm_app/feature/home/contact/viewmodel/contact_view_model.dart'; import 'package:crm_app/product/widgets/card/check_box_card_v2.dart'; import 'package:dio/dio.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import '../viewmodel/company_detail_view_model.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; import 'package:popup_card/popup_card.dart'; class CompanyDetailView extends StatefulWidget { final String id; const CompanyDetailView({Key? key, required this.id}) : super(key: key); @override State<CompanyDetailView> createState() => _CompanyDetailViewState(); } class _CompanyDetailViewState extends State<CompanyDetailView> { final CompanyDetailViewModel _viewModel = CompanyDetailViewModel(); final CompanyViewModel _companyViewModel = CompanyViewModel(); final ContactViewModel _contactViewModel = ContactViewModel(); @override void initState() { super.initState(); _viewModel.fetchItems(ApplicationConstants.instance!.token, widget.id); _contactViewModel.fetchItems(ApplicationConstants.instance!.token); _companyViewModel.fetchItems(ApplicationConstants.instance!.token); } @override Widget build(BuildContext context) { MediaQueryData mediaQuery = MediaQuery.of(context); double height = mediaQuery.size.height; double radius = height * 0.02; return Scaffold( appBar: AppBar( title: Image.network( "http://192.168.3.53/assets/images/logo-light.png", width: context.dynamicWidth(0.28), ), centerTitle: true, ), floatingActionButton: // _viewModel.items.access == "2" || _viewModel.items.access == "3" ? PopupItemLauncher( tag: 'Proje Ekle', child: Material( color: context.colorScheme.surface, elevation: 2, shape: RoundedRectangleBorder(borderRadius: context.highBorderRadius), child: Icon( Icons.more_vert, size: 48, color: context.colorScheme.onSurface, ), ), popUp: PopUpItem( padding: EdgeInsets.zero, color: context.colorScheme.onSurface, shape: RoundedRectangleBorder(borderRadius: context.normalBorderRadius), elevation: 2, tag: 'Proje Ekle', child: PopUpItemBody( viewModel: _viewModel, ), ), ), // : null, floatingActionButtonLocation: FloatingActionButtonLocation.miniEndDocked, body: Observer( builder: (context) => SingleChildScrollView( physics: const BouncingScrollPhysics(), child: SizedBox( height: context.dynamicHeight(1.85), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: context.paddingNormal, child: Text( _viewModel.items.name ?? "Geçerli firma adı bulunamadı.", style: context.textTheme.headline4!.copyWith( fontWeight: FontWeight.bold, color: context.colorScheme.onSecondary), ), ), Expanded( child: Column( children: [ Expanded( child: Padding( padding: context.paddingLow, child: Card( child: Padding( padding: context.paddingNormal, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CircleAvatar( radius: 40, child: Icon( Icons.person, size: context.dynamicWidth(0.1), ), ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ BodyText1Copy( data: _viewModel.items.worker?.length .toString() ?? "0", color: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, const BodyText2Copy( data: "Çalışan Sayısı"), ], ) ], ), ), ), ), ), ], ), ), Expanded( child: Column( children: [ Expanded( child: Padding( padding: context.paddingLow, child: Card( child: Padding( padding: context.paddingNormal, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CircleAvatar( radius: 40, child: Icon( Icons.call, size: context.dynamicWidth(0.1), ), backgroundColor: context.colorScheme.error, foregroundColor: context.colorScheme.onSurface, ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ BodyText1Copy( data: _viewModel.items.telephone ?? "Geçerli telefon numarası bulunamadı.", color: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, const BodyText2Copy(data: "Telefon"), ], ) ], ), ), ), ), ), ], ), ), Expanded( child: Column( children: [ Expanded( child: Padding( padding: context.paddingLow, child: Card( child: Padding( padding: context.paddingNormal, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CircleAvatar( radius: 40, child: Icon( Icons.event, size: context.dynamicWidth(0.1), ), backgroundColor: context.colorScheme.onPrimary, foregroundColor: context.colorScheme.onSurface, ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ BodyText1Copy( data: _viewModel.items.web_site ?? "Geçerli web sitesi bulunamadı.", color: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, const BodyText2Copy(data: "Web Site"), ], ) ], ), ), ), ), ), ], ), ), Expanded( child: Column( children: [ Expanded( child: Padding( padding: context.paddingLow, child: Card( child: Padding( padding: context.paddingNormal, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CircleAvatar( radius: 40, child: Icon( Icons.email, size: context.dynamicWidth(0.1), ), backgroundColor: context.colorScheme.primaryVariant, foregroundColor: context.colorScheme.onSurface, ), Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ BodyText1Copy( data: _viewModel.items.email ?? "Geçerli mail adresi bulunamadı.", color: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, const BodyText2Copy(data: "Eposta:"), ], ) ], ), ), ), ), ), ], ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 4, child: Padding( padding: context.paddingLow, child: Card( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: context.paddingNormal, child: Text( "Bilgiler", style: context.textTheme.headline4!.copyWith( fontWeight: FontWeight.bold, color: context.colorScheme.onSecondary), ), ), _viewModel.items.access == "3" ? Padding( padding: context.horizontalPaddingNormal, child: ElevatedButton( onPressed: () { String token = ApplicationConstants .instance!.token; Dio dio = Dio(); dio.post( "http://192.168.3.53/api/Companys/delete_company?token=$token&id=${_viewModel.items.id}"); Navigator.of(context).pop(); ScaffoldMessenger.of(context) .showSnackBar( SnackBar( backgroundColor: context .colorScheme.secondaryVariant, duration: context.durationSlow, content: BodyText2Copy( data: "Firma başarıyla silindi !", color: context .colorScheme.onSurface, ), ), ); _companyViewModel.fetchItems(token); }, child: Row( children: [ Icon(Icons.delete, color: ColorSchemeLight .instance.mandy), context.emptySizedWidthBoxLow, Text( "Firmayı sil", style: TextStyle( color: ColorSchemeLight .instance.mandy, ), ), ], ), style: ButtonStyle( overlayColor: MaterialStateProperty .resolveWith<Color>( (Set<MaterialState> states) { if (states.contains( MaterialState.hovered)) { return context .colorScheme.onBackground .withOpacity(0.2); } if (states.contains( MaterialState.focused) || states.contains( MaterialState.pressed)) { return context .colorScheme.onBackground .withOpacity(0.2); } return Colors .red; // Defer to the widget's default. }, ), backgroundColor: MaterialStateProperty.all<Color>( ColorSchemeLight .instance.pippin), ), ), ) : const SizedBox() ], ), CircleAvatar( radius: 64, backgroundImage: NetworkImage(_viewModel .items.photo ?? "http://192.168.3.53/assets/images/companies/company.png"), backgroundColor: context.colorScheme.onSurface, ), context.emptySizedHeightBoxLow3x, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Email :", ), context.emptySizedWidthBoxLow, Text(_viewModel.items.email ?? "Geçerli mail adresi bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Telefon :", ), context.emptySizedWidthBoxLow, Text(_viewModel.items.telephone ?? "Geçerli telefon numarası bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Vergi Dairesi :", ), context.emptySizedWidthBoxLow, Text(_viewModel.items.tax_department ?? "Geçerli vergi dairesi bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Vergi Numarası :", ), context.emptySizedWidthBoxLow, Text(_viewModel.items.tax_number ?? "Geçerli vergi numarası bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context.horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Konum :", ), context.emptySizedWidthBoxLow, Text(_viewModel.items.location ?? "Geçerli konum bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), ], ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 4, child: Padding( padding: context.paddingLow, child: Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: context.verticalPaddingLow, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: context.paddingNormal, child: Text( "Çalışanlar", style: context.textTheme.headline4! .copyWith( fontWeight: FontWeight.bold, color: context .colorScheme.onSecondary), ), ), _viewModel.items.access == "3" ? Padding( padding: context.horizontalPaddingNormal, child: ElevatedButton( onPressed: () { ApplicationConstants .instance!.accessLevel .clear(); ApplicationConstants .instance!.userId .clear(); _showModalBottomSheet( context, radius, _contactViewModel.items.users); }, child: Row( children: [ Icon( Icons.person_add, color: context.colorScheme.onError, ), context.emptySizedWidthBoxLow, Text( "Çalışan Ekle", style: TextStyle( color: context .colorScheme.onError), ), ], ), style: ButtonStyle( overlayColor: MaterialStateProperty .resolveWith<Color>( (Set<MaterialState> states) { if (states.contains( MaterialState.hovered)) { return context .colorScheme.onError .withOpacity(0.2); } if (states.contains( MaterialState .focused) || states.contains( MaterialState .pressed)) { return context .colorScheme.onError .withOpacity(0.2); } return Colors .red; // Defer to the widget's default. }, ), backgroundColor: MaterialStateProperty.all< Color>(Color(0xffE6E6FA)), ), ), ) : const SizedBox() ], ), ), context.emptySizedHeightBoxLow, Expanded( child: Padding( padding: context.paddingLow, child: ListView.builder( physics: const BouncingScrollPhysics(), itemCount: _viewModel.items.worker?.length ?? 0, itemBuilder: (context, index) => Column( children: [ Padding( padding: context.paddingLow, child: Slidable( actionPane: const SlidableDrawerActionPane(), secondaryActions: [ IconSlideAction( color: context .colorScheme.primaryVariant, caption: 'Sil', icon: Icons.delete, onTap: () async { String token = ApplicationConstants .instance!.token; Dio dio = Dio(); await dio.post( "http://192.168.3.53/api/Companys/delete_access?token=$token&user_id=${_viewModel.items.worker?[index].id}&company_id=${_viewModel.items.id}"); _viewModel.fetchItems(token, _viewModel.items.id ?? ""); ScaffoldMessenger.of(context) .showSnackBar( SnackBar( backgroundColor: context .colorScheme .secondaryVariant, duration: context.durationSlow, content: BodyText2Copy( data: "Çalışan başarıyla silindi !", color: context .colorScheme.onSurface, ), ), ); }, ), ], child: ExpansionTile( title: BodyText1Copy( data: _viewModel .items .worker?[index] .full_name ?? "Geçerli isim bulunamadı."), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(_viewModel.items .worker?[index].email ?? "Geçerli eposta adresi bulunamadı."), context.emptySizedWidthBoxLow3x, Text(_viewModel .items .worker?[index] .telephone ?? "Geçerli telefon numarası bulunamadı."), ], ), leading: const CircleAvatar( radius: 30, backgroundImage: NetworkImage( "http://192.168.3.53/assets/images/users/user0.jpg", ), ), expandedAlignment: Alignment.centerLeft, children: [ context.emptySizedHeightBoxLow3x, Padding( padding: context .horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Meslek: ", ), context.emptySizedWidthBoxLow, Text(_viewModel.items .worker?[index].job ?? "Geçerli meslek bulunamadı."), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow, Padding( padding: context .horizontalPaddingNormal, child: Row( children: [ BoldText( data: "Doğum Tarihi :", ), context.emptySizedWidthBoxLow, Text(_viewModel .items .worker?[index] .birthday ?? ""), ], ), ), const Divider( thickness: 2, indent: 15, endIndent: 15, ), context.emptySizedHeightBoxLow3x, ], ), ), ), const Divider( thickness: 2, height: 25, ), ], ), ), ), ) ], ), ), ), ), context.emptySizedHeightBoxLow3x, ], ), ), ), ), ); } _showModalBottomSheet(context, double radius, List<Users>? users) { showModalBottomSheet( isScrollControlled: true, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius), ), context: context, builder: (BuildContext context) { return Container( height: context.dynamicHeight(0.7), padding: context.paddingNormal, decoration: BoxDecoration( color: context.colorScheme.onSurface, borderRadius: BorderRadius.only( topLeft: context.highadius, topRight: context.highadius, ), ), child: Column( children: [ context.emptySizedHeightBoxLow, Center( child: Container( height: context.dynamicWidth(0.03), width: context.dynamicWidth(0.2), decoration: BoxDecoration( borderRadius: context.lowBorderRadius, color: Colors.grey, ), ), ), context.emptySizedHeightBoxLow3x, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const BodyText1Copy(data: "Çalışan Ekle"), InkWell( onTap: () { Navigator.pop(context); }, child: CircleAvatar( backgroundColor: context.colorScheme.primaryVariant, child: Icon( Icons.close, color: context.colorScheme.onSurface, ), ), ), ], ), context.emptySizedHeightBoxLow3x, Expanded( child: ListView.builder( physics: const BouncingScrollPhysics(), itemCount: users?.length ?? 0, itemBuilder: (context, index) => Padding( padding: context.paddingLow, child: CheckBoxCardV2( isSelect: users![index].isSelect, data: users[index].full_name ?? "", userId: users[index].id ?? "", )), ), ), Padding( padding: context.paddingLow, child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ ElevatedButton( onPressed: () { Navigator.of(context).pop(); }, child: Row( children: [ Icon( Icons.close, color: ColorSchemeLight.instance.mandy, ), BodyText2Copy( data: "Vazgeç", color: ColorSchemeLight.instance.mandy, ), ], ), style: ButtonStyle( overlayColor: MaterialStateProperty.resolveWith<Color>( (Set<MaterialState> states) { if (states.contains(MaterialState.hovered)) { return context.colorScheme.onError .withOpacity(0.2); } if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { return context.colorScheme.onError .withOpacity(0.2); } return Colors.red; // Defer to the widget's default. }, ), backgroundColor: MaterialStateProperty.all<Color>( ColorSchemeLight.instance.pippin), ), ), context.emptySizedWidthBoxLow, ElevatedButton( onPressed: () async { String token = ApplicationConstants.instance!.token; List<String> userId = ApplicationConstants.instance!.userId; List<String> accesLevel = ApplicationConstants.instance!.accessLevel; Dio dio = Dio(); for (var i = 0; i < ApplicationConstants .instance!.accessLevel.length; i++) { await dio.post( "http://192.168.3.53/api/Companys/new_access?token=$token&user_id=${userId[i]}&company_id=${_viewModel.items.id}&access=${accesLevel[i]}"); _viewModel.fetchItems( token, _viewModel.items.id ?? ""); Navigator.of(context).pop(); } }, child: Row( children: [ Icon(Icons.add), BodyText2Copy( data: "Ekle", color: ColorSchemeLight.instance.java), ], ), style: ElevatedButton.styleFrom( primary: ColorSchemeLight.instance.hummingBird), ), ], ), ), ], ), ); }, ); } } class PopUpItemBody extends StatelessWidget { var nameController = TextEditingController(); var mailController = TextEditingController(); var phoneController = TextEditingController(); var webSiteController = TextEditingController(); var taxNumberController = TextEditingController(); var taxDepartmentController = TextEditingController(); var detailController = TextEditingController(); var locationController = TextEditingController(); final CompanyDetailViewModel viewModel; PopUpItemBody({Key? key, required this.viewModel}) : super(key: key); @override Widget build(BuildContext context) { return Center( child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Align( alignment: Alignment.topRight, child: InkWell( onTap: () { Navigator.pop(context); }, child: CircleAvatar( backgroundColor: context.colorScheme.primaryVariant, child: Icon( Icons.close, color: context.colorScheme.onSurface, ), ), ), ), Center( child: Padding( padding: context.paddingLow, child: const BodyText1Copy(data: "Firma Ekle")), ), Padding( padding: context.paddingLow, child: const Text("Firma İsmi"), ), context.emptySizedHeightBoxLow, TextField( controller: nameController, decoration: InputDecoration( prefixIcon: const Icon(Icons.business), hintText: 'Firma ismi giriniz.', labelText: 'Firma ismi', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Eposta Adresi"), ), context.emptySizedHeightBoxLow, TextField( controller: mailController, keyboardType: TextInputType.emailAddress, decoration: InputDecoration( prefixIcon: const Icon(Icons.mail), hintText: 'Eposta adresi giriniz.', labelText: 'Eposta adresi', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Telefon"), ), context.emptySizedHeightBoxLow, TextField( controller: phoneController, keyboardType: TextInputType.phone, decoration: InputDecoration( prefixIcon: const Icon(Icons.phone), hintText: 'Telefon numarası giriniz.', labelText: 'Telefon numarası', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Web Sayfanız"), ), context.emptySizedHeightBoxLow, TextField( controller: webSiteController, decoration: InputDecoration( prefixIcon: const Icon(Icons.public), hintText: 'Web sayfanızı giriniz.', labelText: 'Web sayfası', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Vergi Numarası"), ), context.emptySizedHeightBoxLow, TextField( controller: taxNumberController, keyboardType: TextInputType.number, decoration: InputDecoration( prefixIcon: const Icon(Icons.tag), hintText: 'Veri numarası giriniz.', labelText: 'Vergi numarası', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Vergi Dairesi"), ), context.emptySizedHeightBoxLow, TextField( controller: taxDepartmentController, decoration: InputDecoration( prefixIcon: const Icon(Icons.store), hintText: 'Veri dairesi giriniz.', labelText: 'Vergi dairesi', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Detay"), ), context.emptySizedHeightBoxLow, TextField( controller: detailController, decoration: InputDecoration( prefixIcon: const Icon(Icons.description), hintText: 'Detay giriniz.', labelText: 'Detay', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow, Padding( padding: context.paddingLow, child: const Text("Konum"), ), context.emptySizedHeightBoxLow, TextField( controller: locationController, decoration: InputDecoration( prefixIcon: const Icon(Icons.location_on), hintText: 'Konum giriniz.', labelText: 'Konum', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.onBackground), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: context.colorScheme.surface), ), ), cursorColor: context.colorScheme.onSecondary, ), context.emptySizedHeightBoxLow3x, Divider( color: context.colorScheme.secondaryVariant, thickness: 0.4, ), Padding( padding: context.paddingLow, child: Row( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ ElevatedButton( onPressed: () { Navigator.of(context).pop(); }, child: BodyText2Copy( data: "Vazgeç", color: context.colorScheme.onSurface), style: ElevatedButton.styleFrom( primary: context.colorScheme.secondaryVariant), ), context.emptySizedWidthBoxLow, ElevatedButton( onPressed: () async { debugPrint(viewModel.items.id); String token = ApplicationConstants.instance!.token; Dio dio = Dio(); await dio.post( "http://192.168.3.53/api/Companys/update_company?token=$token&id=${viewModel.items.id}&name=${nameController.text}&email=${mailController.text}&telephone=${phoneController.text}&web_site=${webSiteController.text}&tax_number=${taxNumberController.text}&tax_department=${taxDepartmentController.text}&detail=${detailController.text}&location=${locationController.text}"); viewModel.fetchItems(token, viewModel.items.id ?? "0"); Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: context.colorScheme.secondaryVariant, duration: context.durationSlow, content: BodyText2Copy( data: "Firma bilgileri başarıyla güncellendi !", color: context.colorScheme.onSurface, ), ), ); }, child: BodyText2Copy( data: "Kaydet", color: context.colorScheme.onSurface), style: ElevatedButton.styleFrom( primary: context.colorScheme.surface), ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/model/company_detail_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'company_detail_model.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** CompanyDetailModel _$CompanyDetailModelFromJson(Map<String, dynamic> json) { return CompanyDetailModel( message: json['message'] as String?, userid: json['userid'] as String?, id: json['id'] as String?, access: json['access'] as String?, worker: (json['worker'] as List<dynamic>?) ?.map((e) => Worker.fromJson(e as Map<String, dynamic>)) .toList(), name: json['name'] as String?, c_name: json['c_name'] as String?, is_active: json['is_active'] as String?, email: json['email'] as String?, telephone: json['telephone'] as String?, web_site: json['web_site'] as String?, address: json['address'] as String?, detail: json['detail'] as String?, photo: json['photo'] as String?, tax_number: json['tax_number'] as String?, tax_department: json['tax_department'] as String?, location: json['location'] as String?, ); } Map<String, dynamic> _$CompanyDetailModelToJson(CompanyDetailModel instance) => <String, dynamic>{ 'message': instance.message, 'userid': instance.userid, 'id': instance.id, 'access': instance.access, 'worker': instance.worker, 'name': instance.name, 'c_name': instance.c_name, 'is_active': instance.is_active, 'email': instance.email, 'telephone': instance.telephone, 'web_site': instance.web_site, 'address': instance.address, 'detail': instance.detail, 'photo': instance.photo, 'tax_number': instance.tax_number, 'tax_department': instance.tax_department, 'location': instance.location, }; Worker _$WorkerFromJson(Map<String, dynamic> json) { return Worker( full_name: json['full_name'] as String?, email: json['email'] as String?, id: json['id'] as String?, photo: json['photo'] as String?, telephone: json['telephone'] as String?, detail: json['detail'] as String?, job: json['job'] as String?, company_id: json['company_id'] as String?, birthday: json['birthday'] as String?, ); } Map<String, dynamic> _$WorkerToJson(Worker instance) => <String, dynamic>{ 'full_name': instance.full_name, 'email': instance.email, 'id': instance.id, 'photo': instance.photo, 'telephone': instance.telephone, 'detail': instance.detail, 'job': instance.job, 'company_id': instance.company_id, 'birthday': instance.birthday, };
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/model/company_detail_model.dart
// ignore_for_file: non_constant_identifier_names import 'package:json_annotation/json_annotation.dart'; part 'company_detail_model.g.dart'; @JsonSerializable() class CompanyDetailModel { String? message; String? userid; String? id; String? access; List<Worker>? worker; String? name; String? c_name; String? is_active; String? email; String? telephone; String? web_site; String? address; String? detail; String? photo; String? tax_number; String? tax_department; String? location; CompanyDetailModel( {this.message, this.userid, this.id, this.access, this.worker, this.name, this.c_name, this.is_active, this.email, this.telephone, this.web_site, this.address, this.detail, this.photo, this.tax_number, this.tax_department, this.location}); factory CompanyDetailModel.fromJson(Map<String, dynamic> json) => _$CompanyDetailModelFromJson(json); Map<String, dynamic> toJson() => _$CompanyDetailModelToJson(this); } @JsonSerializable() class Worker { String? full_name; String? email; String? id; String? photo; String? telephone; String? detail; String? job; String? company_id; String? birthday; Worker( {this.full_name, this.email, this.id, this.photo, this.telephone, this.detail, this.job, this.company_id, this.birthday}); factory Worker.fromJson(Map<String, dynamic> json) => _$WorkerFromJson(json); Map<String, dynamic> toJson() => _$WorkerToJson(this); }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/service/company_detail_service.dart
import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import '../model/company_detail_model.dart'; import 'company_detail_service_end_points.dart'; import 'i_company_detail_service.dart'; class CompanyDetailService extends ICompanyDetailService { CompanyDetailService(Dio dio) : super(dio); @override Future<CompanyDetailModel> fetchAllTask(String token, String id) async { final response = await dio .get(CompanyDetailServiceEndPoints.companyDetail.rawValue(token, id)); if (response.statusCode == HttpStatus.ok) { return CompanyDetailModel.fromJson(jsonDecode(response.data)); } return CompanyDetailModel(); } }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/service/i_company_detail_service.dart
import 'package:dio/dio.dart'; import '../model/company_detail_model.dart'; abstract class ICompanyDetailService { final Dio dio; ICompanyDetailService(this.dio); Future<CompanyDetailModel> fetchAllTask(String token,String id); }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/service/company_detail_service_end_points.dart
enum CompanyDetailServiceEndPoints { companyDetail } extension CompanyDetailServiceExtension on CompanyDetailServiceEndPoints { String rawValue(String token,String id) { switch (this) { case CompanyDetailServiceEndPoints.companyDetail: return 'Companys/get_detail?id=$id&token=$token'; } } }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/viewmodel/company_detail_view_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'company_detail_view_model.dart'; // ************************************************************************** // StoreGenerator // ************************************************************************** // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$CompanyDetailViewModel on _CompanyDetailViewModelBase, Store { final _$itemsAtom = Atom(name: '_CompanyDetailViewModelBase.items'); @override CompanyDetailModel get items { _$itemsAtom.reportRead(); return super.items; } @override set items(CompanyDetailModel value) { _$itemsAtom.reportWrite(value, super.items, () { super.items = value; }); } final _$fetchItemsAsyncAction = AsyncAction('_CompanyDetailViewModelBase.fetchItems'); @override Future<void> fetchItems(String token, String id) { return _$fetchItemsAsyncAction.run(() => super.fetchItems(token, id)); } @override String toString() { return ''' items: ${items} '''; } }
0
mirrored_repositories/crm_app/lib/feature/home/company/company_detail
mirrored_repositories/crm_app/lib/feature/home/company/company_detail/viewmodel/company_detail_view_model.dart
import '../../../../../core/init/network/network_manager.dart'; import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import '../model/company_detail_model.dart'; import '../service/company_detail_service.dart'; import '../service/i_company_detail_service.dart'; part 'company_detail_view_model.g.dart'; class CompanyDetailViewModel = _CompanyDetailViewModelBase with _$CompanyDetailViewModel; abstract class _CompanyDetailViewModelBase with Store { BuildContext? context; late ICompanyDetailService companyDetailService; @observable CompanyDetailModel items = CompanyDetailModel(); _CompanyDetailViewModelBase() { companyDetailService = CompanyDetailService(NetworkManager.instance!.dio); } void setContext(BuildContext context) { this.context = context; } @action Future<void> fetchItems(String token,String id) async { items = await companyDetailService.fetchAllTask(token,id); } }
0
mirrored_repositories/crm_app/lib/feature/home/company/home
mirrored_repositories/crm_app/lib/feature/home/company/home/view/company_setting_view.dart
// ignore_for_file: prefer_const_constructors import 'package:crm_app/core/components/text/body_text2_copy.dart'; import 'package:crm_app/core/components/text/subtitle1_copy.dart'; import 'package:crm_app/core/init/theme/light/color_scheme_light.dart'; import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; class CompanySettingView extends StatelessWidget { const CompanySettingView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Padding( padding: context.paddingLow, child: Column( children: [ SizedBox( height: context.dynamicHeight(0.1), child: Card( elevation: 5, shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), child: ListTile( title: BodyText2Copy( data: "School Calendar", fontWeight: FontWeight.bold, ), subtitle: Subtitle1Copy( data: "Events & Happenings", color: Colors.grey, ), trailing: SizedBox( width: context.dynamicWidth(0.3), child: ElevatedButton( onPressed: () {}, child: Row( // ignore: prefer_const_literals_to_create_immutables children: [ Icon(Icons.add, color: context.colorScheme.onSurface), Text( "Add Event", style: TextStyle(color: context.colorScheme.onSurface), ) ], ), style: ElevatedButton.styleFrom( primary: ColorSchemeLight.instance.java, shadowColor: ColorSchemeLight.instance.hummingBird, ), ), ), ), ), ) ], ), ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/company/home
mirrored_repositories/crm_app/lib/feature/home/company/home/view/company_home_view.dart
// ignore_for_file: prefer_const_constructors import 'package:crm_app/core/components/text/body_text2_copy.dart'; import 'package:crm_app/core/components/text/bold_text.dart'; import 'package:crm_app/core/components/text/subtitle1_copy.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:kartal/kartal.dart'; class CompanyHomeView extends StatelessWidget { const CompanyHomeView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: SizedBox( height: context.dynamicHeight(2.6), child: Padding( padding: context.paddingLow, child: Column( children: [ Expanded( child: Card( shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), elevation: 5, child: Padding( padding: context.paddingNormal, child: Column( children: [ Expanded( child: Container( decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( "http://192.168.3.54/crm-v4/dist/assets/media/stock-600x400/img-70.jpg"), ), borderRadius: context.normalBorderRadius), ), ), context.emptySizedHeightBoxLow3x, Text("Firma İsmi"), context.emptySizedHeightBoxLow, Text( "Uzun isim", style: context.textTheme.caption!.copyWith( color: Colors.grey, fontWeight: FontWeight.bold, ), ) ], ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( child: Card( shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), elevation: 5, child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, // ignore: prefer_const_literals_to_create_immutables children: [ BoldText(data: "Books to Pickup"), context.emptySizedHeightBoxLow, Text( "24 Books to return", style: context.textTheme.caption!.copyWith( color: Colors.grey, fontWeight: FontWeight.bold, ), ), context.emptySizedHeightBoxLow, Expanded( child: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (context, index) => ListTile( leading: Container( width: context.dynamicWidth(0.1), height: context.dynamicHeight(0.1), decoration: BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: NetworkImage( "http://192.168.3.54/crm-v4/dist/assets/media/books/4.png", ), ), borderRadius: context.lowBorderRadius), ), title: BodyText2Copy(data: "Darius The Great"), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Subtitle1Copy( data: "Amazing Short Story About Darius greatness", color: Colors.grey, ), context.emptySizedHeightBoxLow, SizedBox( height: context.dynamicHeight(0.04), child: ElevatedButton( onPressed: () {}, child: Text("Book Now"), style: ButtonStyle( foregroundColor: MaterialStateProperty.all<Color>( Colors.grey.shade800), overlayColor: MaterialStateProperty .resolveWith<Color>( (Set<MaterialState> states) { if (states.contains( MaterialState.hovered)) { return Colors.grey .withOpacity(0.2); } if (states.contains( MaterialState.focused) || states.contains( MaterialState.pressed)) { return Colors.black .withOpacity(0.2); } return Colors .red; // Defer to the widget's default. }, ), backgroundColor: MaterialStateProperty.all<Color>( Colors.grey.shade300), ), ), ), context.emptySizedHeightBoxLow3x, ], ), ), ), ) ], ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( child: Card( shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), elevation: 5, child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ BoldText(data: "Authors"), context.emptySizedHeightBoxLow, Expanded( child: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (context, index) => ListTile( leading: Container( width: context.dynamicWidth(0.1), child: SvgPicture.network( "http://192.168.3.54/crm-v4/dist/assets/media/svg/avatars/009-boy-4.svg"), decoration: BoxDecoration( color: Color(0xffC9F7F5), borderRadius: context.lowBorderRadius), ), title: BodyText2Copy( data: "Ricky Hunt", fontWeight: FontWeight.w500, ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, // ignore: prefer_const_literals_to_create_immutables children: [ Subtitle1Copy( data: "PHP, SQLite, Artisan CLI", color: Colors.grey, ), ], ), trailing: Icon(Icons.more_horiz), ), ), ) ], ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( flex: 3, child: Card( shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), elevation: 5, child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ BoldText(data: "Personal Information"), context.emptySizedHeightBoxLow, Text( "Update your personal informaiton", style: context.textTheme.caption!.copyWith( color: Colors.grey, fontWeight: FontWeight.bold, ), ), context.emptySizedHeightBoxLow, Divider( thickness: 2, ), context.emptySizedHeightBoxLow, BoldText(data: "Customer Info"), context.emptySizedHeightBoxLow3x, Text( "Avatar", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), context.emptySizedHeightBoxLow, Stack( children: [ Container( height: context.dynamicHeight(0.1), width: context.dynamicWidth(0.18), decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( "http://192.168.3.54/crm-v4/dist/assets/media/users/blank.png"), fit: BoxFit.fill), borderRadius: context.lowBorderRadius), ), Positioned( left: 50, top: 50, bottom: 50, right: 0, child: Card( child: IconButton( onPressed: () {}, icon: Icon(Icons.edit)), ), ), ], ), context.emptySizedHeightBoxLow, Text( "Allowed file types: png, jpg, jpeg.", style: context.textTheme.caption!.copyWith( color: Colors.grey, fontWeight: FontWeight.bold, fontSize: 11), ), context.emptySizedHeightBoxLow3x, Row( children: [ Padding( padding: context.paddingLow, child: Text( "First Name :", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), ), context.emptySizedHeightBoxLow, Expanded( child: TextFormField( decoration: InputDecoration( filled: true, prefixIcon: const Icon(Icons.person), labelText: 'Please enter first name.', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: Colors.grey), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide( color: context.colorScheme.onSecondary), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ], ), context.emptySizedHeightBoxLow3x, Row( children: [ Padding( padding: context.paddingLow, child: Text( "Last Name :", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), ), context.emptySizedHeightBoxLow, Expanded( child: TextFormField( decoration: InputDecoration( filled: true, prefixIcon: const Icon(Icons.person), labelText: 'Please enter last name.', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: Colors.grey), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide( color: context.colorScheme.onSecondary), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ], ), context.emptySizedHeightBoxLow3x, Row( children: [ Padding( padding: context.paddingLow, child: Text( "Company Name :", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), ), context.emptySizedHeightBoxLow, Expanded( child: TextFormField( decoration: InputDecoration( filled: true, prefixIcon: const Icon(Icons.person), labelText: 'Please enter company name.', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: Colors.grey), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide( color: context.colorScheme.onSecondary), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ], ), context.emptySizedHeightBoxLow, Divider( thickness: 2, ), context.emptySizedHeightBoxLow, BoldText(data: "Contact Info"), context.emptySizedHeightBoxLow3x, Row( children: [ Padding( padding: context.paddingLow, child: Text( "Contact Phone :", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), ), context.emptySizedHeightBoxLow, Expanded( child: TextFormField( decoration: InputDecoration( filled: true, prefixIcon: const Icon(Icons.call), labelText: 'Please enter phone.', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: Colors.grey), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide( color: context.colorScheme.onSecondary), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ], ), context.emptySizedHeightBoxLow3x, Row( children: [ Padding( padding: context.paddingLow, child: Text( "Email Address :", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), ), context.emptySizedHeightBoxLow, Expanded( child: TextFormField( decoration: InputDecoration( filled: true, prefixIcon: const Icon(Icons.mail), labelText: 'Please enter email address.', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: Colors.grey), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide( color: context.colorScheme.onSecondary), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ], ), context.emptySizedHeightBoxLow3x, Row( children: [ Padding( padding: context.paddingLow, child: Text( "Company Site :", style: context.textTheme.caption!.copyWith( fontWeight: FontWeight.w500, ), ), ), context.emptySizedHeightBoxLow, Expanded( child: TextFormField( decoration: InputDecoration( filled: true, prefixIcon: const Icon(Icons.language), labelText: 'Please enter company site.', enabledBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide(color: Colors.grey), ), focusedBorder: OutlineInputBorder( borderRadius: context.lowBorderRadius, borderSide: BorderSide( color: context.colorScheme.onSecondary), ), ), cursorColor: context.colorScheme.onSecondary, ), ), ], ), context.emptySizedHeightBoxLow3x, ], ), ), ), ), context.emptySizedHeightBoxLow3x, Expanded( child: Card( elevation: 5, shape: RoundedRectangleBorder( borderRadius: context.lowBorderRadius), child: Padding( padding: context.paddingNormal, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ BoldText(data: "Upcoming Events"), context.emptySizedHeightBoxLow, Text( "Next Event is in 9 days", style: context.textTheme.caption!.copyWith( color: Colors.grey, fontWeight: FontWeight.bold, ), ), context.emptySizedHeightBoxLow3x, Expanded( child: ListView.builder( physics: BouncingScrollPhysics(), itemBuilder: (context, index) => ListTile( leading: Container( child: Icon( Icons.music_note_rounded, color: Color(0xff1BC5BD), size: context.dynamicHeight(0.05), ), decoration: BoxDecoration( color: Color(0xffC9F7F5), borderRadius: context.lowBorderRadius), ), title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, // ignore: prefer_const_literals_to_create_immutables children: [ BodyText2Copy( data: "School Music Festival", fontWeight: FontWeight.w500, ), BodyText2Copy( data: "03 Sep, 4:20PM", fontWeight: FontWeight.w500, ), ], ), subtitle: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, // ignore: prefer_const_literals_to_create_immutables children: [ Subtitle1Copy( data: "By Rose Liam", color: Colors.grey, ), Subtitle1Copy( data: "Time", color: Colors.grey, ), ], ), ), ), ), ], ), ), ), ) ], ), ), ), ), ); } }
0
mirrored_repositories/crm_app/lib/feature/home/company/tab
mirrored_repositories/crm_app/lib/feature/home/company/tab/view/company_tab.dart
// ignore_for_file: prefer_const_constructors import 'package:crm_app/feature/home/company/home/view/company_home_view.dart'; import 'package:crm_app/feature/home/company/home/view/company_setting_view.dart'; import 'package:flutter/material.dart'; import 'package:salomon_bottom_bar/salomon_bottom_bar.dart'; class CompanyTab extends StatefulWidget { const CompanyTab({Key? key}) : super(key: key); @override State<CompanyTab> createState() => _CompanyViewV2State(); } class _CompanyViewV2State extends State<CompanyTab> { int _currentIndex = 0; List<Widget> tabs = [ CompanyHomeView(), Center( child: Text("Ayarlar"), ), CompanySettingView(), Center( child: Text("Çalışanlar"), ), ]; @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: SalomonBottomBar( currentIndex: _currentIndex, items: [ SalomonBottomBarItem( selectedColor: Color(0xff8950FC), unselectedColor: Color(0xff8950FC), icon: Icon( Icons.home, ), title: Text("Ana Sayfa"), ), SalomonBottomBarItem( selectedColor: Color(0xff663259), unselectedColor: Color(0xff663259), icon: Icon( Icons.settings, ), title: Text("Ayarlar"), ), SalomonBottomBarItem( selectedColor: Color(0xff1BC5BD), unselectedColor: Color(0xff1BC5BD), icon: Icon(Icons.access_time), title: Text("Takvim"), ), SalomonBottomBarItem( selectedColor: Color(0xffF64E60), unselectedColor: Color(0xffF64E60), icon: Icon( Icons.person, ), title: Text("Çalışanlar")), ], onTap: (index) => setState(() => _currentIndex = index), ), body: tabs[_currentIndex], ); } }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/viewmodel/company_view_model.dart
import '../../../../core/init/network/network_manager.dart'; import 'package:flutter/cupertino.dart'; import 'package:mobx/mobx.dart'; import '../model/company_model.dart'; import '../service/company_service.dart'; import '../service/i_company_service.dart'; part 'company_view_model.g.dart'; class CompanyViewModel = _CompanyViewModelBase with _$CompanyViewModel; abstract class _CompanyViewModelBase with Store { BuildContext? context; late ICompanyService companyService; @observable CompanyModel items = CompanyModel(); _CompanyViewModelBase() { companyService = CompanyService(NetworkManager.instance!.dio); } void setContext(BuildContext context) { this.context = context; } @action Future<void> fetchItems(String token) async { items = await companyService.fetchAllTask(token); } }
0
mirrored_repositories/crm_app/lib/feature/home/company
mirrored_repositories/crm_app/lib/feature/home/company/viewmodel/company_view_model.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'company_view_model.dart'; // ************************************************************************** // StoreGenerator // ************************************************************************** // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic mixin _$CompanyViewModel on _CompanyViewModelBase, Store { final _$itemsAtom = Atom(name: '_CompanyViewModelBase.items'); @override CompanyModel get items { _$itemsAtom.reportRead(); return super.items; } @override set items(CompanyModel value) { _$itemsAtom.reportWrite(value, super.items, () { super.items = value; }); } final _$fetchItemsAsyncAction = AsyncAction('_CompanyViewModelBase.fetchItems'); @override Future<void> fetchItems(String token) { return _$fetchItemsAsyncAction.run(() => super.fetchItems(token)); } @override String toString() { return ''' items: ${items} '''; } }
0
mirrored_repositories/crm_app/lib/feature/splash
mirrored_repositories/crm_app/lib/feature/splash/view/splash_view.dart
import 'package:animated_splash_screen/animated_splash_screen.dart'; import 'package:flutter/material.dart'; import 'package:kartal/kartal.dart'; import '../../auth/login/view/login_view.dart'; class SplashView extends StatelessWidget { const SplashView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return AnimatedSplashScreen( backgroundColor: context.colorScheme.secondaryVariant, splash: Image.network( "http://192.168.3.53/assets/images/logo-light.png", ), nextScreen: const LoginView(), duration: 1000, ); } }
0
mirrored_repositories/crm_app
mirrored_repositories/crm_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 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:crm_app/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/WidgetsApp
mirrored_repositories/WidgetsApp/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:widget_app/config/router/app_router.dart'; import 'package:widget_app/config/theme/app_theme.dart'; import 'package:widget_app/presentation/providers/theme_provider.dart'; // import 'package:widget_app/presentation/screens/screens.dart'; void main() { runApp(const ProviderScope(child: MainApp())); } class MainApp extends ConsumerWidget { const MainApp({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final AppTheme appTheme = ref.watch(themeNotifierProvider); return MaterialApp.router( title: "Flutter Widgets", routerConfig: appRouter, debugShowCheckedModeBanner: false, theme: AppTheme(selectedColor: appTheme.selectedColor, isDarkMode: appTheme.isDarkMode) .getTheme(), /* Routing way 1: routes: { '/buttons':(context)=> const ButtonsScreen(), '/cards':(context)=> const CardsScreen() }, */ ); } }
0
mirrored_repositories/WidgetsApp/lib/config
mirrored_repositories/WidgetsApp/lib/config/router/app_router.dart
import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:widget_app/presentation/screens/screens.dart'; final GoRouter appRouter = GoRouter( initialLocation: '/', routes: <RouteBase>[ GoRoute( path: '/counter', name: CounterScreen.name, builder: (BuildContext context, GoRouterState state) { return const CounterScreen(); }, ), GoRoute( path: '/', name: HomeScreen.name, builder: (BuildContext context, GoRouterState state) { return const HomeScreen(); }, ), GoRoute( path: '/theme-changer', name: ThemeChangerScreen.name, builder: (BuildContext context, GoRouterState state) { return const ThemeChangerScreen(); }, ), GoRoute( path: '/buttons', name: ButtonsScreen.name, builder: (BuildContext context, GoRouterState state) { return const ButtonsScreen(); }, ), GoRoute( path: '/cards', name: CardsScreen.name, builder: (BuildContext context, GoRouterState state) { return const CardsScreen(); }, ), GoRoute( path: '/progress', name: ProgressScreen.name, builder: (BuildContext context, GoRouterState state) { return const ProgressScreen(); }, ), GoRoute( path: '/snackbars', name: SnackBarScreen.name, builder: (BuildContext context, GoRouterState state) { return const SnackBarScreen(); }, ), GoRoute( path: '/animated-container', name: AnimatedScreen.name, builder: (BuildContext context, GoRouterState state) { return const AnimatedScreen(); }, ), GoRoute( path: '/ui-controls', name: UIControlsScreen.name, builder: (BuildContext context, GoRouterState state) { return const UIControlsScreen(); }, ), GoRoute( path: '/app-tutorial', name: AppTutorialScreen.name, builder: (BuildContext context, GoRouterState state) { return const AppTutorialScreen(); }, ), GoRoute( path: '/infinite-scroll', name: InfiniteScrollScreen.name, builder: (BuildContext context, GoRouterState state) { return const InfiniteScrollScreen(); }, ), ], );
0
mirrored_repositories/WidgetsApp/lib/config
mirrored_repositories/WidgetsApp/lib/config/theme/app_theme.dart
import 'package:flutter/material.dart'; const colorList = <Color>[ Colors.blue, Colors.teal, Colors.deepPurpleAccent, Colors.red, Colors.lightGreen, Colors.amberAccent, Colors.deepOrangeAccent, Colors.pink, ]; class AppTheme { final int selectedColor; final bool isDarkMode; AppTheme({this.selectedColor = 0, this.isDarkMode = false}) : assert( selectedColor >= 0, "Selected color must be greater or equal to 0"), assert(selectedColor < colorList.length, "Selected color must be less than or equal to ${colorList.length - 1}"); ThemeData getTheme() => ThemeData( brightness: isDarkMode ? Brightness.dark : Brightness.light, colorSchemeSeed: colorList[selectedColor], appBarTheme: const AppBarTheme(centerTitle: true)); AppTheme copyWith({int? selectedColor, bool? isDarkMode}) => AppTheme( selectedColor: selectedColor ?? this.selectedColor, isDarkMode: isDarkMode ?? this.isDarkMode); }
0
mirrored_repositories/WidgetsApp/lib/config
mirrored_repositories/WidgetsApp/lib/config/menu/menu_items.dart
import 'package:flutter/material.dart'; class MenuItem { final String title; final String subTitle; final String link; final IconData icon; const MenuItem( {required this.title, required this.subTitle, required this.link, required this.icon}); } const appMenuItems = <MenuItem>[ MenuItem( title: 'Counter Screen', subTitle: 'Example using Riverpod', link: '/counter', icon: Icons.numbers_outlined), MenuItem( title: 'Theme Changer Screen', subTitle: 'Change the application colors', link: '/theme-changer', icon: Icons.color_lens_outlined), MenuItem( title: 'Botones', subTitle: 'Varios botones en Flutter', link: '/buttons', icon: Icons.smart_button_outlined), MenuItem( title: 'Tarjetas', subTitle: 'Un contenedor estilizado', link: '/cards', icon: Icons.credit_card), MenuItem( title: 'Progress Indicator', subTitle: 'Generales y controlados', link: '/progress', icon: Icons.refresh_rounded), MenuItem( title: 'SnackBars y Dialogs', subTitle: 'Indicadores en pantalla', link: '/snackbars', icon: Icons.info_outline), MenuItem( title: 'Animated Container', subTitle: 'Statefull widget animated', link: '/animated-container', icon: Icons.check_box_outline_blank), MenuItem( title: 'UI Controls + Tiles', subTitle: 'Controls in flutter', link: '/ui-controls', icon: Icons.control_camera_rounded), MenuItem( title: 'App Tutorial', subTitle: 'Introduction tutorial', link: '/app-tutorial', icon: Icons.add_chart_outlined), MenuItem( title: 'Infinite Scroll and pull', subTitle: 'Infinite scrolls and pull to refresh', link: '/infinite-scroll', icon: Icons.list_alt_outlined), ];
0
mirrored_repositories/WidgetsApp/lib/presentation
mirrored_repositories/WidgetsApp/lib/presentation/widgets/side_menu.dart
import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:widget_app/config/menu/menu_items.dart'; class SideMenu extends StatefulWidget { const SideMenu({super.key, required this.scaffoldKey}); final GlobalKey<ScaffoldState> scaffoldKey; @override State<SideMenu> createState() => _SideMenuState(); } class _SideMenuState extends State<SideMenu> { int navDrawerIndex = 1; @override Widget build(BuildContext context) { final hasNotch = MediaQuery.of(context).viewPadding.top > 35; return NavigationDrawer( selectedIndex: navDrawerIndex, onDestinationSelected: (value) { setState(() { navDrawerIndex = value; }); final menuItem = appMenuItems[value]; context.push(menuItem.link); widget.scaffoldKey.currentState?.closeDrawer(); }, children: [ Padding( padding: EdgeInsets.fromLTRB(28, hasNotch ? 10 : 20, 16, 10), child: const Text("Menu Options"), ), ...appMenuItems.sublist(0, 3).map( (item) => NavigationDrawerDestination( icon: Icon(item.icon), label: Text(item.title)), ), const Padding( padding: const EdgeInsets.fromLTRB(28, 16, 28, 10), child: Divider(), ), const Padding( padding: EdgeInsets.fromLTRB(28, 10, 16, 10), child: Text("More Options"), ), ...appMenuItems.sublist(3).map( (item) => NavigationDrawerDestination( icon: Icon(item.icon), label: Text(item.title)), ), ]); } }
0
mirrored_repositories/WidgetsApp/lib/presentation
mirrored_repositories/WidgetsApp/lib/presentation/screens/screens.dart
export 'package:widget_app/presentation/screens/theme_changer/theme_changer_screen.dart'; export 'package:widget_app/presentation/screens/counter/counter_screen.dart'; export 'package:widget_app/presentation/screens/Infinite_scroll/infinite_scroll_screen.dart'; export 'package:widget_app/presentation/screens/animated/animated_screen.dart'; export 'package:widget_app/presentation/screens/app_tutorial/app_tutorial_screen.dart'; export 'package:widget_app/presentation/screens/progress/progress_screen.dart'; export 'package:widget_app/presentation/screens/snackbar/snackbar_screen.dart'; export 'package:widget_app/presentation/screens/ui_controls/ui_controls_screen.dart'; export 'package:widget_app/presentation/screens/home/home_screen.dart'; export 'package:widget_app/presentation/screens/cards/cards_screen.dart'; export 'package:widget_app/presentation/screens/buttons/buttons_screen.dart';
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/cards/cards_screen.dart
import 'package:flutter/material.dart'; const cards = <Map<String, dynamic>>[ {"elevation": 0.0, "label": "Elevation 0"}, {"elevation": 1.0, "label": "Elevation 1"}, {"elevation": 2.0, "label": "Elevation 2"}, {"elevation": 3.0, "label": "Elevation 3"}, ]; class CardsScreen extends StatelessWidget { const CardsScreen({super.key}); static const String name = "cards_screen"; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Cards screen"), ), body: const _CardsView()); } } class _CardsView extends StatelessWidget { const _CardsView({super.key}); @override Widget build(BuildContext context) { return SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( children: [ ...cards.map((card) => _CardType1( elevation: card['elevation'], label: card['label'], )), ...cards.map((card) => _CardType2( elevation: card['elevation'], label: card['label'], )), ...cards.map((card) => _CardType3( elevation: card['elevation'], label: card['label'], )), ...cards.map((card) => _CardType4( elevation: card['elevation'], label: card['label'], )), const SizedBox( height: 50, ) ], ), ); } } class _CardType1 extends StatelessWidget { final String label; final double elevation; const _CardType1({super.key, required this.label, required this.elevation}); @override Widget build(BuildContext context) { return Card( elevation: elevation, child: Padding( padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), child: Column( children: [ Align( alignment: Alignment.topRight, child: IconButton( onPressed: () {}, icon: const Icon(Icons.more_vert_outlined)), ), Align( alignment: Alignment.bottomLeft, child: Text(label), ), ], ), ), ); } } class _CardType2 extends StatelessWidget { final String label; final double elevation; const _CardType2({super.key, required this.label, required this.elevation}); @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return Card( shape: RoundedRectangleBorder( borderRadius: const BorderRadius.all(Radius.circular(12)), side: BorderSide(color: colors.outline)), elevation: elevation, child: Padding( padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), child: Column( children: [ Align( alignment: Alignment.topRight, child: IconButton( onPressed: () {}, icon: const Icon(Icons.more_vert_outlined)), ), Align( alignment: Alignment.bottomLeft, child: Text('$label - outline'), ), ], ), ), ); } } class _CardType3 extends StatelessWidget { final String label; final double elevation; const _CardType3({super.key, required this.label, required this.elevation}); @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return Card( color: colors.surfaceVariant, elevation: elevation, child: Padding( padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), child: Column( children: [ Align( alignment: Alignment.topRight, child: IconButton( onPressed: () {}, icon: const Icon(Icons.more_vert_outlined)), ), Align( alignment: Alignment.bottomLeft, child: Text('$label - filled'), ), ], ), ), ); } } class _CardType4 extends StatelessWidget { final String label; final double elevation; const _CardType4({super.key, required this.label, required this.elevation}); @override Widget build(BuildContext context) { return Card( clipBehavior: Clip.hardEdge, elevation: elevation, child: Stack( children: [ Image.network( "http://picsum.photos/id/${elevation.toInt()}/600/250", height: 250, fit: BoxFit.cover, ), Align( alignment: Alignment.topRight, child: Container( decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20))), child: IconButton( onPressed: () {}, icon: const Icon(Icons.more_vert_outlined)), ), ), ], ), ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/Infinite_scroll/infinite_scroll_screen.dart
import 'package:animate_do/animate_do.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; class InfiniteScrollScreen extends StatefulWidget { const InfiniteScrollScreen({super.key}); static const String name = "infinite_scroll_screen"; @override State<InfiniteScrollScreen> createState() => _InfiniteScrollScreenState(); } class _InfiniteScrollScreenState extends State<InfiniteScrollScreen> { List<int> imagesIds = [1, 2, 3, 4, 5]; final ScrollController scrollController = ScrollController(); bool isLoading = false; bool isMounted = true; @override void initState() { super.initState(); scrollController.addListener(() { if (scrollController.position.pixels + 500 >= scrollController.position.maxScrollExtent) { loadNextPage(); } }); } @override void dispose() { scrollController.dispose(); isMounted = false; super.dispose(); } Future loadNextPage() async { if (isLoading) return; isLoading = true; isMounted = true; setState(() {}); await Future.delayed(const Duration(seconds: 2)); addFiveImages(); isLoading = false; if (!isMounted) return; setState(() {}); moveScrollToBottom(); } Future<void> onRefresh() async { isLoading = true; setState(() {}); await Future.delayed(const Duration(seconds: 3)); if (!isMounted) return; isLoading = false; final lastId = imagesIds.last; imagesIds.clear(); imagesIds.add(lastId + 1); addFiveImages(); setState(() {}); } void moveScrollToBottom() { if (scrollController.position.pixels + 100 <= scrollController.position.maxScrollExtent) return; scrollController.animateTo(scrollController.position.pixels + 120, duration: const Duration(milliseconds: 300), curve: Curves.fastOutSlowIn); } void addFiveImages() { final lastId = imagesIds.last; imagesIds.addAll([1, 2, 3, 4, 5].map((e) => lastId + e)); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, body: MediaQuery.removePadding( context: context, removeTop: true, removeBottom: true, child: RefreshIndicator( onRefresh: onRefresh, edgeOffset: 10, strokeWidth: 2, child: ListView.builder( controller: scrollController, itemCount: imagesIds.length, itemBuilder: (context, index) { return FadeInImage( fit: BoxFit.cover, width: double.infinity, height: 300, placeholder: const AssetImage("assets/images/jar-loading.gif"), image: NetworkImage( 'https://picsum.photos/id/${imagesIds[index]}/500/300')); }, ), )), floatingActionButton: FloatingActionButton( onPressed: () => context.pop(), child: isLoading ? SpinPerfect( infinite: true, child: const Icon(Icons.refresh_rounded), ) : FadeIn( child: const Icon(Icons.arrow_back_ios_new_outlined), ))); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/snackbar/snackbar_screen.dart
import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; class SnackBarScreen extends StatelessWidget { const SnackBarScreen({super.key}); static const String name = "snackbar_screen"; void showCustomSnackBar(BuildContext context) { ScaffoldMessenger.of(context).clearSnackBars(); final snackBar = SnackBar( content: const Text("I am a SnackBar"), action: SnackBarAction(label: "Ok", onPressed: () {}), duration: const Duration(seconds: 2), ); ScaffoldMessenger.of(context).showSnackBar(snackBar); } void showCustomDialog(BuildContext context) { showDialog( barrierDismissible: false, context: context, builder: (context) => AlertDialog( title: const Text("are you sure?"), content: const Text( " It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."), actions: [ TextButton( onPressed: () => context.pop(), child: const Text("Cancel")), FilledButton( onPressed: () => context.pop(), child: const Text("Accept")) ], )); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("SnackBar and Dialogs"), ), floatingActionButton: FloatingActionButton.extended( label: const Text("Show SnackBar"), icon: const Icon(Icons.remove_red_eye_outlined), onPressed: () => showCustomSnackBar(context), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ FilledButton.tonal( onPressed: () { showAboutDialog(context: context, children: [ const Text( "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. ") ]); }, child: const Text("Licence used")), FilledButton.tonal( onPressed: () => showCustomDialog(context), child: const Text("Show dialog")) ], ), ), ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/ui_controls/ui_controls_screen.dart
import 'package:flutter/material.dart'; class UIControlsScreen extends StatelessWidget { const UIControlsScreen({super.key}); static const String name = "ui_controls_screen"; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("UI Controls"), ), body: _UiControlsView(), ); } } class _UiControlsView extends StatefulWidget { @override State<StatefulWidget> createState() => _UiControlsViewState(); } enum Transportation { car, plane, boat, submarine } class _UiControlsViewState extends State<_UiControlsView> { bool isDeveloper = true; Transportation selectedTransportation = Transportation.car; bool wantsBreakFast = false; bool wantsLunch = false; bool wantsDinner = false; @override Widget build(BuildContext context) { return ListView( physics: const ClampingScrollPhysics(), children: [ SwitchListTile( value: isDeveloper, onChanged: (value) => setState(() { isDeveloper = !isDeveloper; }), title: const Text("Developer mode"), subtitle: const Text("Additional controls")), ExpansionTile( title: const Text("Transportation option"), subtitle: Text('$selectedTransportation'), children: [ RadioListTile( title: const Text("By Car"), subtitle: const Text("Travelling by car"), value: Transportation.car, groupValue: selectedTransportation, onChanged: (value) => setState(() { selectedTransportation = Transportation.car; })), RadioListTile( title: const Text("By Boat"), subtitle: const Text("Travelling by boat"), value: Transportation.boat, groupValue: selectedTransportation, onChanged: (value) => setState(() { selectedTransportation = Transportation.boat; })), RadioListTile( title: const Text("By Plane"), subtitle: const Text("Travelling by plane"), value: Transportation.plane, groupValue: selectedTransportation, onChanged: (value) => setState(() { selectedTransportation = Transportation.plane; })), RadioListTile( title: const Text("By Submarine"), subtitle: const Text("Travelling by submarine"), value: Transportation.submarine, groupValue: selectedTransportation, onChanged: (value) => setState(() { selectedTransportation = Transportation.submarine; })) ], ), CheckboxListTile( title: const Text("Do you want breakfast?"), value: wantsBreakFast, onChanged: (value) => setState(() { wantsBreakFast = !wantsBreakFast; })), CheckboxListTile( title: const Text("Do you want lunch?"), value: wantsLunch, onChanged: (value) => setState(() { wantsLunch = !wantsLunch; })), CheckboxListTile( title: const Text("Do you want dinner?"), value: wantsDinner, onChanged: (value) => setState(() { wantsDinner = !wantsDinner; })), ], ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/theme_changer/theme_changer_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:widget_app/config/theme/app_theme.dart'; import 'package:widget_app/presentation/providers/theme_provider.dart'; class ThemeChangerScreen extends ConsumerWidget { const ThemeChangerScreen({super.key}); static const String name = "theme_changer_screen"; @override Widget build(BuildContext context, WidgetRef ref) { final AppTheme appTheme = ref.watch(themeNotifierProvider); return Scaffold( appBar: AppBar( title: const Text("Theme Changer"), actions: [ IconButton( onPressed: () { ref.read(themeNotifierProvider.notifier).toggleDarkMode(); }, icon: Icon(appTheme.isDarkMode ? Icons.dark_mode_outlined : Icons.light_mode_outlined)) ], ), body: const _ThemeChangerView(), ); } } class _ThemeChangerView extends ConsumerWidget { const _ThemeChangerView({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final List<Color> colors = ref.watch(colorsListProvider); final AppTheme appTheme = ref.watch(themeNotifierProvider); return ListView.builder( itemCount: colors.length, itemBuilder: (context, index) { final color = colors[index]; return RadioListTile( title: Text( "This is the color", style: TextStyle(color: color), ), subtitle: Text('${color.value}'), activeColor: color, value: index, groupValue: appTheme.selectedColor, onChanged: (value) { ref.read(themeNotifierProvider.notifier).changeColorIndex(index); }, ); }, ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/app_tutorial/app_tutorial_screen.dart
import 'package:animate_do/animate_do.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; class SlideInfo { final String title; final String caption; final String imageUrl; SlideInfo(this.title, this.caption, this.imageUrl); } final slides = <SlideInfo>[ SlideInfo("Busca la comida", "caption", "assets/images/1.png"), SlideInfo("Entrega rapida", "caption", "assets/images/2.png"), SlideInfo("Disfruta la comida", "caption", "assets/images/3.png") ]; class AppTutorialScreen extends StatefulWidget { const AppTutorialScreen({super.key}); static const String name = "app_tutorial_screen"; @override State<AppTutorialScreen> createState() => _AppTutorialScreenState(); } class _AppTutorialScreenState extends State<AppTutorialScreen> { final PageController pageViewController = PageController(); bool endReached = false; double lastSlide = slides.length - 1.5; @override void initState() { super.initState(); pageViewController.addListener(() { final page = pageViewController.page ?? 0; if (!endReached && page >= lastSlide) { setState(() { endReached = true; }); } }); } @override void dispose() { pageViewController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final bgColor=Theme.of(context).colorScheme.background; return Scaffold( backgroundColor: bgColor, body: Stack( children: [ PageView( controller: pageViewController, physics: const BouncingScrollPhysics(), children: slides .map((slideItem) => _Slide( title: slideItem.title, caption: slideItem.caption, imageUrl: slideItem.imageUrl, )) .toList()), Positioned( right: 20, top: 50, child: TextButton( child: const Text("Exit"), onPressed: () => context.pop(), )), endReached ? Positioned( bottom: 30, right: 30, child: FadeInRight( from: 15, delay: const Duration(seconds: 1), child: FilledButton( child: const Text("Start"), onPressed: () {}, ), )) : const SizedBox() ], ), ); } } class _Slide extends StatelessWidget { final String title; final String caption; final String imageUrl; const _Slide( {required this.title, required this.caption, required this.imageUrl}); @override Widget build(BuildContext context) { final titleStyle = Theme.of(context).textTheme.titleLarge; final captionStyle = Theme.of(context).textTheme.bodySmall; return Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Image(image: AssetImage(imageUrl)), const SizedBox( height: 20, ), Text( title, style: titleStyle, ), const SizedBox( height: 20, ), Text( caption, style: captionStyle, ) ], ), ), ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/progress/progress_screen.dart
import 'package:flutter/material.dart'; class ProgressScreen extends StatelessWidget { const ProgressScreen({super.key}); static const String name = "progress_screen"; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Progress indicators"), ), body: const _ProgressView(), ); } } class _ProgressView extends StatelessWidget { const _ProgressView(); @override Widget build(BuildContext context) { return const Center( child: Column( children: [ SizedBox( width: 20, ), Text("Circular progress indicator"), SizedBox( width: 20, ), CircularProgressIndicator( strokeWidth: 2, backgroundColor: Colors.black45, ), SizedBox( width: 20, ), Text("Circular indicator controlado"), SizedBox( width: 20, ), _ControllerProgressIndicator() ], ), ); } } class _ControllerProgressIndicator extends StatelessWidget { const _ControllerProgressIndicator(); @override Widget build(BuildContext context) { return StreamBuilder( stream: Stream.periodic(const Duration(milliseconds: 300), (value) { return (value * 2) / 100; }).takeWhile((value) => value < 100), builder: (context, snapshot) { final progressValue = snapshot.data ?? 0; return Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ CircularProgressIndicator( value: progressValue, strokeWidth: 2, backgroundColor: Colors.black45, ), const SizedBox( width: 20, ), Expanded( child: LinearProgressIndicator( value:progressValue, )) ], ), ); }, ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/counter/counter_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:widget_app/presentation/providers/counter_provider.dart'; import 'package:widget_app/presentation/providers/theme_provider.dart'; class CounterScreen extends ConsumerWidget { const CounterScreen({super.key}); static const String name = "Counter Screen"; @override Widget build(BuildContext context, WidgetRef ref) { final int counter = ref.watch(counterProvider); final bool isDarkMode = ref.watch(isDarkModeProver); return Scaffold( appBar: AppBar( title: const Text("Counter Screen"), actions: [ IconButton( onPressed: () { ref.read(isDarkModeProver.notifier).update((state) => !state); }, icon: Icon(isDarkMode ? Icons.dark_mode_outlined : Icons.light_mode_outlined)) ], ), floatingActionButton: FloatingActionButton( onPressed: () { //Different way to do it // ref.read(counterProvider.notifier).update((state) => state + 1); ref.read(counterProvider.notifier).state++; }, child: const Icon(Icons.add), ), body: Container( alignment: Alignment.center, child: Text("Value: $counter", style: Theme.of(context).textTheme.titleLarge), ), ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/home/home_screen.dart
import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:widget_app/config/menu/menu_items.dart'; import 'package:widget_app/presentation/widgets/side_menu.dart'; class HomeScreen extends StatelessWidget { const HomeScreen({super.key}); static const String name = "home_screen"; @override Widget build(BuildContext context) { final scaffoldKey = GlobalKey<ScaffoldState>(); return Scaffold( key: scaffoldKey, appBar: AppBar(title: const Text("Flutter + Material 3")), body: const _HomeView(), drawer: SideMenu(scaffoldKey: scaffoldKey)); } } class _HomeView extends StatelessWidget { const _HomeView({super.key}); @override Widget build(BuildContext context) { const List<MenuItem> menuItems = appMenuItems; return ListView.builder( physics: const BouncingScrollPhysics(), itemCount: menuItems.length, itemBuilder: (context, index) { final menuItem = menuItems[index]; return _CustomListTile(menuItem: menuItem); }); } } class _CustomListTile extends StatelessWidget { const _CustomListTile({ super.key, required this.menuItem, }); final MenuItem menuItem; @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return ListTile( leading: Icon(menuItem.icon, color: colors.primary), trailing: Icon(Icons.arrow_forward_ios_outlined, color: colors.primary), title: Text(menuItem.title), subtitle: Text( menuItem.subTitle, style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w700), ), onTap: () { // Routing way 3: with Go_Router context.push(menuItem.link); /* Routing way 1: Navigator.pushNamed(context, menuItem.link); */ /* Routing way 2: This needs logic to control what page will be routed Navigator.of(context).push( MaterialPageRoute( builder: (context) => const ButtonsScreen(), ), ); */ }, ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/buttons/buttons_screen.dart
import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; class ButtonsScreen extends StatelessWidget { const ButtonsScreen({super.key}); static const String name = "buttons_screen"; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Buttons screen"), ), body: const _ButtonsView(), floatingActionButton: FloatingActionButton( child: const Icon(Icons.arrow_back_ios_new_outlined), onPressed: () { context.pop(); }, ), ); } } class _ButtonsView extends StatelessWidget { const _ButtonsView(); @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return SizedBox( width: double.infinity, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), child: Wrap( spacing: 10, alignment: WrapAlignment.center, children: [ ElevatedButton( onPressed: () {}, child: const Text("Elevated Button")), const ElevatedButton( onPressed: null, child: Text("Elevated Disable")), ElevatedButton.icon( onPressed: () {}, icon: const Icon(Icons.access_alarm_rounded), label: const Text("Elevated Icon")), FilledButton(onPressed: () {}, child: const Text("Filled")), FilledButton.icon( icon: const Icon(Icons.access_time), onPressed: () {}, label: const Text("Filled Icon")), OutlinedButton(onPressed: () {}, child: const Text("Outline")), OutlinedButton.icon( icon: const Icon(Icons.add_circle), onPressed: () {}, label: const Text("Outline Icon")), TextButton(onPressed: () {}, child: const Text("Text")), TextButton.icon( icon: const Icon(Icons.account_circle_sharp), onPressed: () {}, label: const Text("Text Icon")), IconButton( onPressed: () {}, icon: const Icon(Icons.app_registration_rounded)), IconButton( onPressed: () {}, icon: const Icon(Icons.ac_unit_sharp), style: ButtonStyle( backgroundColor: MaterialStatePropertyAll(colors.primary), iconColor: const MaterialStatePropertyAll(Colors.white)), ), const CustomButton() ], ), )); } } class CustomButton extends StatelessWidget { const CustomButton({super.key}); @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return ClipRRect( borderRadius: BorderRadius.circular(20), child: Material( color: colors.primary, child: InkWell( onTap: () {}, child: const Padding( padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), child: Text( "Custom Button", style: TextStyle(color: Colors.white), )), ), ), ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation/screens
mirrored_repositories/WidgetsApp/lib/presentation/screens/animated/animated_screen.dart
import 'package:flutter/material.dart'; import 'dart:math' show Random; class AnimatedScreen extends StatefulWidget { const AnimatedScreen({super.key}); static const String name = "animated_screen"; @override State<StatefulWidget> createState() => _AnimatedScreenState(); } class _AnimatedScreenState extends State<AnimatedScreen> { double width = 50; double height = 50; Color color = Colors.indigo; double borderRadius = 10.0; void changeShape() { final random = Random(); width = random.nextInt(400) + 50; height = random.nextInt(300) + 50; borderRadius = random.nextInt(50) + 5; color = Color.fromRGBO(random.nextInt(255), random.nextInt(255), random.nextInt(255), random.nextDouble()); setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Animated Container"), ), body: Center( child: AnimatedContainer( duration: const Duration(milliseconds: 500), curve: Curves.easeOutCubic, width: width <= 0 ? 0 : width, height: height <= 0 ? 0 : height, decoration: BoxDecoration( color: color, borderRadius: BorderRadius.circular(borderRadius < 0 ? 0 : borderRadius)), ), ), floatingActionButton: FloatingActionButton( onPressed: changeShape, child: const Icon(Icons.play_arrow_rounded), ), ); } }
0
mirrored_repositories/WidgetsApp/lib/presentation
mirrored_repositories/WidgetsApp/lib/presentation/providers/counter_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; final counterProvider=StateProvider<int>((ref) => 5);
0
mirrored_repositories/WidgetsApp/lib/presentation
mirrored_repositories/WidgetsApp/lib/presentation/providers/theme_provider.dart
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:widget_app/config/theme/app_theme.dart'; final isDarkModeProver = StateProvider<bool>( (ref) => false, ); final colorsListProvider = Provider((ref) => colorList); final selectedColorProvider = StateProvider<int>((ref) => 0); // Object App Theme final themeNotifierProvider = StateNotifierProvider<ThemeNotifier, AppTheme>((ref) => ThemeNotifier()); class ThemeNotifier extends StateNotifier<AppTheme> { ThemeNotifier() : super(AppTheme()); void toggleDarkMode() { state = state.copyWith(isDarkMode: !state.isDarkMode); } void changeColorIndex(int colorIndex) { state = state.copyWith(selectedColor: colorIndex); } }
0
mirrored_repositories/folka
mirrored_repositories/folka/lib/main.dart
import 'dart:io'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/screens/DetailsScreen.dart'; import 'package:folka/screens/FeedScreen.dart'; import 'package:folka/screens/HomeScreenIos.dart'; import 'package:folka/screens/LoginScreen.dart'; import 'package:folka/screens/SignUpScreen.dart'; import 'package:introduction_screen/introduction_screen.dart'; import 'package:provider/provider.dart'; import 'screens/HomeScreenAndroid.dart'; import 'package:flutter/services.dart'; import 'screens/IntroScreen.dart'; void main() => runApp(MyApp()); /* ______ ______ __ __ __ ______ /\ == \ /\ __ \ /\ \ /\ \/ / /\ __ \ \ \ _-/ \ \ \/\ \ \ \ \____ \ \ _"-. \ \ __ \ ru \ \_\ \ \_____\ \ \_____\ \ \_\ \_\ \ \_\ \_\ \/_/ \/_____/ \/_____/ \/_/\/_/ \/_/\/_/ \\|| ||\\ ______ __ __ ______ __ ______ /\ ___\ /\ \_\ \ /\ ___\ /\ \ /\ ___\ \ \___ \ \ \ __ \ \ \ __\ \ \ \____ \ \ __\ en \/\_____\ \ \_\ \_\ \ \_____\ \ \_____\ \ \_\ \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_/ */ class MyApp extends StatelessWidget { Widget _getScreenId() { return StreamBuilder<FirebaseUser>( stream: FirebaseAuth.instance.onAuthStateChanged, builder: (BuildContext context, snapshot) { if (snapshot.hasData) { Provider.of<UserData>(context).currentUserId = snapshot.data.uid; return Platform.isIOS ? HomeScreenIos() : HomeScreenAndroid(); } else { return IntroScreen(); } }, ); } // This widget is the root of your application. @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (context) => UserData(), child: MaterialApp( title: 'shelf', debugShowCheckedModeBanner: true, theme: ThemeData( brightness: Brightness.light, appBarTheme: Theme.of(context).appBarTheme.copyWith( color: Colors.white, ), primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith( color: Colors.black, ), floatingActionButtonTheme: Theme.of(context).floatingActionButtonTheme.copyWith( foregroundColor: Colors.black45 ), primaryColor: Colors.greenAccent, hintColor: Colors.black38, ), darkTheme: ThemeData( brightness: Brightness.dark, primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith( color: Colors.white, ), floatingActionButtonTheme: Theme.of(context).floatingActionButtonTheme.copyWith( foregroundColor: Colors.greenAccent[100] ), popupMenuTheme: Theme.of(context).popupMenuTheme.copyWith( color: CupertinoColors.darkBackgroundGray, ), hintColor: Colors.white38, ), home: _getScreenId(), routes: { LoginScreen.id: (context) => LoginScreen(), SignupScreen.id: (context) => SignupScreen(), FeedScreen.id: (context) => FeedScreen(), }, ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/widgets/PostView.dart
import 'dart:async'; import 'package:animator/animator.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/CommentsScreen.dart'; import 'package:folka/screens/DetailsScreen.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/services/DatabaseService.dart'; class PostView extends StatefulWidget { final String currentUserId; final Post post; final User author; PostView({this.currentUserId, this.post, this.author}); @override _PostViewState createState() => _PostViewState(); } class _PostViewState extends State<PostView> { int _likeCount = 0; bool _isLiked = false; bool _heartAnim = false; @override void initState() { super.initState(); _likeCount = widget.post.likeCount; _initPostLiked(); } @override void didUpdateWidget(PostView oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.post.likeCount != widget.post.likeCount) { _likeCount = widget.post.likeCount; } } _initPostLiked() async { bool isLiked = await DatabaseService.didLikePost( currentUserId: widget.currentUserId, post: widget.post, ); if (mounted) { setState(() { _isLiked = isLiked; }); } } _likePost() { if (_isLiked) { // Unlike Post DatabaseService.unlikePost( currentUserId: widget.currentUserId, post: widget.post); setState(() { _isLiked = false; _likeCount = _likeCount - 1; }); } else { // Like Post DatabaseService.likePost( currentUserId: widget.currentUserId, post: widget.post); setState(() { _heartAnim = true; _isLiked = true; _likeCount = _likeCount + 1; }); Timer(Duration(milliseconds: 350), () { setState(() { _heartAnim = false; }); }); } } pushToDetails() { Navigator.push( context, MaterialPageRoute( builder: (_) => DetailsScreen( //TODO make scan choose (to scan qr or give qr) post: widget.post, author: widget.author, authorScanBool: true, //likeCount: _likeCount, ), ), ); } @override Widget build(BuildContext context) { return GestureDetector( onTap: pushToDetails, child: Card( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), child: Column( children: <Widget>[ /*GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileScreen( currentUserId: widget.currentUserId, userId: widget.post.authorId, ), ), ), child: Container( padding: EdgeInsets.symmetric( horizontal: 16.0, vertical: 10.0, ), child: Row( children: <Widget>[ CircleAvatar( radius: 25.0, backgroundColor: Colors.grey, backgroundImage: widget.author.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider( widget.author.profileImageUrl), ), SizedBox(width: 8.0), Text( widget.author.name, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), SizedBox(width: 4.0), Text( widget.author.surname, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), ], ), ), ),*/ GestureDetector( onDoubleTap: _likePost, child: Stack( alignment: Alignment.center, children: <Widget>[ Container( height: 182, width: 400, //height: MediaQuery.of(context).size.width, decoration: BoxDecoration( borderRadius: BorderRadius.circular(14.0), image: DecorationImage( image: CachedNetworkImageProvider(widget.post.imageUrl), fit: BoxFit.cover, ), ), ), _heartAnim ? Animator( duration: Duration(milliseconds: 300), tween: Tween(begin: 0.5, end: 1.4), curve: Curves.elasticOut, builder: (anim) => Transform.scale( scale: anim.value, child: Icon( Icons.stars, size: 100.0, color: Colors.yellow[400], ), ), ) : SizedBox.shrink(), ], ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Stack( children: <Widget>[ Text( widget.post.name, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18.0, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ], ), Stack( children: <Widget>[ Row( children: <Widget>[ IconButton( icon: _isLiked ? Icon( Icons.star, color: Colors.yellow, ) : Icon(Icons.star_border), iconSize: 30.0, onPressed: _likePost, ), IconButton( icon: Icon(Icons.mail_outline), iconSize: 30.0, onPressed: () => Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: widget.post, likeCount: _likeCount, ), ), ), ), ], ), ], ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Stack( children: <Widget>[ Row( children: <Widget>[ Icon(Icons.attach_money, color: Colors.green,), Text( widget.post.price + 'RUB', style: TextStyle( color: Colors.green, fontSize: 16.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), Text(' per', style: TextStyle( fontFamily: 'ProductSans', ),), Icon(Icons.timer, color: Colors.blue,), Text( widget.post.time, style: TextStyle( color: Colors.blue, fontSize: 16.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ], ), ], ), Stack( children: <Widget>[ Padding( padding: EdgeInsets.symmetric(horizontal: 12.0), child: Text( '${_likeCount.toString()} stars', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.bold, ), ), ), ], ), ], ), SizedBox(height: 4.0), Row( children: <Widget>[ Container( margin: EdgeInsets.only( left: 12.0, right: 6.0, ), ), Expanded( child: Text( widget.post.caption, style: TextStyle( color: Colors.grey, fontSize: 16.0, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ), ], ), SizedBox(height: 12.0), ], ), ), ], ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/widgets/GridPostView.dart
import 'dart:async'; import 'package:animator/animator.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/CommentsScreen.dart'; import 'package:folka/screens/DetailsScreen.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/services/DatabaseService.dart'; class GridPostView extends StatefulWidget { final String currentUserId; final Post post; final User author; GridPostView({this.currentUserId, this.post, this.author}); @override _PostViewState createState() => _PostViewState(); } class _PostViewState extends State<GridPostView> { int _likeCount = 0; bool _isLiked = false; bool _heartAnim = false; @override void initState() { super.initState(); _likeCount = widget.post.likeCount; _initPostLiked(); } @override void didUpdateWidget(GridPostView oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.post.likeCount != widget.post.likeCount) { _likeCount = widget.post.likeCount; } } _initPostLiked() async { bool isLiked = await DatabaseService.didLikePost( currentUserId: widget.currentUserId, post: widget.post, ); if (mounted) { setState(() { _isLiked = isLiked; }); } } _likePost() { if (_isLiked) { // Unlike Post DatabaseService.unlikePost( currentUserId: widget.currentUserId, post: widget.post); setState(() { _isLiked = false; _likeCount = _likeCount - 1; }); } else { // Like Post DatabaseService.likePost( currentUserId: widget.currentUserId, post: widget.post); setState(() { _heartAnim = true; _isLiked = true; _likeCount = _likeCount + 1; }); Timer(Duration(milliseconds: 350), () { setState(() { _heartAnim = false; }); }); } } pushToDetails() { Navigator.push( context, MaterialPageRoute( builder: (_) => DetailsScreen( currentUserId: widget.currentUserId, post: widget.post, author: widget.author, authorScanBool: false, //likeCount: _likeCount, ), ), ); } @override Widget build(BuildContext context) { return GestureDetector( onTap: pushToDetails, child: Card( semanticContainer: true, clipBehavior: Clip.antiAliasWithSaveLayer, elevation: 1, margin: EdgeInsets.all(3), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), child: Container( width: 320, height: 320, child: Column( children: <Widget>[ GestureDetector( onDoubleTap: _likePost, child: Stack( alignment: Alignment.topCenter, children: <Widget>[ Container( height: 124, width: 224, //height: MediaQuery.of(context).size.width, decoration: BoxDecoration( borderRadius: BorderRadius.circular(14.0), image: DecorationImage( image: CachedNetworkImageProvider(widget.post.imageUrl), fit: BoxFit.cover, ), ), child: Padding( padding: const EdgeInsets.fromLTRB(0, 0, 0, 100), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Stack( children: <Widget>[ IconButton( icon: _isLiked ? Icon( Icons.star, color: Colors.yellow, ) : Icon(Icons.star_border), iconSize: 25.0, color: Colors.greenAccent, onPressed: _likePost, ), ], ), Stack( children: <Widget>[ IconButton( icon: Icon(Icons.mail_outline), iconSize: 25.0, color: Colors.greenAccent, onPressed: () => Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: widget.post, likeCount: _likeCount, ), ), ), ), ], ), ], ), ), ), _heartAnim ? Animator( duration: Duration(milliseconds: 300), tween: Tween(begin: 0.5, end: 1.4), curve: Curves.elasticOut, builder: (anim) => Transform.scale( scale: anim.value, child: Icon( Icons.stars, size: 100.0, color: Colors.yellow[400], ), ), ) : SizedBox.shrink(), ], ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 8.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ /*Row( children: <Widget>[ IconButton( icon: _isLiked ? Icon( Icons.star, color: Colors.yellow, ) : Icon(Icons.star_border), iconSize: 30.0, onPressed: _likePost, ), IconButton( icon: Icon(Icons.mail_outline), iconSize: 30.0, onPressed: () => Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: widget.post, likeCount: _likeCount, ), ), ), ), Text( widget.post.name, style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.bold, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ], ),*/ SizedBox(height: 2,), Text( widget.post.name, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 18, fontFamily: 'ProductSans', //color: Colors.black, ), ), SizedBox(height: 2,), Row( children: <Widget>[ Icon(Icons.attach_money, color: Colors.green,), Text( widget.post.price + 'RUB', style: TextStyle( color: Colors.green, fontSize: 16.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), Text(' per', style: TextStyle(fontFamily: 'ProductSans'),), Icon(Icons.timer, color: Colors.blue,), Text( widget.post.time, style: TextStyle( color: Colors.blue, fontSize: 16.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ], ), Padding( padding: const EdgeInsets.only(left: 4.0), child: Text( widget.post.caption, style: TextStyle( color: Colors.grey, fontSize: 14.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ), /*Padding( padding: EdgeInsets.symmetric(horizontal: 12.0), child: Text( '${_likeCount.toString()} stars', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.bold, ), ), ),*/ //SizedBox(height: 4.0), ], ), ), ], ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/widgets/HidingAppBar.dart
import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; Widget HidingAppBar({bool forceElevated}) { if (Platform.isIOS) { return CupertinoSliverNavigationBar( largeTitle: Text('shelf'), backgroundColor: Colors.greenAccent, ); } else if(Platform.isAndroid) { return new SliverAppBar( //bottomOpacity: 0.0, expandedHeight: 6, elevation: 0, //centerTitle: true, backgroundColor: Colors.transparent, title: Text( 'shelf', style: TextStyle( //color: Colors.black, fontFamily: 'ProductSans', fontSize: 24.0 ), ), pinned: false, //<-- pinned to true floating: false, //<-- floating to true forceElevated: forceElevated, //<-- forceElevated to innerBoxIsScrolled ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/widgets/SearchPostView.dart
import 'dart:async'; import 'package:animator/animator.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/CommentsScreen.dart'; import 'package:folka/screens/DetailsScreen.dart'; import 'package:folka/screens/SearchScreen.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/services/DatabaseService.dart'; class SearchPostView extends StatefulWidget { final String currentUserId; final Post post; final User author; SearchPostView({this.currentUserId, this.post, this.author}); @override _PostViewState createState() => _PostViewState(); } class _PostViewState extends State<SearchPostView> { int _likeCount = 0; bool _isLiked = false; bool _heartAnim = false; @override void initState() { super.initState(); _likeCount = widget.post.likeCount; _initPostLiked(); } @override void didUpdateWidget(SearchPostView oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.post.likeCount != widget.post.likeCount) { _likeCount = widget.post.likeCount; } } _initPostLiked() async { bool isLiked = await DatabaseService.didLikePost( currentUserId: widget.currentUserId, post: widget.post, ); if (mounted) { setState(() { _isLiked = isLiked; }); } } _likePost() { if (_isLiked) { // Unlike Post DatabaseService.unlikePost( currentUserId: widget.currentUserId, post: widget.post); setState(() { _isLiked = false; _likeCount = _likeCount - 1; }); } else { // Like Post DatabaseService.likePost( currentUserId: widget.currentUserId, post: widget.post); setState(() { _heartAnim = true; _isLiked = true; _likeCount = _likeCount + 1; }); Timer(Duration(milliseconds: 350), () { setState(() { _heartAnim = false; }); }); } } pushToDetails() { Navigator.push( context, MaterialPageRoute( builder: (_) => DetailsScreen( post: widget.post, author: widget.author, authorScanBool: false, //author: widget.author, //likeCount: _likeCount, ), ), ); } @override Widget build(BuildContext context) { return GestureDetector( onTap: pushToDetails, child: Container( child: Card( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), child: Column( children: <Widget>[ /*GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileScreen( currentUserId: widget.currentUserId, userId: widget.post.authorId, ), ), ), child: Container( padding: EdgeInsets.symmetric( horizontal: 16.0, vertical: 10.0, ), child: Row( children: <Widget>[ CircleAvatar( radius: 25.0, backgroundColor: Colors.grey, backgroundImage: widget.author.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider( widget.author.profileImageUrl), ), SizedBox(width: 8.0), Text( widget.author.name, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), SizedBox(width: 4.0), Text( widget.author.surname, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), ], ), ), ),*/ GestureDetector( onDoubleTap: _likePost, child: Stack( alignment: Alignment.center, children: <Widget>[ Container( height: 282, width: 450, //height: MediaQuery.of(context).size.width, decoration: BoxDecoration( borderRadius: BorderRadius.circular(14.0), image: DecorationImage( image: CachedNetworkImageProvider(widget.post.imageUrl), fit: BoxFit.cover, ), ), ), _heartAnim ? Animator( duration: Duration(milliseconds: 300), tween: Tween(begin: 0.5, end: 1.4), curve: Curves.elasticOut, builder: (anim) => Transform.scale( scale: anim.value, child: Icon( Icons.stars, size: 100.0, color: Colors.yellow[400], ), ), ) : SizedBox.shrink(), ], ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Stack( children: <Widget>[ Text( widget.post.name, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18.0, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ], ), Stack( children: <Widget>[ Row( children: <Widget>[ IconButton( icon: _isLiked ? Icon( Icons.star, color: Colors.yellow, ) : Icon(Icons.star_border), iconSize: 30.0, onPressed: _likePost, ), IconButton( icon: Icon(Icons.mail_outline), iconSize: 30.0, onPressed: () => Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: widget.post, likeCount: _likeCount, ), ), ), ), ], ), ], ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Stack( children: <Widget>[ Row( children: <Widget>[ Icon(Icons.attach_money, color: Colors.green,), Text( widget.post.price + 'RUB', style: TextStyle( color: Colors.green, fontSize: 16.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), Text(' per', style: TextStyle( fontFamily: 'ProductSans', ),), Icon(Icons.timer, color: Colors.blue,), Text( widget.post.time, style: TextStyle( color: Colors.blue, fontSize: 16.0, fontWeight: FontWeight.w400, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ], ), ], ), Stack( children: <Widget>[ Padding( padding: EdgeInsets.symmetric(horizontal: 12.0), child: Text( '${_likeCount.toString()} stars', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.bold, ), ), ), ], ), ], ), SizedBox(height: 4.0), Row( children: <Widget>[ Container( margin: EdgeInsets.only( left: 12.0, right: 6.0, ), ), Expanded( child: Text( widget.post.caption, style: TextStyle( color: Colors.grey, fontSize: 16.0, fontFamily: 'ProductSans' ), overflow: TextOverflow.ellipsis, ), ), ], ), SizedBox(height: 12.0), ], ), ), ], ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/utilities/Constants.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_storage/firebase_storage.dart'; final _firestore = Firestore.instance; final storageRef = FirebaseStorage.instance.ref(); final usersRef = _firestore.collection('users'); final postsRef = _firestore.collection('posts'); final feedRef = _firestore.collection('feed'); final followersRef = _firestore.collection('followers'); final followingRef = _firestore.collection('following'); final feedsRef = _firestore.collection('feeds'); final likesRef = _firestore.collection('likes'); final favouriteRef = _firestore.collection('favourite'); final commentsRef = _firestore.collection('comments'); final activitiesRef = _firestore.collection('activities'); final ratingRef = _firestore.collection('rating');
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/models/Post.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class Post { final String id; final String imageUrl; final String caption; final String category; final String price; final String name; final String time; final String location; final int likeCount; final String authorId; final Timestamp timestamp; Post({ this.id, this.imageUrl, this.caption, this.category, this.price, this.name, this.time, this.location, this.likeCount, this.authorId, this.timestamp, }); factory Post.fromDoc(DocumentSnapshot doc) { return Post( id: doc.documentID, imageUrl: doc['imageUrl'], caption: doc['caption'], category: doc['category'], price: doc['price'], name: doc['name'], time: doc['time'], location: doc['location'], likeCount: doc['likeCount'], authorId: doc['authorId'], timestamp: doc['timestamp'], ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/models/User.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class User { final String id; final String name; final String surname; final String birthdate; final String address; final String rating; final String profileImageUrl; final String email; final String phone; final String bio; User({ this.id, this.name, this.surname, this.birthdate, this.address, this.rating, this.profileImageUrl, this.email, this.phone, this.bio, }); factory User.fromDoc(DocumentSnapshot doc) { return User( id: doc.documentID, name: doc['name'], surname: doc['surname'], birthdate: doc['bithdate'], address: doc['address'], rating: doc['rating'], profileImageUrl: doc['profileImageUrl'], email: doc['email'], phone: doc['phone'], bio: doc['bio'] ?? '', ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/models/UserData.dart
import 'package:flutter/foundation.dart'; class UserData extends ChangeNotifier { String currentUserId; }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/models/Activity.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class Activity { final String id; final String fromUserId; final String postId; final String postImageUrl; final String comment; final Timestamp timestamp; Activity({ this.id, this.fromUserId, this.postId, this.postImageUrl, this.comment, this.timestamp, }); factory Activity.fromDoc(DocumentSnapshot doc) { return Activity( id: doc.documentID, fromUserId: doc['fromUserId'], postId: doc['postId'], postImageUrl: doc['postImageUrl'], comment: doc['comment'], timestamp: doc['timestamp'], ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/models/Comment.dart
import 'package:cloud_firestore/cloud_firestore.dart'; class Comment { final String id; final String content; final String authorId; final Timestamp timestamp; Comment({ this.id, this.content, this.authorId, this.timestamp, }); factory Comment.fromDoc(DocumentSnapshot doc) { return Comment( id: doc.documentID, content: doc['content'], authorId: doc['authorId'], timestamp: doc['timestamp'], ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/services/AuthService.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/UserData.dart'; import 'package:provider/provider.dart'; class AuthService { static final _auth = FirebaseAuth.instance; static final _firestore = Firestore.instance; static void signUpUser( BuildContext context, String name, String surname, String birthdate, String address, String email, String phone, String password) async { try { AuthResult authResult = await _auth.createUserWithEmailAndPassword( email: email, password: password, ); FirebaseUser signedInUser = authResult.user; if (signedInUser != null) { _firestore.collection('/users').document(signedInUser.uid).setData({ 'name': name, 'surname': surname, 'birthdate': birthdate, 'address': address, 'email': email, 'phone': phone, 'profileImageUrl': '', }); Provider.of<UserData>(context).currentUserId = signedInUser.uid; Navigator.pop(context); } } catch (e) { print(e); } } static void logout() { _auth.signOut(); } static void login(String email, String password) async { try { await _auth.signInWithEmailAndPassword(email: email, password: password); } catch (e) { print(e); } } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/services/ShareService.dart
import 'package:flutter/material.dart'; import 'package:share/share.dart'; share(BuildContext context, String text) { final RenderBox box = context.findRenderObject(); Share.share( text, sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size ); }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/services/StorageService.dart
import 'dart:io'; import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter_image_compress/flutter_image_compress.dart'; import 'package:folka/utilities/Constants.dart'; import 'package:path_provider/path_provider.dart'; import 'package:uuid/uuid.dart'; class StorageService { static Future<String> uploadUserProfileImage( String url, File imageFile) async { String photoId = Uuid().v4(); File image = await compressImage(photoId, imageFile); if (url.isNotEmpty) { // Updating user profile image RegExp exp = RegExp(r'userProfile_(.*).jpg'); photoId = exp.firstMatch(url)[1]; } StorageUploadTask uploadTask = storageRef .child('images/users/userProfile_$photoId.jpg') .putFile(image); StorageTaskSnapshot storageSnap = await uploadTask.onComplete; String downloadUrl = await storageSnap.ref.getDownloadURL(); return downloadUrl; } static Future<File> compressImage(String photoId, File image) async { final tempDir = await getTemporaryDirectory(); final path = tempDir.path; File compressedImageFile = await FlutterImageCompress.compressAndGetFile( image.absolute.path, '$path/img_$photoId.jpg', quality: 70, ); return compressedImageFile; } static Future<String> uploadPost(File imageFile) async { String photoId = Uuid().v4(); File image = await compressImage(photoId, imageFile); StorageUploadTask uploadTask = storageRef .child('images/posts/post_$photoId.jpg') .putFile(image); StorageTaskSnapshot storageSnap = await uploadTask.onComplete; String downloadUrl = await storageSnap.ref.getDownloadURL(); return downloadUrl; } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/services/DatabaseService.dart
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:folka/models/Activity.dart'; import 'package:folka/models/Comment.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/utilities/Constants.dart'; import 'package:intl/intl.dart'; import 'package:uuid/uuid.dart'; class DatabaseService { static void updateUser(User user) { usersRef.document(user.id).updateData({ 'name': user.name, 'surname': user.surname, 'profileImageUrl': user.profileImageUrl, 'bio': user.bio, 'address': user.address, }); } static Future<QuerySnapshot> searchUsers(String name) { Future<QuerySnapshot> users = usersRef.where('name', isGreaterThanOrEqualTo: name).getDocuments(); return users; } static Future<QuerySnapshot> searchPosts(String name) { Future<QuerySnapshot> posts = feedRef.where('name', isGreaterThanOrEqualTo: name).getDocuments(); //usersRef.where('name', isGreaterThanOrEqualTo: name).getDocuments(); return posts; } static void createPost(Post post) { postsRef.document(post.authorId).collection('userPosts').add({ 'imageUrl': post.imageUrl, 'caption': post.caption, 'name': post.name, 'price': post.price, 'time': post.time, 'category': post.category, 'likeCount': post.likeCount, 'location': post.location, 'authorId': post.authorId, 'timestamp': post.timestamp, }); } static void createFeedPost(Post post) { feedRef.document(Uuid().v4()).setData({ 'imageUrl': post.imageUrl, 'caption': post.caption, 'name': post.name, 'price': post.price, 'time': post.time, 'category': post.category, 'likeCount': post.likeCount, 'location': post.location, 'authorId': post.authorId, 'timestamp': post.timestamp, }); } static void followUser({String currentUserId, String userId}) { // Add user to current user's following collection followingRef .document(currentUserId) .collection('userFollowing') .document(userId) .setData({}); // Add current user to user's followers collection followersRef .document(userId) .collection('userFollowers') .document(currentUserId) .setData({}); } static void unFollowUser({String currentUserId, String userId}) { // Remove user from current user's following collection followingRef .document(currentUserId) .collection('userFollowing') .document(userId) .get() .then((doc) { if (doc.exists) { doc.reference.delete(); } }); // Remove current user from user's followers collection followersRef .document(userId) .collection('userFollowers') .document(currentUserId) .get() .then((doc) { if (doc.exists) { doc.reference.delete(); } }); } static Future<bool> isFollowingUser( {String currentUserId, String userId}) async { DocumentSnapshot followingDoc = await followersRef .document(userId) .collection('userFollowers') .document(currentUserId) .get(); return followingDoc.exists; } static Future<int> numFollowing(String userId) async { QuerySnapshot followingSnapshot = await followingRef .document(userId) .collection('userFollowing') .getDocuments(); return followingSnapshot.documents.length; } static Future<int> numFollowers(String userId) async { QuerySnapshot followersSnapshot = await followersRef .document(userId) .collection('userFollowers') .getDocuments(); return followersSnapshot.documents.length; } static Future<List<Post>> getFeedPosts(String userId) async { QuerySnapshot feedSnapshot = await feedsRef .document(userId) .collection('userFeed') .orderBy('timestamp', descending: true) .getDocuments(); List<Post> posts = feedSnapshot.documents.map((doc) => Post.fromDoc(doc)).toList(); return posts; } static Future<List<Post>> getFavouritePosts(String userId) async { QuerySnapshot userPostsSnapshot = await favouriteRef .document(userId) .collection('favouritePosts') .orderBy('timestamp', descending: true) .getDocuments(); List<Post> posts = userPostsSnapshot.documents.map((doc) => Post.fromDoc(doc)).toList(); return posts; } static Future<List<Post>> getUserPosts(String userId) async { QuerySnapshot userPostsSnapshot = await postsRef .document(userId) .collection('userPosts') .orderBy('timestamp', descending: true) .getDocuments(); List<Post> posts = userPostsSnapshot.documents.map((doc) => Post.fromDoc(doc)).toList(); return posts; } static Future<List<Post>> getAllUserPosts() async { QuerySnapshot userPostsSnapshot = await feedRef .where('authorId') .where('price') .where('time') .where('caption') .orderBy('timestamp', descending: true) .getDocuments(); List<Post> posts = userPostsSnapshot.documents.map((doc) => Post.fromDoc(doc)).toList(); return posts; } static Future<User> getUserWithId(String userId) async { DocumentSnapshot userDocSnapshot = await usersRef.document(userId).get(); if (userDocSnapshot.exists) { return User.fromDoc(userDocSnapshot); } return User(); } static void likePost({String currentUserId, Post post}) { DocumentReference postRef = postsRef .document(post.authorId) .collection('userPosts') .document(post.id); favouriteRef.document(currentUserId).collection('favouritePosts').add({ 'imageUrl': post.imageUrl, 'caption': post.caption, 'name': post.name, 'price': post.price, 'time': post.time, 'category': post.category, 'likeCount': post.likeCount, 'location': post.location, 'authorId': post.authorId, 'timestamp': post.timestamp, }); postRef.get().then((doc) { int likeCount = doc.data['likeCount']; postRef.updateData({'likeCount': likeCount + 1}); likesRef .document(post.id) .collection('postLikes') .document(currentUserId) .setData({}); addActivityItem(currentUserId: currentUserId, post: post, comment: null); }); } static void unlikePost({String currentUserId, Post post}) { DocumentReference postRef = postsRef .document(post.authorId) .collection('userPosts') .document(post.id); favouriteRef .document(currentUserId) .collection('favouritePosts') .document(post.id) .get() .then((doc) { if (doc.exists) { doc.reference.delete(); } }); postRef.get().then((doc) { int likeCount = doc.data['likeCount']; postRef.updateData({'likeCount': likeCount - 1}); likesRef .document(post.id) .collection('postLikes') .document(currentUserId) .get() .then((doc) { if (doc.exists) { doc.reference.delete(); } }); }); } static Future<bool> didLikePost({String currentUserId, Post post}) async { DocumentSnapshot userDoc = await likesRef .document(post.id) .collection('postLikes') .document(currentUserId) .get(); return userDoc.exists; } static void commentOnPost( {String currentUserId, Post post, String comment}) { commentsRef.document(post.id).collection('postComments').add({ 'content': comment, 'authorId': currentUserId, 'timestamp': Timestamp.fromDate(DateTime.now()), }); addActivityItem(currentUserId: currentUserId, post: post, comment: comment); } static void addActivityItem( {String currentUserId, Post post, String comment}) { if (currentUserId != post.authorId) { activitiesRef.document(post.authorId).collection('userActivities').add({ 'fromUserId': currentUserId, 'postId': post.id, 'postImageUrl': post.imageUrl, 'comment': comment, 'timestamp': Timestamp.fromDate(DateTime.now()), }); } } static Future<List<Activity>> getActivities(String userId) async { QuerySnapshot userActivitiesSnapshot = await activitiesRef .document(userId) .collection('userActivities') .orderBy('timestamp', descending: true) .getDocuments(); List<Activity> activity = userActivitiesSnapshot.documents .map((doc) => Activity.fromDoc(doc)) .toList(); return activity; } static Future<Post> getUserPost(String userId, String postId) async { DocumentSnapshot postDocSnapshot = await postsRef .document(userId) .collection('userPosts') .document(postId) .get(); return Post.fromDoc(postDocSnapshot); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/SearchScreen.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/DetailsScreen.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/widgets/GridPostView.dart'; import 'package:folka/widgets/PostView.dart'; import 'package:folka/widgets/SearchPostView.dart'; import 'package:provider/provider.dart'; import 'ProfleSmbScreen.dart'; class SearchScreen extends StatefulWidget { @override _SearchScreenState createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { TextEditingController _searchController = TextEditingController(); Future<QuerySnapshot> _users; Future<QuerySnapshot> _posts; /*_buildUserTile(User user) { return ListTile( leading: CircleAvatar( radius: 20.0, backgroundImage: user.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider(user.profileImageUrl), ), title: Text(user.name), onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileSMDScreen( currentUserId: Provider.of<UserData>(context).currentUserId, userId: user.id, ), ), ), ); }*/ _buildPostTile(Post post) { return PostView( post: post, ); } _clearSearch() { WidgetsBinding.instance .addPostFrameCallback((_) => _searchController.clear()); setState(() { //_users = null; _posts = null; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, bottomOpacity: 0.0, elevation: 0, title: TextField( controller: _searchController, decoration: InputDecoration( contentPadding: EdgeInsets.symmetric(vertical: 15.0), border: InputBorder.none, hintText: 'Search', hintStyle: TextStyle(fontFamily: 'ProductSans'), prefixIcon: Icon( Icons.search, //color: Colors.grey, size: 30.0, ), suffixIcon: IconButton( icon: Icon( Icons.clear, //color: Colors.grey, ), onPressed: _clearSearch, ), filled: true, ), onSubmitted: (input) { if (input.isNotEmpty) { setState(() { //_users = DatabaseService.searchUsers(input); _posts = DatabaseService.searchPosts(input); }); } }, ), ), //body: _users == null body: _posts == null ? Center( child: Padding( padding: const EdgeInsets.all(8.0), child: OrientationBuilder( builder: (context, orentation) { return Container( height: 520, width: orentation == Orientation.portrait ? 350 : 220, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Container( child: Image.asset('assets/images/search.png')), Text('Search for something or somebody', style: TextStyle(fontFamily: 'ProductSans'),), ], ), ); }, ), ), ) : FutureBuilder( //future: _users, future: _posts, builder: (context, snapshot) { if (!snapshot.hasData) { return Center( child: CircularProgressIndicator(), ); } if (snapshot.data.documents.length == 0) { return Center( child: Padding( padding: const EdgeInsets.all(8.0), child: OrientationBuilder( builder: (context, orentation) { return Container( height: 320, width: orentation == Orientation.portrait ? 420 : 220, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Image.asset('assets/images/notfound.png'), Text('Nothing found, try again later', style: TextStyle(fontFamily: 'ProductSans'),), ], ), ); }, ), ), ); } //User author = snapshot.data; return OrientationBuilder( builder: (context, orentation) { return GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: orentation == Orientation.portrait ? 1 : 2,), itemCount: snapshot.data.documents.length, itemBuilder: (BuildContext context, int index) { Post post = Post.fromDoc(snapshot.data.documents[index]); //User author; return FutureBuilder( future: DatabaseService.getUserWithId(post.authorId), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return SizedBox.shrink(); } User author = snapshot.data; return SearchPostView( //currentUserId: widget.currentUserId, post: post, author: author, ); } ); }, ); },); /*return ListView.builder( itemCount: snapshot.data.documents.length, itemBuilder: (BuildContext context, int index) { User user = User.fromDoc(snapshot.data.documents[index]); return _buildUserTile(user); }, );*/ }, ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/HomeScreenAndroid.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/screens/ActivityScreen.dart'; import 'package:folka/screens/CreatePostScreen.dart'; import 'package:folka/screens/FeedScreen.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/screens/SearchScreen.dart'; import 'package:folka/services/AuthService.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; import 'package:provider/provider.dart'; import 'package:quick_actions/quick_actions.dart'; class HomeScreenAndroid extends StatefulWidget { @override _HomeScreenAndroidState createState() => _HomeScreenAndroidState(); } class _HomeScreenAndroidState extends State<HomeScreenAndroid> { int bottomSelectedIndex = 0; bool nav; PageController pageController = PageController( initialPage: 0, keepPage: true, ); final QuickActions _quickActions = QuickActions(); @override Future<void> initState() { super.initState(); //WidgetsBinding.instance.renderView.automaticSystemUiAdjustment=false; //<-- SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( //statusBarColor: Colors.transparent, systemNavigationBarIconBrightness: Brightness.dark, statusBarIconBrightness: Brightness.dark, ), ); //SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); FlutterStatusbarcolor.setStatusBarColor(Colors.transparent); FlutterStatusbarcolor.setNavigationBarColor(Colors.greenAccent); FlutterStatusbarcolor.setNavigationBarWhiteForeground(false); //FlutterStatusbarcolor.setStatusBarWhiteForeground(false); /*if (useWhiteForeground(Colors.greenAccent)) { FlutterStatusbarcolor.setStatusBarWhiteForeground(false); FlutterStatusbarcolor.setNavigationBarWhiteForeground(false); } else { FlutterStatusbarcolor.setStatusBarWhiteForeground(false); FlutterStatusbarcolor.setNavigationBarWhiteForeground(false); }*/ _quickActions.initialize((String shortcut) { print(shortcut); if (shortcut != null) { if (shortcut == 'add') { pageChanged(2); } else if (shortcut == 'search') { pageChanged(1); } else if (shortcut == 'mail') { pageChanged(3); } else if (shortcut == 'account') { pageChanged(4); } else { debugPrint('No one shortcut selected'); } } }); _quickActions.setShortcutItems( <ShortcutItem>[ const ShortcutItem( type: 'add', localizedTitle: 'Add', icon: 'add', ), const ShortcutItem( type: 'search', localizedTitle: 'Search', icon: 'searchs', ), const ShortcutItem( type: 'mail', localizedTitle: 'Mail', icon: 'mail', ), const ShortcutItem( type: 'account', localizedTitle: 'Account', icon: 'account', ), ], ); } pageView(String currentUserId) { return PageView( controller: pageController, onPageChanged: (index) { pageChanged(index); }, children: <Widget>[ FeedScreen(currentUserId: currentUserId), SearchScreen(), CreatePostScreen(currentUserId: currentUserId, userId: currentUserId,), ActivityScreen(currentUserId: currentUserId), ProfileScreen(currentUserId: currentUserId, userId: currentUserId,), ], ); } void pageChanged(int index) { setState(() { bottomSelectedIndex = index; }); } void bottomTapped(int index) { setState(() { bottomSelectedIndex = index; pageController.animateToPage(index, duration: Duration(milliseconds: 500), curve: Curves.ease); }); } void _onItemTapped(index) { setState(() { pageController = index; }); } buildPageView(String currentUserId) { return PageView( controller: pageController, onPageChanged: (index) { pageChanged(index); }, children: <Widget>[ FeedScreen(currentUserId: currentUserId), SearchScreen(), CreatePostScreen(currentUserId: currentUserId, userId: currentUserId,), ActivityScreen(currentUserId: currentUserId), ProfileScreen(currentUserId: currentUserId, userId: currentUserId,), ], ); } @override Widget build(BuildContext context) { final String currentUserId = Provider.of<UserData>(context).currentUserId; return Scaffold( extendBody: true, /*appBar: AppBar( /*shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(30.0), ), ),*/ bottomOpacity: 0.0, elevation: 0, //centerTitle: true, backgroundColor: Colors.transparent, title: Text( 'shelf', style: TextStyle( //color: Colors.black, fontFamily: 'ProductSans', fontSize: 24.0 ), ), /*leading: Padding( padding: const EdgeInsets.all(4.0), child: new IconButton( icon: Image.asset('assets/images/bookcase.png'), onPressed: null ), ),*/ /*actions: <Widget>[ IconButton( icon: Icon(Icons.exit_to_app, /*color: Colors.black,*/), onPressed: AuthService.logout, ) ],*/ ),*/ body: OrientationBuilder( builder: (context, orientation){ if (orientation == Orientation.portrait) { return pageView(currentUserId); } else { return Row( children: <Widget>[ Expanded( child: pageView(currentUserId), ), NavigationRail( extended: false, groupAlignment: 0, selectedIndex: bottomSelectedIndex, onDestinationSelected: (int index){ setState(() { bottomTapped(index); }); }, labelType: NavigationRailLabelType.none, backgroundColor: Colors.greenAccent, selectedLabelTextStyle: TextStyle(fontFamily: 'ProductSans', color: Colors.black), selectedIconTheme: IconThemeData(color: Colors.black), unselectedLabelTextStyle: TextStyle(fontFamily: 'ProductSans', color: Colors.black), unselectedIconTheme: IconThemeData(color: Colors.black38), destinations: [ NavigationRailDestination( icon: Tooltip(message: 'Home', child: Icon(Icons.business)), selectedIcon: Tooltip(message: 'Home', child: Icon(Icons.business,)), label: Text('Home',), ), NavigationRailDestination( icon: Tooltip(message: 'Search', child: Icon(Icons.search)), selectedIcon: Icon(Icons.search,), label: Tooltip(message: 'Search', child: Text('Search',)), ), NavigationRailDestination( icon: Tooltip(message: 'Add', child: FloatingActionButton( tooltip: 'Add', backgroundColor: Colors.black54, onPressed: () { setState(() { pageController.jumpToPage(2); }); }, child: Icon( OMIcons.add, color: Colors.greenAccent, ), // elevation: 5.0, ),), selectedIcon: FloatingActionButton( tooltip: 'Add', backgroundColor: Colors.black87, onPressed: () { setState(() { pageController.jumpToPage(2); }); }, child: Icon( OMIcons.add, color: Colors.greenAccent, ), // elevation: 5.0, ), label: Text('Add',), ), NavigationRailDestination( icon: Tooltip(message: 'Activity', child: Icon(Icons.mail_outline)), selectedIcon: Icon(Icons.mail_outline,), label: Tooltip(message: 'Activity', child: Text('Activity',)), ), NavigationRailDestination( icon: Tooltip(message: 'Profile', child: Icon(Icons.person_outline)), selectedIcon: Icon(Icons.person_outline,), label: Tooltip(message: 'Profile', child: Text('Profile',)), ), ], ), VerticalDivider(thickness: 0, width: 0,), ], ); } } ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, bottomNavigationBar: OrientationBuilder( builder: (context, orentation) { if (orentation == Orientation.portrait) { return BottomAppBar( shape: CircularNotchedRectangle(), notchMargin: 6, clipBehavior: Clip.antiAlias, child: BottomNavigationBar( onTap: (index) { bottomTapped(index); _onItemTapped(index); }, showSelectedLabels: false, showUnselectedLabels: false, type: BottomNavigationBarType.fixed, backgroundColor: Colors.greenAccent, items: [ BottomNavigationBarItem( icon: Tooltip(message: 'Home', child: Icon(Icons.domain, color: Colors.black38,)), title: Text('Home'), activeIcon: Tooltip(message: 'Home', child: Icon(Icons.domain, color: Colors.black,)), ), BottomNavigationBarItem( icon: Tooltip(message: 'Search', child: Icon(Icons.search, color: Colors.black38,)), title: Text('Search'), activeIcon: Tooltip(message: 'Search', child: Icon(Icons.search, color: Colors.black,)), ), BottomNavigationBarItem( icon: Icon(Icons.add_circle_outline, color: Colors.transparent,), title: Text('Add'), ), BottomNavigationBarItem( icon: Tooltip(message: 'Activity', child: Icon(Icons.mail_outline, color: Colors.black38,)), title: Text('Activity'), activeIcon: Tooltip(message: 'Activity', child: Icon(Icons.mail_outline, color: Colors.black,)), ), BottomNavigationBarItem( icon: Tooltip(message: 'Profile', child: Icon(Icons.person_outline, color: Colors.black38,)), title: Text('Profile'), activeIcon: Tooltip(message: 'Profile', child: Icon(Icons.person_outline, color: Colors.black,)), ), ], selectedItemColor: Colors.black87, currentIndex: bottomSelectedIndex, ), ); } else { return BottomAppBar(); } } ), floatingActionButton: OrientationBuilder( builder: (context, orentation) { if (orentation == Orientation.portrait) { return Container( height: 60.0, width: 60.0, child: FittedBox( child: FloatingActionButton( tooltip: 'Add', backgroundColor: Colors.greenAccent[100], onPressed: () { setState(() { pageController.jumpToPage(2); }); }, child: Icon( OMIcons.add, color: Colors.black, ), // elevation: 5.0, ), ), ); } else { return Container(); } } ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/ProfileScreen.dart
import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/EditProfileScreen.dart'; import 'package:folka/services/AuthService.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/utilities/Constants.dart'; import 'package:folka/widgets/HidingAppBar.dart'; import 'package:folka/widgets/PostView.dart'; import 'package:folka/widgets/SearchPostView.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; import 'package:provider/provider.dart'; import 'CommentsScreen.dart'; class ProfileScreen extends StatefulWidget { final String currentUserId; final String userId; ProfileScreen({this.currentUserId, this.userId}); @override _ProfileScreenState createState() => _ProfileScreenState(); } enum WhyFarther { settings, exit} class _ProfileScreenState extends State<ProfileScreen> { bool _isFollowing = false; int _followerCount = 0; int _followingCount = 0; List<Post> _posts = []; int _displayPosts = 0; // 0 - grid, 1 - column User _profileUser; WhyFarther _selection; @override void initState() { super.initState(); _setupIsFollowing(); _setupFollowers(); _setupFollowing(); _setupPosts(); _setupFavourite(); _setupProfileUser(); } _setupIsFollowing() async { bool isFollowingUser = await DatabaseService.isFollowingUser( currentUserId: widget.currentUserId, userId: widget.userId, ); setState(() { _isFollowing = isFollowingUser; }); } _setupFollowers() async { int userFollowerCount = await DatabaseService.numFollowers(widget.userId); setState(() { _followerCount = userFollowerCount; }); } _setupFollowing() async { int userFollowingCount = await DatabaseService.numFollowing(widget.userId); setState(() { _followingCount = userFollowingCount; }); } _setupPosts() async { List<Post> posts = await DatabaseService.getUserPosts(widget.userId); setState(() { _posts = posts; }); } _setupFavourite() async { List<Post> posts = await DatabaseService.getFavouritePosts(widget.userId); setState(() { _posts = posts; }); } _setupProfileUser() async { User profileUser = await DatabaseService.getUserWithId(widget.userId); setState(() { _profileUser = profileUser; }); } _followOrUnfollow() { if (_isFollowing) { _unFollowUser(); } else { _followUser(); } } _unFollowUser() { DatabaseService.unFollowUser( currentUserId: widget.currentUserId, userId: widget.userId, ); setState(() { _isFollowing = false; _followerCount--; }); } _followUser() { DatabaseService.followUser( currentUserId: widget.currentUserId, userId: widget.userId, ); setState(() { _isFollowing = true; _followerCount++; }); } _displayButton(User user) { return user.id == Provider.of<UserData>(context).currentUserId ? PopupMenuButton<WhyFarther>( icon: Icon(OMIcons.settings), //color: Colors.black, onSelected: (WhyFarther result) { setState(() { _selection = result; print('selected $result'); if(result == WhyFarther.settings) { Navigator.push(context, MaterialPageRoute( builder: (_) => EditProfileScreen( user: user, ), ), ); } else { AuthService.logout(); } }); }, itemBuilder: (BuildContext context) => <PopupMenuEntry<WhyFarther>>[ const PopupMenuItem<WhyFarther>( value: WhyFarther.settings, child: Text('Edit Profile'), ), const PopupMenuItem<WhyFarther>( value: WhyFarther.exit, child: Text('Exit from account'), ), ], // navigate to settings /*onPressed: () => Navigator.push(context, MaterialPageRoute( builder: (_) => EditProfileScreen( user: user, ), ), ),*/ ): IconButton( icon: new Icon( _isFollowing ? Icons.check_circle_outline : Icons.radio_button_unchecked, color: _isFollowing ? Colors.green : Colors.black, ), //color: Colors.black, onPressed: _followOrUnfollow, ); } _buildToggleButtons() { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ IconButton( icon: Icon(Icons.grid_on), iconSize: 30.0, color: _displayPosts == 0 ? Colors.greenAccent //Theme.of(context).primaryColor : Colors.grey[300], onPressed: () => setState(() { _displayPosts = 0; }), ), IconButton( icon: Icon(Icons.list), iconSize: 30.0, color: _displayPosts == 1 ? Colors.greenAccent//Theme.of(context).primaryColor : Colors.grey[300], onPressed: () => setState(() { _displayPosts = 1; }), ), IconButton( icon: Icon(Icons.favorite_border), iconSize: 30.0, color: _displayPosts == 2 ? Colors.greenAccent : Colors.grey[300], onPressed: () => setState(() { _displayPosts = 2; }), ), ], ); } _buildTilePost(Post post) { return GridTile( child: GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: post, likeCount: post.likeCount, ), ), ), child: Image( image: CachedNetworkImageProvider(post.imageUrl), fit: BoxFit.cover, ), ), ); } _setupFeed() async { //List<Post> posts = await DatabaseService.getFeedPosts(widget.currentUserId); List<Post> posts = await DatabaseService.getAllUserPosts(); setState(() { _posts = posts; }); } _buildDisplayPosts() { if (_displayPosts == 0) { // Grid _setupPosts(); List<GridTile> tiles = []; _posts.forEach( (post) => tiles.add(_buildTilePost(post)), ); return GridView.count( crossAxisCount: 3, childAspectRatio: 1.0, mainAxisSpacing: 2.0, crossAxisSpacing: 2.0, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), children: tiles, ); } if (_displayPosts == 1) { // Column _setupPosts(); List<PostView> postViews = []; _posts.forEach((post) { postViews.add( PostView( currentUserId: widget.currentUserId, post: post, author: _profileUser, ), ); }); return Column(children: postViews); } if(_displayPosts == 2){ // Column favorite _setupFavourite(); List<PostView> postViews = []; _posts.forEach((post) { postViews.add( PostView( currentUserId: widget.currentUserId, post: post, author: _profileUser, ), ); }); return Column(children: postViews); } } @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( future: usersRef.document(widget.userId).get(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return Center( child: CircularProgressIndicator(), ); } User user = User.fromDoc(snapshot.data); return NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ HidingAppBar(forceElevated: innerBoxIsScrolled), ]; }, body: ListView( padding: EdgeInsets.zero, children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB(4.0, 8.0, 4.0, 8.0,), child: Card( child: Padding( padding: const EdgeInsets.all(16.0), child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ CircleAvatar( radius: 35.0, backgroundColor: Colors.grey, backgroundImage: user.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider(user.profileImageUrl), ), Column( children: <Widget>[ Row( children: <Widget>[ Column( children: <Widget>[ Text(user.name, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ),), /*Text( 'name', style: TextStyle(color: Colors.black54), ),*/ ], ), SizedBox(width: 5,), Column( children: <Widget>[ Text(user.surname, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), /*Text( 'surname', style: TextStyle(color: Colors.black54), ),*/ ], ), _displayButton(user), ], ), Column( children: <Widget>[ Text(user.email, style: TextStyle( fontSize: 14.0, fontFamily: 'ProductSans', color: Colors.grey, fontWeight: FontWeight.w600, ), ), ], ), ], ), ], ), ), ), ), ), Padding( padding: const EdgeInsets.fromLTRB(4.0, 0, 4.0, 0,), child: Card( child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Icon( Icons.shopping_basket, color: Colors.green, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text(_posts.length.toString(), style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('products', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), SizedBox(width: 15.0,), Icon( Icons.work, color: Colors.blue, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text('123', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('sales', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), SizedBox(width: 15.0,), Icon( Icons.star, color: Colors.orange, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text('D', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('raiting', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), SizedBox(width: 15.0,), Icon( Icons.group, color: Colors.purple, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text(_followerCount.toString(), style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('followers', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), ],), ], ), ), ), _buildToggleButtons(), Divider(), _buildDisplayPosts(), ], ), ); }, ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/HomeScreenIos.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/screens/ActivityScreen.dart'; import 'package:folka/screens/CreatePostScreen.dart'; import 'package:folka/screens/FeedScreen.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/screens/SearchScreen.dart'; import 'package:folka/services/AuthService.dart'; import 'package:provider/provider.dart'; class HomeScreenIos extends StatefulWidget { @override _HomeScreenIosState createState() => _HomeScreenIosState(); } class _HomeScreenIosState extends State<HomeScreenIos> { int _currentTab = 0; PageController _pageController; @override Widget build(BuildContext context) { final String currentUserId = Provider.of<UserData>(context).currentUserId; return CupertinoPageScaffold( child: CupertinoTabScaffold( tabBar: CupertinoTabBar( currentIndex: _currentTab, onTap: (int index) { setState(() { _currentTab = index; }); _pageController.animateToPage( index, duration: Duration(milliseconds: 200), curve: Curves.easeIn, ); }, backgroundColor: Colors.transparent, activeColor: Colors.greenAccent, items: [ BottomNavigationBarItem( icon: Icon( CupertinoIcons.news, //Icons.receipt, size: 32.0, ), title: Text('Feed'), ), BottomNavigationBarItem( icon: Icon( CupertinoIcons.search, size: 32.0, ), title: Text('Search'), ), BottomNavigationBarItem( icon: Icon( CupertinoIcons.add_circled, size: 32.0, ), title: Text('Add'), ), BottomNavigationBarItem( icon: Icon( CupertinoIcons.mail, size: 32.0, ), title: Text('Activity'), ), BottomNavigationBarItem( icon: Icon( CupertinoIcons.person, size: 32.0, ), title: Text('Profile'), ), ], ), tabBuilder: (context, index) { switch (index) { case 0: return FeedScreen(currentUserId: currentUserId); break; case 1: return SearchScreen(); break; case 2: return CreatePostScreen(currentUserId: currentUserId, userId: currentUserId,); break; case 3: return ActivityScreen(currentUserId: currentUserId); break; case 4: return ProfileScreen( currentUserId: currentUserId, userId: currentUserId, ); break; default: return FeedScreen(currentUserId: currentUserId); break; } }), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/QrScreen.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:super_qr_reader/super_qr_reader.dart'; class QrScreen extends StatefulWidget { final String currentUserId; final String userId; final bool authorScanBool; final Post post; final User author; Future<void> _launched; QrScreen({this.post, this.author, this.currentUserId, this.userId, this.authorScanBool}); @override State<StatefulWidget> createState() { return _QrScreenState(); } } class _QrScreenState extends State<QrScreen> { String result = ''; var scanResult; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.transparent, centerTitle: true, title: Text('Qr Screen', style: TextStyle( fontFamily: 'ProductSans'),), ), body: Container( child: Center( child: Column( children: <Widget>[ Text('Scan it to get document'), Container( width: 332, height: 332, child: QrImage( backgroundColor: Colors.white, data: widget.post.authorId + widget.post.name, ), ), Container( width: 250.0, child: FlatButton( onPressed: () async { String results = await Navigator.push( context, MaterialPageRoute( builder: (context) => ScanView(), )); if (results != null) { setState(() { result = results; }); } }, color: Colors.greenAccent, shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(28.0)), padding: EdgeInsets.all(10.0), child: Text( 'Next', style: TextStyle( fontFamily: 'ProductSans', //color: Colors.black, fontSize: 18.0, ), ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/ActivityScreen.dart
import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Activity.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/CommentsScreen.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/widgets/HidingAppBar.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; class ActivityScreen extends StatefulWidget { final String currentUserId; ActivityScreen({this.currentUserId}); @override _ActivityScreenState createState() => _ActivityScreenState(); } class _ActivityScreenState extends State<ActivityScreen> { List<Activity> _activities = []; @override void initState() { super.initState(); _setupActivities(); } _setupActivities() async { List<Activity> activities = await DatabaseService.getActivities(widget.currentUserId); if (mounted) { setState(() { _activities = activities; }); } } _buildActivity(Activity activity) { return FutureBuilder( future: DatabaseService.getUserWithId(activity.fromUserId), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return SizedBox.shrink(); } User user = snapshot.data; return ListTile( leading: CircleAvatar( radius: 20.0, backgroundColor: Colors.grey, backgroundImage: user.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider(user.profileImageUrl), ), title: activity.comment != null ? Text('${user.name} send you messege: "${activity.comment}"', style: TextStyle(fontFamily: 'ProductSans'),) : Text('${user.name} liked your post', style: TextStyle(fontFamily: 'ProductSans'),), subtitle: Text( DateFormat.yMd().add_jm().format(activity.timestamp.toDate(),), style: TextStyle(fontFamily: 'ProductSans'), ), trailing: CachedNetworkImage( imageUrl: activity.postImageUrl, height: 40.0, width: 40.0, fit: BoxFit.cover, ), onTap: () async { String currentUserId = Provider.of<UserData>(context).currentUserId; Post post = await DatabaseService.getUserPost( currentUserId, activity.postId, ); Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: post, likeCount: post.likeCount, ), ), ); }, ); }, ); } @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ HidingAppBar(forceElevated: innerBoxIsScrolled), ]; }, body: RefreshIndicator( onRefresh: () => _setupActivities(), child: ListView.builder( padding: EdgeInsets.zero, itemCount: _activities.length, itemBuilder: (BuildContext context, int index) { Activity activity = _activities[index]; return _buildActivity(activity); }, ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/IntroScreen.dart
import 'package:flutter/material.dart'; import 'package:folka/screens/LoginScreen.dart'; import 'package:introduction_screen/introduction_screen.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; class IntroScreen extends StatefulWidget { @override _IntroScreenState createState() => _IntroScreenState(); } class _IntroScreenState extends State<IntroScreen> { final introKey = GlobalKey<IntroductionScreenState>(); void _onIntroEnd(context) { Navigator.push(context, MaterialPageRoute( builder: (_) => LoginScreen(), ), ); } Widget _buildImage(String assetName) { return Align( child: Image.asset('assets/images/$assetName.png', width: 350.0), alignment: Alignment.bottomCenter, ); } @override Widget build(BuildContext context) { const bodyStyle = TextStyle(fontSize: 19.0, fontFamily: 'ProductSans'); const pageDecoration = const PageDecoration( titleTextStyle: TextStyle(fontSize: 28.0, fontWeight: FontWeight.w700, fontFamily: 'ProductSans'), bodyTextStyle: bodyStyle, descriptionPadding: EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 16.0), pageColor: Colors.transparent, imagePadding: EdgeInsets.zero, ); return IntroductionScreen( key: introKey, pages: [ PageViewModel( title: "Welcome here", body: "Thanks for downloading our app. We are sure you will like!", image: _buildImage('happyface'), decoration: pageDecoration, ), PageViewModel( title: "Rent", body: "Shelf is the best place to rent very necessary at this moment and lease something unnecessary.", image: _buildImage('moneyjar'), decoration: pageDecoration, ), PageViewModel( title: "Safety", body: "Rentals made through the app will be safe and fraudulent.", image: _buildImage('authentication'), decoration: pageDecoration, ), PageViewModel( title: "Convenience", body: "Application is designed to quickly and conveniently find what you need, saving your time.", image: _buildImage('orderconfirmed'), decoration: pageDecoration, ), PageViewModel( title: "What are you waiting for?!", bodyWidget: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Click on ", style: bodyStyle), Icon(OMIcons.search), ], ), Text("find needfull!", style: bodyStyle), ], ), image: _buildImage('qualitycheck'), decoration: pageDecoration, ), ], onDone: () => _onIntroEnd(context), //onSkip: () => _onIntroEnd(context), // You can override onSkip callback showSkipButton: true, skipFlex: 0, nextFlex: 0, skip: const Text('Skip', style: TextStyle(fontFamily: 'ProductSans'),), next: const Icon(Icons.arrow_forward), done: const Text('Continue', style: TextStyle(fontWeight: FontWeight.w600, fontFamily: 'ProductSans')), dotsDecorator: const DotsDecorator( size: Size(10.0, 10.0), color: Color(0xFFBDBDBD), activeColor: Colors.tealAccent, activeSize: Size(22.0, 10.0), activeShape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(25.0)), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/LoginScreen.dart
import 'package:flutter/material.dart'; import 'package:folka/screens/SignUpScreen.dart'; import 'package:folka/services/AuthService.dart'; class LoginScreen extends StatefulWidget { static final String id = 'login_screen'; @override _LoginScreenState createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> { final _formKey = GlobalKey<FormState>(); String _email, _password; _submit() { if (_formKey.currentState.validate()) { _formKey.currentState.save(); // Logging in the user w/ Firebase AuthService.login(_email, _password); Navigator.pop(context); } } @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( 'shelf', style: TextStyle( fontFamily: 'ProductSans', fontSize: 50.0, ), ), Form( key: _formKey, child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Email', hintStyle: TextStyle(fontFamily: 'ProductSans'),), validator: (input) => !input.contains('@') ? 'Please enter a valid email' : null, onSaved: (input) => _email = input, ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Password', hintStyle: TextStyle(fontFamily: 'ProductSans'),), validator: (input) => input.length < 6 ? 'Must be at least 6 characters' : null, onSaved: (input) => _password = input, obscureText: true, ), ), SizedBox(height: 20.0), Container( width: 250.0, child: OutlineButton( borderSide: BorderSide(color: Colors.greenAccent), highlightedBorderColor: Colors.green, onPressed: _submit, color: Colors.greenAccent, shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(28.0)), padding: EdgeInsets.all(10.0), child: Text( 'Login', style: TextStyle( fontFamily: 'ProductSans', //color: Colors.black, fontSize: 18.0, ), ), ), ), SizedBox(height: 20.0), Container( width: 250.0, child: FlatButton( onPressed: () => Navigator.pushNamed(context, SignupScreen.id), color: Colors.greenAccent, shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(28.0)), padding: EdgeInsets.all(10.0), child: Text( 'Sign Up', style: TextStyle( fontFamily: 'ProductSans', color: Colors.black, fontSize: 18.0, ), ), ), ), ], ), ), ], ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/EditProfileScreen.dart
import 'dart:async'; import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cupertino_date_picker_fork/flutter_cupertino_date_picker_fork.dart'; import 'package:flutter_material_pickers/helpers/show_scroll_picker.dart'; import 'package:folka/models/User.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/services/StorageService.dart'; import 'package:image_picker/image_picker.dart'; import 'package:intl/intl.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; class EditProfileScreen extends StatefulWidget { final User user; EditProfileScreen({this.user}); @override _EditProfileScreenState createState() => _EditProfileScreenState(); } class _EditProfileScreenState extends State<EditProfileScreen> { final _formKey = GlobalKey<FormState>(); File _profileImage; String _name = ''; String _surname = ''; String _phone = ''; String _birthdate = ''; String _address = ''; String _bio = ''; bool _isLoading = false; String _region = ''; int age = -1; List<String> items = [ 'Saint-Peterburg', 'Leningradskaya oblast', 'Moscow', 'Moscowskaya oblast', 'Novosibirsk', 'Novosibirskaya oblast', 'Ryazan', 'Ryazanskaya oblast', 'Tula', 'Tulskaya oblast', ]; int selected_item = 0; var selectedRegion = "Saint-Peterburg"; @override void initState() { super.initState(); _name = widget.user.name; _surname = widget.user.surname; _phone = widget.user.phone; _birthdate = widget.user.birthdate; _address = widget.user.address; _bio = widget.user.bio; } _handleImageFromGallery() async { File imageFile = await ImagePicker.pickImage(source: ImageSource.gallery); if (imageFile != null) { setState(() { _profileImage = imageFile; }); } } _displayProfileImage() { // No new profile image if (_profileImage == null) { // No existing profile image if (widget.user.profileImageUrl.isEmpty) { // Display placeholder return AssetImage('assets/images/avatar.png'); } else { // User profile image exists return CachedNetworkImageProvider(widget.user.profileImageUrl); } } else { // New profile image return FileImage(_profileImage); } } _submit() async { if (_formKey.currentState.validate() && !_isLoading) { _formKey.currentState.save(); setState(() { _isLoading = true; }); // Update user in database String _profileImageUrl = ''; if (_profileImage == null) { _profileImageUrl = widget.user.profileImageUrl; } else { _profileImageUrl = await StorageService.uploadUserProfileImage( widget.user.profileImageUrl, _profileImage, ); } User user = User( id: widget.user.id, name: _name, surname: _surname, phone: _phone, birthdate: _birthdate, address: _address, profileImageUrl: _profileImageUrl, bio: _bio, ); // Database update DatabaseService.updateUser(user); Navigator.pop(context); } } calculateAge(DateTime birthDate) { DateTime currentDate = DateTime.now(); int age = currentDate.year - birthDate.year; int month1 = currentDate.month; int month2 = birthDate.month; if (month2 > month1) { age--; } else if (month1 == month2) { int day1 = currentDate.day; int day2 = birthDate.day; if (day2 > day1) { age--; } } return age; } selectDate(BuildContext context, DateTime initialDateTime, {DateTime lastDate}) async { Completer completer = Completer(); String _selectedDateInString; if (Platform.isAndroid) showDatePicker( context: context, initialDate: initialDateTime, firstDate: DateTime(1970), lastDate: lastDate == null ? DateTime(initialDateTime.year + 10) : lastDate) .then((temp) { if (temp == null) return null; completer.complete(temp); setState(() {}); }); else DatePicker.showDatePicker( context, dateFormat: 'yyyy-mmm-dd', //locale: 'en', onConfirm: (temp, selectedIndex) { if (temp == null) return null; completer.complete(temp); setState(() {}); }, ); return completer.future; } _showSelectItemPicker() { return Platform.isIOS ? _iosItemPicker() : _androidItemPicker(); } _iosItemPicker() async { final selectedItem = await showCupertinoModalPopup<String>( context: context, builder: (BuildContext context){ return Container( height: MediaQuery.of(context).size.width, child: CupertinoPicker( itemExtent: 50.0, onSelectedItemChanged: (index){ setState(() { selected_item = index; _address = '${items[index]}'; print("You selected ${items[selected_item]}"); }); }, children: List<Widget>.generate(items.length, (index){ return Center( child: GestureDetector( onTap:() { _address = '${items[index]}'; setState(() {}); Navigator.pop(context); }, child: Text(items[index]), ), ); }), ), ); } ); } _androidItemPicker() async { final selectedItem = await showMaterialScrollPicker( context: context, title: "Pick your region", items: items, //selectedItem: selectedRegion, onChanged: (value) => setState(() { selectedRegion = value; _address = '${selectedRegion}'; _region = _address; print('you choose ' + _address); }) ); } @override Widget build(BuildContext context) { return Scaffold( //backgroundColor: Colors.white, /*floatingActionButton: Stack( children: <Widget>[ Padding(padding: EdgeInsets.only(left:31), child: Align( alignment: Alignment.bottomLeft, child: FloatingActionButton( backgroundColor: Colors.greenAccent, onPressed: () {Navigator.pop(context);}, child: Icon(Icons.arrow_back, color: Colors.black,),), ),), Align( alignment: Alignment.bottomRight, child: FloatingActionButton( backgroundColor: Colors.greenAccent, onPressed: _submit, child: Icon(Icons.check, color: Colors.black,),), ), ], ),*/ appBar: AppBar( //backgroundColor: Colors.white, bottomOpacity: 0.0, elevation: 0, title: Text( 'Edit Profile', style: TextStyle( //color: Colors.black, fontFamily: 'ProductSans', ), ), ), body: GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: ListView( children: <Widget>[ _isLoading ? LinearProgressIndicator( backgroundColor: Colors.transparent, valueColor: AlwaysStoppedAnimation(Colors.greenAccent), ) : SizedBox.shrink(), Padding( padding: EdgeInsets.all(30.0), child: Form( key: _formKey, child: Column( children: <Widget>[ CircleAvatar( radius: 60.0, backgroundColor: Colors.grey, backgroundImage: _displayProfileImage(), ), FlatButton( onPressed: _handleImageFromGallery, child: Text( 'Change Profile Image', style: TextStyle( //color: Theme.of(context).accentColor, color: Colors.green, fontFamily: 'ProductSans', fontSize: 16.0), ), ), TextFormField( initialValue: _name, style: TextStyle(fontSize: 18.0), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), icon: Icon( Icons.person_outline, size: 30.0, ), labelText: 'Name', ), validator: (input) => input.trim().length < 1 ? 'Please enter a valid name' : null, onSaved: (input) => _name = input, ), SizedBox(height: 20.0), TextFormField( initialValue: _surname, style: TextStyle(fontSize: 18.0), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), icon: Icon( Icons.person_outline, size: 30.0, ), labelText: 'Surname', ), validator: (input) => input.trim().length < 1 ? 'Please enter a valid surname' : null, onSaved: (input) => _surname = input, ), SizedBox(height: 20.0), TextFormField( initialValue: _bio, style: TextStyle(fontSize: 18.0), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), icon: Icon( OMIcons.book, size: 30.0, ), labelText: 'Bio', ), validator: (input) => input.trim().length > 150 ? 'Please enter a bio less than 150 characters' : null, onSaved: (input) => _bio = input, ), SizedBox(height: 20.0), TextFormField( initialValue: _phone, style: TextStyle(fontSize: 18.0), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), icon: Icon( OMIcons.phone, size: 30.0, ), labelText: 'Phone', ), validator: (input) => input.trim().length < 5 ? 'Please enter a valid phone' : null, onSaved: (input) => _phone = input, ), /*SizedBox(height: 20.0), GestureDetector( //onTap: ()=> selectDate(context, DateTime.now(),), onTap: () async { DateTime birthDate = await selectDate(context, DateTime.now(), lastDate: DateTime.now()); final df = new DateFormat('dd-MMM-yyyy'); this._birthdate = df.format(birthDate); this.age = calculateAge(birthDate); setState(() {}); }, child: Row( children: <Widget>[ Container( child: Icon(Icons.child_friendly, color: Colors.grey, size: 30.0,), ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.0)), border: Border.all(color: Colors.grey), ), padding: EdgeInsets.fromLTRB(10,20,20,20,), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Birthdate ", style: TextStyle(fontFamily: 'ProductSans', color: Colors.grey[600]),), Text("$_birthdate", style: TextStyle(fontFamily: 'ProductSans'),) ], ), ), ], ), ),*/ SizedBox(height: 20.0), Row( children: <Widget>[ Icon(OMIcons.map, color: Colors.grey, size: 30,), Padding( padding: EdgeInsets.symmetric( horizontal: 22.0, //vertical: 5.0, ), child: GestureDetector( //onTap: () async {_showSelectRegionDialog();}, onTap: _showSelectItemPicker, child: Padding( padding: const EdgeInsets.only(right: 30.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.0)), border: Border.all(color: Colors.grey), ), padding: EdgeInsets.fromLTRB(10,20,20,20,), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Region ", style: TextStyle(fontSize: 16, fontFamily: 'ProductSans', color: Colors.grey[600]),), Text("$_address", style: TextStyle(fontFamily: 'ProductSans'),), ], ), ), ), ), ), ], ), Container( margin: EdgeInsets.all(40.0), height: 40.0, width: 250.0, child: FlatButton( shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(18.0), ), onPressed: _submit, color: Colors.greenAccent, textColor: Colors.black, child: Text( 'Save Profile', style: TextStyle(fontSize: 18.0), ), ), ), ], ), ), ), ], ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/SignUpScreen.dart
import 'dart:async'; import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cupertino_date_picker_fork/flutter_cupertino_date_picker_fork.dart'; import 'package:flutter_material_pickers/flutter_material_pickers.dart'; import 'package:folka/screens/TermsScreen.dart'; import 'package:folka/services/AuthService.dart'; import 'package:intl/intl.dart'; class SignupScreen extends StatefulWidget { static final String id = 'signup_screen'; @override _SignupScreenState createState() => _SignupScreenState(); } class _SignupScreenState extends State<SignupScreen> { final _formKey = GlobalKey<FormState>(); String _name, _surname, _birthdate, _address, _email, _phone, _password; String birthDate = ""; int age = -1; String _region = ""; _submit() { _birthdate = birthDate; if (age <= 18) { return SnackBar ( content: Text('Sorry you are not an adult', style: TextStyle(fontFamily: 'ProductSans'),), action: SnackBarAction( label: 'Undo', onPressed: () {}, ), );} if (_formKey.currentState.validate()) { _formKey.currentState.save(); // Logging in the user w/ Firebase AuthService.signUpUser(context, _name, _surname, _birthdate, _address, _email, _phone, _password); } } calculateAge(DateTime birthDate) { DateTime currentDate = DateTime.now(); int age = currentDate.year - birthDate.year; int month1 = currentDate.month; int month2 = birthDate.month; if (month2 > month1) { age--; } else if (month1 == month2) { int day1 = currentDate.day; int day2 = birthDate.day; if (day2 > day1) { age--; } } return age; } selectDate(BuildContext context, DateTime initialDateTime, {DateTime lastDate}) async { Completer completer = Completer(); String _selectedDateInString; if (Platform.isAndroid) showDatePicker( context: context, initialDate: initialDateTime, firstDate: DateTime(1970), lastDate: lastDate == null ? DateTime(initialDateTime.year + 10) : lastDate) .then((temp) { if (temp == null) return null; completer.complete(temp); setState(() {}); }); else DatePicker.showDatePicker( context, dateFormat: 'yyyy-mmm-dd', //locale: 'en', onConfirm: (temp, selectedIndex) { if (temp == null) return null; completer.complete(temp); setState(() {}); }, ); return completer.future; } List<String> items = [ 'Saint-Peterburg', 'Leningradskaya oblast', 'Moscow', 'Moscowskaya oblast', 'Novosibirsk', 'Novosibirskaya oblast', 'Ryazan', 'Ryazanskaya oblast', 'Tula', 'Tulskaya oblast', ]; int selected_item = 0; var selectedRegion = "Saint-Peterburg"; _showSelectItemPicker() { return Platform.isIOS ? _iosItemPicker() : _androidItemPicker(); } _iosItemPicker() async { final selectedItem = await showCupertinoModalPopup<String>( context: context, builder: (BuildContext context){ return Container( height: MediaQuery.of(context).size.width, child: CupertinoPicker( itemExtent: 50.0, onSelectedItemChanged: (index){ setState(() { selected_item = index; _address = '${items[index]}'; print("You selected ${items[selected_item]}"); }); }, children: List<Widget>.generate(items.length, (index){ return Center( child: GestureDetector( onTap:() { _address = '${items[index]}'; setState(() {}); Navigator.pop(context); }, child: Text(items[index]), ), ); }), ), ); } ); } _androidItemPicker() async { final selectedItem = await showMaterialScrollPicker( context: context, title: "Pick your region", items: items, //selectedItem: selectedRegion, onChanged: (value) => setState(() { selectedRegion = value; _address = '${selectedRegion}'; }) ); } @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ //SizedBox(height: 24,), Text( 'Sign Up', style: TextStyle( fontFamily: 'ProductSans', fontSize: 50.0, ), ), Form( key: _formKey, child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Name'), validator: (input) => input.trim().isEmpty ? 'Please enter a valid name' : null, onSaved: (input) => _name = input, ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Surname'), validator: (input) => input.trim().isEmpty ? 'Please enter a valid surname' : null, onSaved: (input) => _surname = input, ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: GestureDetector( //onTap: ()=> selectDate(context, DateTime.now(),), onTap: () async { DateTime birthDate = await selectDate(context, DateTime.now(), lastDate: DateTime.now()); final df = new DateFormat('dd-MMM-yyyy'); this.birthDate = df.format(birthDate); this.age = calculateAge(birthDate); setState(() {}); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.0)), border: Border.all(color: Colors.grey), ), padding: EdgeInsets.fromLTRB(10,20,20,20,), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Birthdate ", style: TextStyle(fontSize: 16, fontFamily: 'ProductSans', color: Colors.grey[600]),), Text("$birthDate", style: TextStyle(fontFamily: 'ProductSans'),) ], ), ), ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 5.0, ), child: GestureDetector( //onTap: () async {_showSelectRegionDialog();}, onTap: _showSelectItemPicker, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.0)), border: Border.all(color: Colors.grey), ), padding: EdgeInsets.fromLTRB(10,20,20,20,), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Region ", style: TextStyle(fontSize: 16, fontFamily: 'ProductSans', color: Colors.grey[600]),), Text("$_address", style: TextStyle(fontFamily: 'ProductSans'),), ], ), ), ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Email'), validator: (input) => !input.contains('@') ? 'Please enter a valid email' : null, onSaved: (input) => _email = input, ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( keyboardType: TextInputType.phone, decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Phone'), validator: (input) => input.length < 6 ? 'Please enter a valid phone number' : null, onSaved: (input) => _phone = input, ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 10.0, ), child: TextFormField( decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Password'), validator: (input) => input.length < 6 ? 'Must be at least 6 characters' : null, onSaved: (input) => _password = input, obscureText: true, ), ), SizedBox(height: 20.0), Container( width: 250.0, child: FlatButton( onPressed: _submit, color: Colors.greenAccent, shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(28.0)), padding: EdgeInsets.all(10.0), child: Text( 'Sign Up', style: TextStyle( fontFamily: 'ProductSans', color: Colors.black, fontSize: 18.0, ), ), ), ), SizedBox(height: 20.0), Container( width: 250.0, child: OutlineButton( borderSide: BorderSide(color: Colors.greenAccent), highlightedBorderColor: Colors.green, shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(28.0)), onPressed: () => Navigator.pop(context), color: Colors.greenAccent, padding: EdgeInsets.all(10.0), child: Text( 'Back to Login', style: TextStyle( fontFamily: 'ProductSans', //color: Colors.black, fontSize: 18.0, ), ), ), ), ], ), ), Padding( padding: const EdgeInsets.all(12.0), child: Align( alignment: Alignment.bottomCenter, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( 'by clicking sign up you agree to the ' ), GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => TermsScreen(), ),), child: Text( 'terms of use', style: TextStyle( color: Colors.blueAccent, ), ), ), ], ), ), ), ], ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/TermsScreen.dart
import 'package:flutter/material.dart'; class TermsScreen extends StatefulWidget { @override _TermsScreenState createState() => _TermsScreenState(); } class _TermsScreenState extends State<TermsScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Terms', style: TextStyle( fontFamily: 'ProductSans', ),), backgroundColor: Colors.transparent, ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/CommentsScreen.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Comment.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/models/User.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/utilities/Constants.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; class CommentsScreen extends StatefulWidget { final Post post; final int likeCount; CommentsScreen({this.post, this.likeCount}); @override _CommentsScreenState createState() => _CommentsScreenState(); } class _CommentsScreenState extends State<CommentsScreen> { final TextEditingController _commentController = TextEditingController(); bool _isCommenting = false; _buildComment(Comment comment) { return FutureBuilder( future: DatabaseService.getUserWithId(comment.authorId), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return SizedBox.shrink(); } User author = snapshot.data; return ListTile( leading: CircleAvatar( radius: 25.0, backgroundColor: Colors.grey, backgroundImage: author.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider(author.profileImageUrl), ), title: Text(author.name, style: TextStyle(fontFamily: 'ProductSans'),), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text(comment.content, style: TextStyle(fontFamily: 'ProductSans'),), SizedBox(height: 6.0), Text( DateFormat.yMd().add_jm().format(comment.timestamp.toDate()), style: TextStyle(fontFamily: 'ProductSans'), ), ], ), ); }, ); } _buildCommentTF() { final currentUserId = Provider.of<UserData>(context).currentUserId; return IconTheme( data: IconThemeData( color: _isCommenting ? Theme.of(context).accentColor : Theme.of(context).disabledColor, ), child: Container( margin: EdgeInsets.symmetric(horizontal: 8.0), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ SizedBox(width: 10.0), Expanded( child: TextField( controller: _commentController, textCapitalization: TextCapitalization.sentences, onChanged: (comment) { setState(() { _isCommenting = comment.length > 0; }); }, decoration: InputDecoration.collapsed(hintText: 'Write a messege...', hintStyle: TextStyle(fontFamily: 'ProductSans')), ), ), Container( margin: EdgeInsets.symmetric(horizontal: 4.0), child: IconButton( icon: Icon(Icons.send), onPressed: () { if (_isCommenting) { DatabaseService.commentOnPost( currentUserId: currentUserId, post: widget.post, comment: _commentController.text, ); _commentController.clear(); setState(() { _isCommenting = false; }); } }, ), ), ], ), ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( //backgroundColor: Colors.white, title: Text( 'Mail', style: TextStyle(fontFamily: 'ProductSans',), ), ), body: Column( children: <Widget>[ Padding( padding: EdgeInsets.all(12.0), child: Text( '${widget.likeCount} stars', style: TextStyle( fontFamily: 'ProductSans', fontSize: 20.0, fontWeight: FontWeight.w600, ), ), ), StreamBuilder( stream: commentsRef .document(widget.post.id) .collection('postComments') .orderBy('timestamp', descending: true) .snapshots(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return Center( child: CircularProgressIndicator(), ); } return Expanded( child: ListView.builder( itemCount: snapshot.data.documents.length, itemBuilder: (BuildContext context, int index) { Comment comment = Comment.fromDoc(snapshot.data.documents[index]); return _buildComment(comment); }, ), ); }, ), Divider(height: 1.0), _buildCommentTF(), ], ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/ProfleSmbScreen.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/EditProfileScreen.dart'; import 'package:folka/services/AuthService.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/utilities/Constants.dart'; import 'package:folka/widgets/PostView.dart'; import 'package:provider/provider.dart'; import 'CommentsScreen.dart'; class ProfileSMDScreen extends StatefulWidget { final String currentUserId; final String userId; ProfileSMDScreen({this.currentUserId, this.userId}); @override _ProfileSMDScreenState createState() => _ProfileSMDScreenState(); } class _ProfileSMDScreenState extends State<ProfileSMDScreen> { bool _isFollowing = false; int _followerCount = 0; int _followingCount = 0; List<Post> _posts = []; int _displayPosts = 0; // 0 - grid, 1 - column User _profileUser; @override void initState() { super.initState(); _setupIsFollowing(); _setupFollowers(); _setupFollowing(); _setupPosts(); _setupProfileUser(); } _setupIsFollowing() async { bool isFollowingUser = await DatabaseService.isFollowingUser( currentUserId: widget.currentUserId, userId: widget.userId, ); setState(() { _isFollowing = isFollowingUser; }); } _setupFollowers() async { int userFollowerCount = await DatabaseService.numFollowers(widget.userId); setState(() { _followerCount = userFollowerCount; }); } _setupFollowing() async { int userFollowingCount = await DatabaseService.numFollowing(widget.userId); setState(() { _followingCount = userFollowingCount; }); } _setupPosts() async { List<Post> posts = await DatabaseService.getUserPosts(widget.userId); setState(() { _posts = posts; }); } _setupProfileUser() async { User profileUser = await DatabaseService.getUserWithId(widget.userId); setState(() { _profileUser = profileUser; }); } _followOrUnfollow() { if (_isFollowing) { _unfollowUser(); } else { _followUser(); } } _unfollowUser() { DatabaseService.unFollowUser( currentUserId: widget.currentUserId, userId: widget.userId, ); setState(() { _isFollowing = false; _followerCount--; }); } _followUser() { DatabaseService.followUser( currentUserId: widget.currentUserId, userId: widget.userId, ); setState(() { _isFollowing = true; _followerCount++; }); } _displayButton(User user) { return user.id == Provider.of<UserData>(context).currentUserId ? IconButton( icon: new Icon(Icons.settings), //color: Colors.black, onPressed: () => Navigator.push(context, MaterialPageRoute( builder: (_) => EditProfileScreen( user: user, ), ), ), ): IconButton( icon: new Icon( _isFollowing ? Icons.check_circle_outline : Icons.radio_button_unchecked, color: _isFollowing ? Colors.green : Colors.black, ), //color: Colors.black, onPressed: _followOrUnfollow, ); } _buildToggleButtons() { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ IconButton( icon: Icon(Icons.grid_on), iconSize: 30.0, color: _displayPosts == 0 ? Theme.of(context).primaryColor : Colors.grey[300], onPressed: () => setState(() { _displayPosts = 0; }), ), IconButton( icon: Icon(Icons.list), iconSize: 30.0, color: _displayPosts == 1 ? Theme.of(context).primaryColor : Colors.grey[300], onPressed: () => setState(() { _displayPosts = 1; }), ), ], ); } _buildTilePost(Post post) { return GridTile( child: GestureDetector( onTap: () => Navigator.push( context, MaterialPageRoute( builder: (_) => CommentsScreen( post: post, likeCount: post.likeCount, ), ), ), child: Image( image: CachedNetworkImageProvider(post.imageUrl), fit: BoxFit.cover, ), ), ); } _buildDisplayPosts() { if (_displayPosts == 0) { // Grid List<GridTile> tiles = []; _posts.forEach( (post) => tiles.add(_buildTilePost(post)), ); return GridView.count( crossAxisCount: 3, childAspectRatio: 1.0, mainAxisSpacing: 2.0, crossAxisSpacing: 2.0, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), children: tiles, ); } else { // Column List<PostView> postViews = []; _posts.forEach((post) { postViews.add( PostView( currentUserId: widget.currentUserId, post: post, author: _profileUser, ), ); }); return Column(children: postViews); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( bottomOpacity: 0.0, elevation: 0, backgroundColor: Colors.transparent, title: Text( 'shelf', style: TextStyle( //color: Colors.black, fontFamily: 'ProductSans', ), ), /*actions: <Widget>[ IconButton( icon: Icon(Icons.exit_to_app), onPressed: AuthService.logout, ), ],*/ ), body: FutureBuilder( future: usersRef.document(widget.userId).get(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return Center( child: CircularProgressIndicator(), ); } User user = User.fromDoc(snapshot.data); return ListView( children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB(4.0, 8.0, 4.0, 8.0,), child: Card( child: Padding( padding: const EdgeInsets.all(16.0), child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ CircleAvatar( radius: 35.0, backgroundColor: Colors.grey, backgroundImage: user.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider(user.profileImageUrl), ), Column( children: <Widget>[ Row( children: <Widget>[ Column( children: <Widget>[ Text(user.name, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ),), /*Text( 'name', style: TextStyle(color: Colors.black54), ),*/ ], ), SizedBox(width: 5,), Column( children: <Widget>[ Text(user.surname, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), /*Text( 'surname', style: TextStyle(color: Colors.black54), ),*/ ], ), _displayButton(user), ], ), Column( children: <Widget>[ Text(user.email, style: TextStyle( fontSize: 14.0, fontFamily: 'ProductSans', color: Colors.grey, fontWeight: FontWeight.w600, ), ), ], ), ], ), ], ), ), ), ), ), Padding( padding: const EdgeInsets.fromLTRB(4.0, 0, 4.0, 0,), child: Card( child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Icon( Icons.shopping_basket, color: Colors.green, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text(_posts.length.toString(), style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('products', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), SizedBox(width: 15.0,), Icon( Icons.work, color: Colors.blue, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text('123', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('sales', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), SizedBox(width: 15.0,), Icon( Icons.star, color: Colors.orange, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text('36', style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('raiting', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), SizedBox(width: 15.0,), Icon( Icons.group, color: Colors.purple, ), Padding( padding: const EdgeInsets.all(8.0), child: Column(children: <Widget>[ Text(_followerCount.toString(), style: TextStyle( fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600,),), Text('followers', style: TextStyle( fontSize: 12.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, /*color: Colors.black54,*/),), ],), ), ],), ], ), ), ), _buildToggleButtons(), Divider(), _buildDisplayPosts(), ], ); }, ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/FeedScreen.dart
import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/ProfileScreen.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/widgets/GridPostView.dart'; import 'package:folka/widgets/HidingAppBar.dart'; import 'package:folka/widgets/PostView.dart'; class FeedScreen extends StatefulWidget { static final String id = 'feed_screen'; final String currentUserId; FeedScreen({this.currentUserId}); @override _FeedScreenState createState() => _FeedScreenState(); } class _FeedScreenState extends State<FeedScreen> { List<Post> _posts = []; bool isIos; @override void initState() { super.initState(); print('your id ' + '${widget.currentUserId}'); _setupFeed(); } _setupFeed() async { //List<Post> posts = await DatabaseService.getFeedPosts(widget.currentUserId); List<Post> posts = await DatabaseService.getAllUserPosts(); setState(() { _posts = posts; }); } @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ HidingAppBar(forceElevated: innerBoxIsScrolled), ]; }, body: RefreshIndicator( onRefresh: () => _setupFeed(), child: OrientationBuilder( builder: (context, orentation) { return GridView.builder( padding: EdgeInsets.zero, physics: AlwaysScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: orentation == Orientation.portrait ? 2 : 4,), itemCount: _posts.length, itemBuilder: (BuildContext context, int index) { Post post = _posts[index]; return FutureBuilder( future: DatabaseService.getUserWithId(post.authorId), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return SizedBox.shrink(); } User author = snapshot.data; return GridPostView( currentUserId: '${widget.currentUserId}', post: post, author: author, ); } ); } );} ), /*child: ListView.builder( itemCount: _posts.length, itemBuilder: (BuildContext context, int index) { Post post = _posts[index]; return FutureBuilder( future: DatabaseService.getUserWithId(post.authorId), builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return SizedBox.shrink(); } User author = snapshot.data; return PostView( currentUserId: widget.currentUserId, post: post, author: author, ); }, ); }, ),*/ ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/ExploreScreen.dart
import 'package:flutter/material.dart'; class ExploreScreen extends StatelessWidget { ExploreScreen({ Key key, @required this.flipScreenCtrl, }) : super(key: key); final AnimationController flipScreenCtrl; @override Widget build(BuildContext context) { return Container( child: Scaffold( appBar: AppBar( elevation: 0.0, backgroundColor: Colors.transparent, ), body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Padding( padding: const EdgeInsets.fromLTRB(30.0, 0.0, 30.0, 0.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Polka Best Place to Rent out \nand Rent In St-Peterburg', style: TextStyle( height: 1.2, fontFamily: 'ProductSans', color: Colors.black, fontSize: 30.0, fontWeight: FontWeight.bold, ), ), SizedBox( height: 16.0, ), Text( 'We will recommended your personality based on\nyour choice to rent and rent out.', style: TextStyle( fontFamily: 'ProductSans', color: Color(0xFFBBCCCC), fontSize: 16.0, ), ), SizedBox( height: 30.0, ), SingleChildScrollView( scrollDirection: Axis.vertical, physics: const BouncingScrollPhysics(), child: Column( children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ StuffShelf( imagePath: 'https://images.unsplash.com/photo-1537495329792-41ae41ad3bf0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80', categorie: 'Books', ), StuffShelf( imagePath: 'https://images.unsplash.com/photo-1541493132330-2f0bca8cb7b9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=375&q=80', categorie: 'Gadgets', ), StuffShelf( imagePath: 'https://images.unsplash.com/photo-1495121605193-b116b5b9c5fe?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80', categorie: 'Clothes', ), ], ), SizedBox( height: 26.0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ StuffShelf( imagePath: 'https://images.unsplash.com/photo-1521412644187-c49fa049e84d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80', categorie: 'Sports', ), StuffShelf( imagePath: 'https://images.unsplash.com/photo-1517842645767-c639042777db?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80', categorie: 'Notes', ), StuffShelf( imagePath: 'https://images.unsplash.com/photo-1479888230021-c24f136d849f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80', categorie: 'Vintage item', ), ], ), ], ), ), Container( padding: const EdgeInsets.only(top: 50.0), width: double.infinity, alignment: Alignment.center, child: RaisedButton( onPressed: () { Navigator.of(context).pushReplacementNamed('/Homepage'); }, color: Colors.greenAccent, child: Padding( padding: const EdgeInsets.symmetric( horizontal: 8.0, vertical: 12.0), child: Text( 'Carry out', style: TextStyle( fontFamily: 'ProductSans', color: Colors.white, fontSize: 16.0, ), ), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), ), ), ], ), ), ), ), ); } } class StuffShelf extends StatelessWidget { final String imagePath; final String categorie; StuffShelf({this.imagePath, this.categorie}); @override Widget build(BuildContext context) { return Column( children: <Widget>[ InkWell( child: Column( children: <Widget>[ Container( width: 110.0, height: 165.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12.0), image: DecorationImage( image: NetworkImage( imagePath, ), fit: BoxFit.cover, ), ), ), ], ), ), SizedBox( height: 10.0, ), Text( categorie, style: TextStyle( color: Colors.black, fontSize: 14.0, fontFamily: 'ProductSans', fontWeight: FontWeight.bold, ), ), ], ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/CreatePostScreen.dart
import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/models/User.dart'; import 'package:folka/models/UserData.dart'; import 'package:folka/services/DatabaseService.dart'; import 'package:folka/services/StorageService.dart'; import 'package:folka/widgets/HidingAppBar.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; import 'package:provider/provider.dart'; class CreatePostScreen extends StatefulWidget { final String currentUserId; final String userId; final User user; CreatePostScreen({this.userId, this.currentUserId, this.user}); @override _CreatePostScreenState createState() => _CreatePostScreenState(); } class _CreatePostScreenState extends State<CreatePostScreen> { User user; File _image; TextEditingController _captionController = TextEditingController(); TextEditingController _nameController = TextEditingController(); TextEditingController _priceController = TextEditingController(); TextEditingController _timeController = TextEditingController(); TextEditingController _locationController = TextEditingController(); TextEditingController _phoneController = TextEditingController(); String _caption = ''; String _name = ''; String _price = ''; String _time = ''; String _location = ''; String _category = ''; bool _isLoading = false; _showSelectImageDialog() { return Platform.isIOS ? _iosBottomSheet() : _androidBottomSheet(); } _showSelectChooseDialog() { return Platform.isIOS ? _iosChooseBottomSheet() : _androidChooseBottomSheet(); } _showTimeChooseDialog() { return Platform.isIOS ? _iosTimeSheet() : _androidTimeSheet(); } _iosBottomSheet() { showCupertinoModalPopup( context: context, builder: (BuildContext context) { return CupertinoActionSheet( title: Text('Add Photo'), actions: <Widget>[ CupertinoActionSheetAction( child: Text('Take Photo'), onPressed: () => _handleImage(ImageSource.camera), ), CupertinoActionSheetAction( child: Text('Choose From Gallery'), onPressed: () => _handleImage(ImageSource.gallery), ), ], cancelButton: CupertinoActionSheetAction( child: Text('Cancel'), onPressed: () => Navigator.pop(context), ), ); }, ); } _iosChooseBottomSheet() { showCupertinoModalPopup( context: context, builder: (BuildContext context) { return CupertinoActionSheet( title: Text('Choose category'), actions: <Widget>[ CupertinoActionSheetAction( child: Text('Videogame Asset'), onPressed: () { _category = 'Videogame Asset'; setState(() {}); Navigator.pop(context); } ), CupertinoActionSheetAction( child: Text('Gadgets'), onPressed: () { _category = 'Gadgets'; setState(() {}); Navigator.pop(context); } ), CupertinoActionSheetAction( child: Text('Electonics'), onPressed: () { _category = 'Electonics'; setState(() {}); Navigator.pop(context); } ), CupertinoActionSheetAction( child: Text('Childrens things'), onPressed: () { _category = 'Childrens things'; setState(() {}); Navigator.pop(context); } ), ], cancelButton: CupertinoActionSheetAction( child: Text('Cancel'), onPressed: ()=> Navigator.pop(context), ), ); }, ); } _androidChooseBottomSheet() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Padding( padding: const EdgeInsets.all(6.0), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), child: OrientationBuilder( builder: (context, orientation) { //height: orientation == Orientation.portrait ? 320 : 220, return Container( height: 350, child: ListView( physics: BouncingScrollPhysics(), children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB( 16.0, 12.0, 16.0, 12.0,), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text('Choose category', style: TextStyle( fontFamily: 'ProductSans', fontSize: 18.0),), MaterialButton( child: Row( children: <Widget>[ Icon(OMIcons.cancel, color: Colors.red,), SizedBox(width: 4,), Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.red),), ], ), onPressed: ()=> Navigator.pop(context), ), ], ), ), ListTile( leading: Icon(OMIcons.videogameAsset), title: Text('Videogames Asset', style: TextStyle( fontFamily: 'ProductSans'),), subtitle: Text('consoles and stuff', style: TextStyle( fontFamily: 'ProductSans'),), onTap: () { _category = 'Videogame Asset'; setState(() {}); Navigator.pop(context); }, ), ListTile( leading: Icon(OMIcons.devicesOther), title: Text('Gadgets', style: TextStyle( fontFamily: 'ProductSans'),), subtitle: Text('phones, tablets, watches and laptops', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { _category = 'Gadgets'; setState(() {}); Navigator.pop(context); }, ), ListTile( leading: Icon(OMIcons.videogameAsset), title: Text('Electronics', style: TextStyle( fontFamily: 'ProductSans'),), subtitle: Text( 'dishwashers, mixers, multicookers and hoem electronics', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { _category = 'Electronics'; setState(() {}); Navigator.pop(context); }, ), ListTile( leading: Icon(OMIcons.childFriendly), title: Text('Children stuff', style: TextStyle( fontFamily: 'ProductSans'),), subtitle: Text( 'everthing for parents and their children', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { _category = 'Childrens things'; setState(() {}); Navigator.pop(context); }, ), ], ), ); }), ), ); } ); } _androidBottomSheet() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Padding( padding: const EdgeInsets.all(6.0), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), //color: Colors.white, child: Container( //color: Colors.transparent, child: new Wrap( children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 12.0,), child: new Text('Add photo', style: TextStyle( fontFamily: 'ProductSans', fontSize: 18.0),), ), new ListTile( leading: new Icon(OMIcons.camera), title: new Text('Take Photo', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => { _handleImage(ImageSource.camera), } ), new ListTile( leading: new Icon(OMIcons.photo), title: new Text('Choose from Gallery', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => { _handleImage(ImageSource.gallery), }, ), new ListTile( leading: new Icon(OMIcons.cancel, color: Colors.redAccent,), title: new Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.redAccent),), onTap: () => Navigator.pop(context), ), ], ), ), ), ); } ); } _androidDialog() { showDialog(context: context, builder: (BuildContext context) { return SimpleDialog( //backgroundColor: Colors.greenAccent, title: Text('Add Photo', style: TextStyle(fontFamily: 'ProductSans'),), children: <Widget>[ SimpleDialogOption( child: Row( children: <Widget>[ Icon(Icons.camera), SizedBox(width: 5.0,), Text('Take Photo', style: TextStyle(fontFamily: 'ProductSans'),), ], ), onPressed: ()=> _handleImage(ImageSource.camera), ), SimpleDialogOption( child: Row( children: <Widget>[ Icon(Icons.photo), SizedBox(width: 5.0,), Text('Choose from Gallery', style: TextStyle(fontFamily: 'ProductSans'),), ], ), onPressed: ()=> _handleImage(ImageSource.gallery), ), SimpleDialogOption( child: Row( children: <Widget>[ Icon(Icons.cancel, color: Colors.red,), SizedBox(width: 5.0,), Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.red),), ], ), onPressed: ()=> Navigator.pop(context), ), ], ); } ); } _androidTimeSheet() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Padding( padding: const EdgeInsets.all(6.0), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), //color: Colors.white, child: Container( //color: Colors.transparent, child: new Wrap( children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 12.0,), child: new Text('Choose time', style: TextStyle( fontFamily: 'ProductSans', fontSize: 18.0),), ), new ListTile( leading: new Icon(OMIcons.today), title: new Text('Day', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { _time = 'Day'; setState(() {}); Navigator.pop(context); }, ), new ListTile( leading: new Icon(OMIcons.dateRange), title: new Text('Week', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { _time = 'Week'; setState(() {}); Navigator.pop(context); }, ), new ListTile( leading: new Icon(OMIcons.eventNote), title: new Text('Month', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { _time = 'Month'; setState(() {}); Navigator.pop(context); }, ), new ListTile( leading: new Icon(OMIcons.cancel, color: Colors.redAccent,), title: new Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.redAccent),), onTap: () => Navigator.pop(context), ), ], ), ), ), ); } ); } _iosTimeSheet() { showCupertinoModalPopup( context: context, builder: (BuildContext context) { return CupertinoActionSheet( title: Text('Choose time'), actions: <Widget>[ CupertinoActionSheetAction( child: Text('Day'), onPressed: () { _time = 'Day'; setState(() {}); Navigator.pop(context); } ), CupertinoActionSheetAction( child: Text('Week'), onPressed: () { _time = 'Week'; setState(() {}); Navigator.pop(context); } ), CupertinoActionSheetAction( child: Text('Month'), onPressed: () { _time = 'Month'; setState(() {}); Navigator.pop(context); } ), ], cancelButton: CupertinoActionSheetAction( child: Text('Cancel'), onPressed: ()=> Navigator.pop(context), ), ); }, ); } _handleImage(ImageSource source) async { Navigator.pop(context); File imageFile = await ImagePicker.pickImage(source: source); if (imageFile != null) { imageFile = await _cropImage(imageFile); setState(() { _image = imageFile; }); } } _cropImage(File imageFile) async { File croppedImage = await ImageCropper.cropImage( sourcePath: imageFile.path, //compressQuality: 10, androidUiSettings: AndroidUiSettings( toolbarTitle: 'Edit photo', activeControlsWidgetColor: Colors.greenAccent, activeWidgetColor: Colors.greenAccent, toolbarColor: Colors.greenAccent, toolbarWidgetColor: Colors.black87, initAspectRatio: CropAspectRatioPreset.square, //lockAspectRatio: true, ), /*aspectRatioPresets: [ CropAspectRatioPreset.square, CropAspectRatioPreset.ratio3x2, CropAspectRatioPreset.original, CropAspectRatioPreset.ratio4x3, CropAspectRatioPreset.ratio16x9 ],*/ //aspectRatio: CropAspectRatio(ratioX: 1.0, ratioY: 1.0,), ); return croppedImage; } _submit() async { if (!_isLoading && _image != null && _caption.isNotEmpty) { setState(() { _isLoading = true; }); // Create post String imageUrl = await StorageService.uploadPost(_image); Post post = Post( imageUrl: imageUrl, caption: _caption, name: _name, price: _price, time: _time, location: _location, category: _category, likeCount: 0, authorId: Provider.of<UserData>(context).currentUserId, timestamp: Timestamp.fromDate(DateTime.now()), ); DatabaseService.createPost(post); DatabaseService.createFeedPost(post); // Reset data _captionController.clear(); _locationController.clear(); _nameController.clear(); _priceController.clear(); _timeController.clear(); setState(() { _image = null; _caption = ''; _name = ''; _price = ''; _location = ''; _time = ''; _category = ''; _isLoading = false; }); } } @override Widget build(BuildContext context) { final height = MediaQuery.of(context).size.height; final width = MediaQuery.of(context).size.width; return Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return <Widget>[ HidingAppBar(forceElevated: innerBoxIsScrolled), ]; }, body: GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: SingleChildScrollView( child: Container( //height: height, child: Column( children: <Widget>[ _isLoading ? Padding( padding: EdgeInsets.only(bottom: 10.0), child: LinearProgressIndicator( backgroundColor: Colors.greenAccent, valueColor: AlwaysStoppedAnimation(Colors.green), ), ) : SizedBox.shrink(), GestureDetector( onTap: _showSelectImageDialog, child: OrientationBuilder( builder: (context, orentation) { return Container( height: 250, width: orentation == Orientation.portrait ? 520 : 320, //color: Colors.white, child: _image == null ? Image(image: AssetImage( 'assets/images/images.png'),) : Image( image: FileImage(_image), fit: BoxFit.cover, ), ); } ), ), SizedBox(height: 20.0), Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: TextFormField( controller: _nameController, style: TextStyle(fontSize: 18.0, fontFamily: 'productSans'), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Name', ), onChanged: (input) => _name = input, ), ), SizedBox(height: 10.0,), Row(), Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: TextFormField( keyboardType: TextInputType.numberWithOptions(), controller: _priceController, style: TextStyle(fontSize: 18.0, fontFamily: 'productSans'), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Price', ), onChanged: (input) => _price = input, ), ), SizedBox(height: 10.0,), /*Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: TextFormField( keyboardType: TextInputType.numberWithOptions(), controller: _timeController, style: TextStyle(fontSize: 18.0, fontFamily: 'productSans'), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Time(days)', ), onChanged: (input) => _time = input, ), ),*/ Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 5.0, ), child: GestureDetector( //onTap: () async {_showSelectRegionDialog();}, onTap: _showTimeChooseDialog, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.0)), border: Border.all(color: Colors.grey), ), padding: EdgeInsets.fromLTRB(10,20,20,20,), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Time ", style: TextStyle(fontSize: 16, fontFamily: 'ProductSans', color: Colors.grey[600]),), Text("$_time", style: TextStyle(fontFamily: 'ProductSans'),), ], ), ), ), ), SizedBox(height: 10.0,), Padding( padding: EdgeInsets.symmetric( horizontal: 30.0, vertical: 5.0, ), child: GestureDetector( //onTap: ()=> selectDate(context, DateTime.now(),), onTap: () async {_showSelectChooseDialog();}, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.0)), border: Border.all(color: Colors.grey), ), padding: EdgeInsets.fromLTRB(10,20,20,20,), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("Category ", style: TextStyle(fontSize: 16, fontFamily: 'ProductSans', color: Colors.grey[600]),), Text("$_category", style: TextStyle(fontFamily: 'ProductSans'),) ], ), ), ), ), SizedBox(height: 10.0,), Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: TextFormField( controller: _locationController, style: TextStyle(fontSize: 18.0, fontFamily: 'productSans'), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Location', ), onChanged: (input) => _location = input, ), ), SizedBox(height: 10.0,), //phoneTextFiled(user), //SizedBox(height: 10.0,), Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: TextFormField( controller: _captionController, style: TextStyle(fontSize: 18.0, fontFamily: 'productSans'), decoration: InputDecoration( border: new OutlineInputBorder( borderRadius: BorderRadius.circular(18.0), borderSide: new BorderSide(color: Colors.greenAccent), ), labelText: 'Caption', ), onChanged: (input) => _caption = input, ), ), SizedBox(height: 10.0,), FlatButton ( shape: RoundedRectangleBorder( borderRadius: new BorderRadius.circular(18.0), ), child: Text('add product', style: TextStyle(fontFamily: 'ProductSans'),), color: Colors.greenAccent, textColor: Colors.black, onPressed: _submit, ), SizedBox(height: 30.0,), ], ), ), ), ), ), ); } }
0
mirrored_repositories/folka/lib
mirrored_repositories/folka/lib/screens/DetailsScreen.dart
import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:folka/models/Post.dart'; import 'package:folka/models/User.dart'; import 'package:folka/screens/ProfleSmbScreen.dart'; import 'package:folka/screens/QrScreen.dart'; import 'package:folka/services/ShareService.dart'; import 'package:geocoder/geocoder.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:location/location.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:outline_material_icons/outline_material_icons.dart'; import 'package:photo_view/photo_view.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:super_qr_reader/super_qr_reader.dart'; import 'package:url_launcher/url_launcher.dart'; class DetailsScreen extends StatefulWidget { final String currentUserId; final String userId; final bool authorScanBool; final Post post; final User author; Future<void> _launched; DetailsScreen({this.post, this.author, this.currentUserId, this.userId, this.authorScanBool}); @override State<StatefulWidget> createState() { return _DetailsScreenState(); } } class _DetailsScreenState extends State<DetailsScreen> { GoogleMapController mapController; String searchAddress; String result = ''; LatLng taxiLatLng; @override void initState() { super.initState(); print('current user: ${widget.currentUserId}'); //searchAndNavigate(); } _showQr() { if (widget.authorScanBool == true) { return Platform.isIOS ? _iosQr() : _androidQr(); } else if (widget.authorScanBool == false) { return Platform.isIOS ? _iosQr() : _androidQr(); } } _iosQr() { return showCupertinoModalPopup( context: context, builder: (BuildContext context) { return Container( color: CupertinoColors.white, child: Padding( padding: const EdgeInsets.all(24.0), child: QrImage( data: widget.author.id + widget.post.name, ), ), ); }); } _androidQr() { return showDialog(context: context, builder: (BuildContext context) { return SimpleDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), //backgroundColor: Colors.greenAccent, title: Text('Let scan this qr code', style: TextStyle(fontFamily: 'ProductSans'),), children: <Widget>[ SimpleDialogOption( child: Container( width: 100, height: 240, child: QrImage( backgroundColor: Colors.white, data: widget.post.name + widget.author.id, ), ), //onPressed: ()=> _handleImage(ImageSource.camera), ), SimpleDialogOption( child: Row( children: <Widget>[ Icon(OMIcons.cancel, color: Colors.red,), SizedBox(width: 5.0,), Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.red),), ], ), onPressed: ()=> Navigator.pop(context), ), ], ); },); } pushToProfile() { Navigator.push( context, MaterialPageRoute( builder: (_) => ProfileSMDScreen( userId: widget.author.id, //author: widget.author, //likeCount: _likeCount, ), ), ); } Future<void> _launchUrl(String url) async { if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } makeCall() { _launchUrl('tel:${widget.author.phone}'); } sendSms() { _launchUrl('sms:${widget.author.phone}?body=Hi%20there,%20its%20shelf%20app%20user'); } sendEmail() { _launchUrl( 'mailto:${widget.author.email}' '?subject=Shelf app - ${widget.post.name}' '&body=<body>, e.g. mailto:smith@example.org' '?subject=News&body=Hi%20there,%20its%20shelf%20app%20user'); } makeRoute() { MapsLauncher.launchQuery( widget.post.location/*+ '' + widget.author.address*/); } // https://yandex.ru/dev/taxi/doc/dg/concepts/deeplinks-docpage/ ссылка на документацию takeTaxi() { _launchUrl('https://3.redirect.appmetrica.yandex.com/route?' //Широта точки назначения //+ 'end-lat=' + '${Geocoder.local.findAddressesFromQuery(widget.post.location)}' + 'end-lat=' + '${taxiLatLng.latitude}' //Долгота точки назначения //+ '&end-lon=' + '${Geocoder.local.findAddressesFromQuery(widget.post.location)}' + '&end-lon=' + '${taxiLatLng.longitude}' //Идентификатор источника + '&ref=' + 'shelf' //Идентификатор, который определяет логику редиректа + '&appmetrica_tracking_id=' + '25395763362139037' ); } _iosRouteBottomSheet() { showCupertinoModalPopup( context: context, builder: (BuildContext context) { return CupertinoActionSheet( title: Text('Choose Route'), actions: <Widget>[ CupertinoActionSheetAction( child: Text('Route'), onPressed: () => makeRoute(), ), CupertinoActionSheetAction( child: Text('Take Taxi'), onPressed: () => takeTaxi(), ), ], cancelButton: CupertinoActionSheetAction( child: Text('Cancel'), onPressed: () => Navigator.pop(context), ), ); }, ); } _androidRouteBottomSheet() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Padding( padding: const EdgeInsets.all(6.0), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), //color: Colors.white, child: Container( //color: Colors.transparent, child: new Wrap( children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 12.0,), child: new Text('Choose Route', style: TextStyle( fontFamily: 'ProductSans', fontSize: 18.0),), ), new ListTile( leading: new Icon(OMIcons.map), title: new Text('Route', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => makeRoute(), ), new ListTile( leading: new Icon(OMIcons.localTaxi), title: new Text('Take Taxi', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => takeTaxi(), ), new ListTile( leading: new Icon(OMIcons.cancel, color: Colors.redAccent,), title: new Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.redAccent),), onTap: () => Navigator.pop(context), ), ], ), ), ), ); } ); } _iosContactBottomSheet() { showCupertinoModalPopup( context: context, builder: (BuildContext context) { return CupertinoActionSheet( title: Text('Choose Action'), actions: <Widget>[ CupertinoActionSheetAction( child: Text('Call'), onPressed: () => makeCall(), ), CupertinoActionSheetAction( child: Text('SMS'), onPressed: () => sendSms(), ), CupertinoActionSheetAction( child: Text('Email'), onPressed: () => sendEmail(), ), CupertinoActionSheetAction( child: Text('Dashboard message'), onPressed: () { Navigator.pop(context); showDialog( context: context, builder: (BuildContext context) => CupertinoAlertDialog( title: new Text('Dashboard message'), content: Padding( padding: const EdgeInsets.all(8.0), child: new Text( '1. Choose picture of this product\n' '2. Write your message on dashboard\n' '3. Send it and wait for answer', ), ), actions: <Widget>[ CupertinoDialogAction( isDefaultAction: true, child: Text('Lets Go'), onPressed: ()=> pushToProfile(), ), CupertinoDialogAction( child: Text('Cancel', style: TextStyle(color: CupertinoColors.destructiveRed),), onPressed: ()=> Navigator.pop(context), ) ], ) ); } ), ], cancelButton: CupertinoActionSheetAction( child: Text('Cancel'), onPressed: () => Navigator.pop(context), ), ); }, ); } _androidContactBottomSheet() { showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (BuildContext context) { return Padding( padding: const EdgeInsets.all(6.0), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), //color: Colors.white, child: Container( height: 330, //color: Colors.transparent, child: new ListView( physics: BouncingScrollPhysics(), children: <Widget>[ Padding( padding: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 12.0,), child: new Text('Choose Action', style: TextStyle( fontFamily: 'ProductSans', fontSize: 18.0),), ), new ListTile( leading: new Icon(OMIcons.phone), title: new Text('Call', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => makeCall(), ), new ListTile( leading: new Icon(OMIcons.sms), title: new Text('SMS', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => sendSms(), ), new ListTile( leading: new Icon(OMIcons.email), title: new Text('Email', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () => sendEmail(), ), new ListTile( leading: new Icon(OMIcons.dashboard), title: new Text('Dashboard Message', style: TextStyle(fontFamily: 'ProductSans'),), onTap: () { Navigator.pop(context); showDialog(context: context, builder: (BuildContext context) { return AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), title: Text('Dashboard Message', style: TextStyle(fontFamily: 'ProductSans'),), content: Container( height: 290, width: 520, child: OrientationBuilder( builder: (context, orientation){ if (orientation == Orientation.portrait) { return Column( children: <Widget>[ Container( child: Image(image: AssetImage('assets/images/messages.png'),) ), Padding( padding: const EdgeInsets.all(8.0), child: Text( '1. Choose picture of this product\n' '2. Write your message on dashboard\n' '3. Send it and wait for answer', style: TextStyle(fontFamily: 'ProductSans'), ), ), ], ); } else { return Row( children: <Widget>[ Container( child: Image(image: AssetImage('assets/images/messages.png'),) ), Padding( padding: const EdgeInsets.all(8.0), child: Text( '1. Choose picture of this product\n' '2. Write your message on dashboard\n' '3. Send it and wait for answer', style: TextStyle(fontFamily: 'ProductSans'), ), ), ], ); } }, ), ), actions: <Widget>[ FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), child: Row( children: <Widget>[ Icon(OMIcons.checkCircle), Text('Lets Go', style: TextStyle(fontFamily: 'ProductSans'),), ], ), onPressed: ()=> pushToProfile(), ), FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.0), ), child: Row( children: <Widget>[ Icon(OMIcons.cancel, color: Colors.red,), Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.red),), ], ), onPressed: ()=> Navigator.pop(context), ), ], ); } ); } ), new ListTile( leading: new Icon(OMIcons.cancel, color: Colors.redAccent,), title: new Text('Cancel', style: TextStyle(fontFamily: 'ProductSans', color: Colors.redAccent),), onTap: () => Navigator.pop(context), ), ], ), ), ), ); } ); } @override Widget build(BuildContext context) { BuildContext _scaffoldContext; pushToQr() async { if(widget.authorScanBool == true) { Navigator.push( context, MaterialPageRoute( builder: (_) => QrScreen( userId: widget.author.id, post: widget.post, currentUserId: widget.currentUserId, authorScanBool: widget.authorScanBool, //author: widget.author, //likeCount: _likeCount, ), ), ); } else if (widget.authorScanBool == false) { String results = await Navigator.push( context, MaterialPageRoute( builder: (context) => ScanView(), ), ); if (results != null) { setState(() { result = results; print('qr code result = ' + result); }); Navigator.push( context, MaterialPageRoute( builder: (context) => QrScreen( userId: widget.author.id, post: widget.post, currentUserId: widget.currentUserId, authorScanBool: widget.authorScanBool, ), ), ); } } } searchAndNavigate() { searchAddress = widget.author.address+ ' ' + widget.post.location; Geolocator().placemarkFromAddress(searchAddress).then((result) { mapController.animateCamera(CameraUpdate.newCameraPosition(CameraPosition( target: taxiLatLng = LatLng(result[0].position.latitude, result[0].position.longitude), zoom: 15.0))); }); } void onMapCreated(controller) { setState(() { searchAndNavigate(); mapController = controller; }); } _showSelectContactSheet() { return Platform.isIOS ? _iosContactBottomSheet() : _androidContactBottomSheet(); } _showSelectRouteSheet() { return Platform.isIOS ? _iosRouteBottomSheet() : _androidRouteBottomSheet(); } Widget _mapSection = Container( decoration: BoxDecoration( border: Border.all( color: Colors.black, width: 8, ), borderRadius: BorderRadius.circular(12), ), height: 220, width: 600, child: GoogleMap( onMapCreated: onMapCreated, initialCameraPosition: CameraPosition( target: LatLng(59.9617101, 30.3135917), zoom: 10.0 )), ); Widget _addressSection = Container( //padding: const EdgeInsets.all(32), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( OMIcons.place, size: 16.0, color: Colors.yellow, ), Text( widget.post.location + '-' + widget.author.address, softWrap: true, textAlign: TextAlign.justify, style: TextStyle(fontFamily: 'ProductSans', color: Colors.yellow ), ), ], ), ); Widget _textSection = Container( padding: const EdgeInsets.fromLTRB(22, 10, 22, 12,), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(OMIcons.category, color: Colors.grey,), Text('Category: ' + widget.post.category, style: TextStyle(fontFamily: 'ProductSans', fontSize: 16, color: Colors.grey),), ],), SizedBox(height: 12,), Text( widget.post.caption, softWrap: true, textAlign: TextAlign.justify, style: TextStyle(fontFamily: 'ProductSans'), ), ], ), ); //Color color = Theme.of(context).primaryColor; Color color = Colors.black; Widget _buttonSection = Container( child: Card( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(34)), color: Colors.greenAccent, child: Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children:[ FlatButton( onPressed: _showSelectContactSheet, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children:[ Icon(OMIcons.message, color: Colors.black87), Container( margin: const EdgeInsets.only(top:8), child: Text( 'CONTACT', style: TextStyle( fontSize: 12, fontWeight: FontWeight.normal, color: Colors.black87, //color: color, ), ), ) ], ), ), FlatButton( onPressed: _showSelectRouteSheet, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children:[ Icon(OMIcons.nearMe, color: Colors.black87,), Container( margin: const EdgeInsets.only(top:8), child: Text( 'ROUTE', style: TextStyle( fontSize: 12, fontWeight: FontWeight.normal, color: Colors.black87, //color: color, ), ), ) ], ), ), FlatButton( onPressed: pushToQr, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children:[ Icon(OMIcons.description, color: Colors.black87,), Container( margin: const EdgeInsets.only(top:8), child: Text( 'SCAN', style: TextStyle( fontSize: 12, fontWeight: FontWeight.normal, color: Colors.black87, //color: color, ), ), ) ], ), ), /*buildButtonColumn(color, Icons.call, "CALL",), buildButtonColumn(color, Icons.near_me, "ROUTE"), buildButtonColumn(color, Icons.share, "SHARE"),*/ ], ), ), ), ); Widget _authorSection = Row( children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: CircleAvatar( radius: 30.0, backgroundColor: Colors.grey, backgroundImage: widget.author.profileImageUrl.isEmpty ? AssetImage('assets/images/avatar.png') : CachedNetworkImageProvider( widget.author.profileImageUrl), ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ //SizedBox(width: 8.0), Text( widget.author.name, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), SizedBox(width: 4.0), Text( widget.author.surname, style: TextStyle( fontSize: 18.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w600, ), ), SizedBox(width: 8.0), Icon( OMIcons.map, color: Colors.yellow, ), Text( widget.author.address, style: TextStyle( color: Colors.yellow, fontSize: 14.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w400, ), ), ], ), Row( children: <Widget>[ Text( widget.author.email, style: TextStyle( color: Colors.grey, fontSize: 16.0, fontFamily: 'ProductSans', fontWeight: FontWeight.w500, ), ), SizedBox(width: 5.0,), Icon( OMIcons.star, color: Colors.red, ), Text(widget.post.likeCount.toString()), ], ), ], ), ], ); Widget titleSection = Container( padding: const EdgeInsets.fromLTRB(12, 0, 12, 10), child: Row( children:[ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children:[ Row( children: <Widget>[ Chip( avatar: CircleAvatar( backgroundColor: Colors.green, child: Icon(OMIcons.attachMoney, color: Colors.black87, size: 24,), ), label: Text(widget.post.price + ' RUB', style: TextStyle(fontFamily: 'ProductSans', fontSize: 22, color: Colors.green),), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 2.0), child: Text(' per', style: TextStyle(fontFamily: 'ProductSans', fontSize: 18),), ), Chip( avatar: CircleAvatar( backgroundColor: Colors.blue, child: Icon(OMIcons.timer, color: Colors.black87, size: 24,), ), label: Text(widget.post.time, style: TextStyle(fontFamily: 'ProductSans', fontSize: 22, color: Colors.blue),), ), ], ), Padding( padding: const EdgeInsets.all(4.0), child: Divider( thickness: 3.0, ), ), ], ), ), ], ), ); Column buildButtonColumn(Color color, IconData icon, String lable){ return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children:[ Icon(icon, color: color), Container( margin: const EdgeInsets.only(top:8), child: Text( lable, style: TextStyle( fontSize: 12, fontWeight: FontWeight.w100, color: color, ), ), ) ], ); } bodyView() { return ListView( children: <Widget>[ /*Container( height: 350, width: 241, //height: MediaQuery.of(context).size.width, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12.0), image: DecorationImage( image: CachedNetworkImageProvider(widget.post.imageUrl), fit: BoxFit.cover, ), ), ),*/ titleSection, GestureDetector( onTap: pushToProfile, child: _authorSection), _buttonSection, _textSection, _mapSection, _addressSection, ], ); } return Scaffold( body: OrientationBuilder( builder: (context, orientation){ if (orientation == Orientation.portrait) { return Scaffold( body: Stack( children: <Widget>[ Container( foregroundDecoration: BoxDecoration( color: Colors.black26 ), height: 360, width: MediaQuery.of(context).size.width, child: GestureDetector( child: CachedNetworkImage( imageUrl: widget.post.imageUrl, placeholder: (context, url) => Center( child: Container( child: CircularProgressIndicator() ), ), errorWidget: (context, url, error) => Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Ошибка при загрузке картинки"), Icon(Icons.error) ] ), fit: BoxFit.cover, ), onTap: () => showDialog( context: context, builder: (_)=> new SimpleDialog( backgroundColor: Colors.transparent, children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.all( Radius.circular(30) ), ), width: MediaQuery.of(context).size.width, height: 400, child: Padding( padding: const EdgeInsets.all(10.0), child: PhotoView( backgroundDecoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.all( Radius.circular(30) ), ), imageProvider: CachedNetworkImageProvider( widget.post.imageUrl ), ), ), ), ], ), ), ), ), SingleChildScrollView( padding: const EdgeInsets.only(top: 16.0,bottom: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ const SizedBox(height: 250), Padding( padding: const EdgeInsets.symmetric(horizontal:16.0), child: Text( widget.post.name, style: TextStyle(color: Colors.white, fontSize: 28.0, fontWeight: FontWeight.bold, fontFamily: 'ProductSans',), ), ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 16.0, ), decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(20.0)), child: Text( widget.post.category, style: TextStyle(color: Colors.white, fontSize: 13.0, fontFamily: 'ProductSans',), ), ), Spacer(), IconButton( icon: Icon(Icons.favorite_border,), tooltip: 'like', //onPressed: () { changePlaceLike(); }, ), ], ), Container( padding: const EdgeInsets.all(32.0), //color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ Row( children: <Widget>[ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star_border, color: Colors.greenAccent, ), ], ), Text.rich(TextSpan(children: [ WidgetSpan( child: Icon(OMIcons.locationOn, size: 16.0, color: Colors.grey,) ), TextSpan( text: widget.post.location, ) ]), style: TextStyle(color: Colors.grey, fontSize: 12.0, fontFamily: 'ProductSans',),) ], ), ), Column( children: <Widget>[ Text("\₽ ${widget.post.price}", style: TextStyle( color: Colors.greenAccent, fontWeight: FontWeight.bold, fontFamily: 'ProductSans', fontSize: 20.0 ),), Text("/per ${widget.post.time}",style: TextStyle( fontFamily: 'ProductSans', fontSize: 12.0, color: Colors.grey ),) ], ) ], ), const SizedBox(height: 30.0), _buttonSection, /*SizedBox( width: double.infinity, child: RaisedButton( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)), color: Colors.orangeAccent, textColor: Colors.white, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.map), SizedBox(width: 2,), Text("Найти на карте", style: TextStyle( fontWeight: FontWeight.normal, fontFamily: 'ProductSans', ),), ], ), padding: const EdgeInsets.symmetric( vertical: 16.0, horizontal: 32.0, ), onPressed: () {MapsLauncher.launchQuery(widget.author.address + ' ' + widget.post.location,);}, ), ),*/ const SizedBox(height: 30.0), Text("DESCRIPTION".toUpperCase(), style: TextStyle( fontWeight: FontWeight.w600, fontFamily: 'ProductSans', fontSize: 14.0 ),), const SizedBox(height: 10.0), Text( widget.post.caption, textAlign: TextAlign.justify, style: TextStyle( fontWeight: FontWeight.w300, fontFamily: 'ProductSans', fontSize: 14.0 ),), const SizedBox(height: 10.0), _mapSection, const SizedBox(height: 10.0), _authorSection, Container( //padding: const EdgeInsets.symmetric(horizontal: 8), child: Wrap( alignment: WrapAlignment.spaceAround, children: [ //Chip(label: Text('#'+widget.place.goals[0]),), //Chip(label: Text('#'+widget.place.goals[1]),), //Chip(label: Text('#'+widget.place.goals[2]),), ], ), ), ], ), ), ], ), ), Positioned( top: 0, left: 0, right: 0, child: AppBar( backgroundColor: Colors.transparent, elevation: 0, centerTitle: true, /*title: Container( decoration: BoxDecoration( color: Colors.greenAccent, border: Border.all( color: Colors.greenAccent, width: 4, ), borderRadius: BorderRadius.circular(12), ), child: new Text('DETAILS', style: TextStyle(fontFamily: 'ProductSans', fontSize: 16, color: Colors.black87),), ),*/ actions: <Widget>[ Padding( padding: EdgeInsets.only(right: 20.0), child: GestureDetector( onTap: ()=> share( context, '${widget.post.name} -\n' '${widget.post.caption}\n\n' 'price = ${widget.post.price}RUB in ${widget.post.time}\n\n' 'location: ${widget.post.location +' '+ widget.author.address}\n\n' 'property owner: ${widget.author.name +' '+ widget.author.surname}\n\n' 'tel: ${widget.author.phone}\n' 'email: ${widget.author.email}\n\n' 'send from Shelf app\n\n' 'https://play.google.com/store/apps/details?id=nudle.shelf',), child: Icon( OMIcons.share, size: 26.0, ), ) ), ], ), ), ], ), ); } else { return Row( children: [ GestureDetector( child: Container( alignment: Alignment.topLeft, child: Stack( children: [ Stack( children: [ Positioned( bottom: 12, left: 12, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal:16.0), child: Text( widget.post.name, style: TextStyle(color: Colors.white, fontSize: 28.0, fontWeight: FontWeight.bold, fontFamily: 'ProductSans',), ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 16.0, ), decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(20.0)), child: Text( widget.post.category, style: TextStyle(color: Colors.white, fontSize: 13.0, fontFamily: 'ProductSans',), ), ), //Spacer(), IconButton( icon: Icon(Icons.favorite_border,), tooltip: 'like', //onPressed: () { changePlaceLike(); }, ), ], ), ], ), ), ], ), Padding( padding: const EdgeInsets.fromLTRB(2, 26, 0, 0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Stack(children: [ IconButton(icon: Icon(OMIcons.arrowBack, size: 23,), onPressed: () { Navigator.pop(context); },), ],), Stack(children: [ Container( decoration: BoxDecoration( color: Colors.greenAccent, /*border: Border.all( color: Colors.orangeAccent, width: 2, ),*/ borderRadius: BorderRadius.circular(14), ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 6.0), //child: new Text(widget.post.name, style: TextStyle(fontFamily: 'ProductSans', color: Colors.black87, fontSize: 23),), ), ), ],), Stack(children: [ IconButton(icon: Icon(OMIcons.share, size: 23,), onPressed: () { share( context, '${widget.post.name} -\n' '${widget.post.caption}\n\n' 'price = ${widget.post.price}RUB in ${widget.post.time}\n\n' 'location: ${widget.post.location +' '+ widget.author.address}\n\n' 'property owner: ${widget.author.name +' '+ widget.author.surname}\n\n' 'tel: ${widget.author.phone}\n' 'email: ${widget.author.email}\n\n' 'send from Shelf app\n\n' 'https://play.google.com/store/apps/details?id=nudle.shelf', ); },), ],), ], ), ), ], ), height: MediaQuery .of(context) .size .height, width: MediaQuery .of(context) .size .width / 2.5, //height: MediaQuery.of(context).size.width, decoration: BoxDecoration( //borderRadius: BorderRadius.circular(12.0), image: DecorationImage( image: CachedNetworkImageProvider(widget.post.imageUrl), fit: BoxFit.cover, ), ), ), onTap: () => showDialog( context: context, builder: (_) => SimpleDialog( backgroundColor: Colors.transparent, children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.all( Radius.circular(30) ), ), width: MediaQuery.of(context).size.height, height: 300, child: Padding( padding: const EdgeInsets.all(10.0), child: PhotoView( backgroundDecoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.all( Radius.circular(30) ), ), imageProvider: CachedNetworkImageProvider(widget.post.imageUrl,), ), ), ), ], ), ), ), //bodyView Expanded(child: SingleChildScrollView( padding: const EdgeInsets.only(top: 16.0,bottom: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ //const SizedBox(height: 250), /*Padding( padding: const EdgeInsets.symmetric(horizontal:16.0), child: Text( widget.post.name, style: TextStyle(color: Colors.white, fontSize: 28.0, fontWeight: FontWeight.bold, fontFamily: 'ProductSans',), ), ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 16.0, ), decoration: BoxDecoration( color: Colors.grey, borderRadius: BorderRadius.circular(20.0)), child: Text( widget.post.category, style: TextStyle(color: Colors.white, fontSize: 13.0, fontFamily: 'ProductSans',), ), ), Spacer(), IconButton( icon: Icon(Icons.favorite_border,), tooltip: 'like', //onPressed: () { changePlaceLike(); }, ), ], ),*/ Container( padding: const EdgeInsets.all(32.0), //color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ Row( children: <Widget>[ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Row( children: <Widget>[ Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star, color: Colors.greenAccent, ), Icon( Icons.star_border, color: Colors.greenAccent, ), ], ), Text.rich(TextSpan(children: [ WidgetSpan( child: Icon(OMIcons.locationOn, size: 16.0, color: Colors.grey,) ), TextSpan( text: widget.post.location, ) ]), style: TextStyle(color: Colors.grey, fontSize: 12.0, fontFamily: 'ProductSans',),) ], ), ), Column( children: <Widget>[ Text("\₽ ${widget.post.price}", style: TextStyle( color: Colors.greenAccent, fontWeight: FontWeight.bold, fontFamily: 'ProductSans', fontSize: 20.0 ),), Text("/per ${widget.post.time}",style: TextStyle( fontFamily: 'ProductSans', fontSize: 12.0, color: Colors.grey ),) ], ) ], ), const SizedBox(height: 30.0), _buttonSection, /*SizedBox( width: double.infinity, child: RaisedButton( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)), color: Colors.orangeAccent, textColor: Colors.white, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.map), SizedBox(width: 2,), Text("Найти на карте", style: TextStyle( fontWeight: FontWeight.normal, fontFamily: 'ProductSans', ),), ], ), padding: const EdgeInsets.symmetric( vertical: 16.0, horizontal: 32.0, ), onPressed: () {MapsLauncher.launchQuery(widget.author.address + ' ' + widget.post.location,);}, ), ),*/ const SizedBox(height: 30.0), Text("DESCRIPTION".toUpperCase(), style: TextStyle( fontWeight: FontWeight.w600, fontFamily: 'ProductSans', fontSize: 14.0 ),), const SizedBox(height: 10.0), Text( widget.post.caption, textAlign: TextAlign.justify, style: TextStyle( fontWeight: FontWeight.w300, fontFamily: 'ProductSans', fontSize: 14.0 ),), const SizedBox(height: 10.0), _mapSection, const SizedBox(height: 10.0), _authorSection, Container( //padding: const EdgeInsets.symmetric(horizontal: 8), child: Wrap( alignment: WrapAlignment.spaceAround, children: [ //Chip(label: Text('#'+widget.place.goals[0]),), //Chip(label: Text('#'+widget.place.goals[1]),), //Chip(label: Text('#'+widget.place.goals[2]),), ], ), ), ], ), ), ], ), ), ), ], ); } } ), ); } }
0
mirrored_repositories/folka
mirrored_repositories/folka/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:folka/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-Weather-App-Bloc
mirrored_repositories/Flutter-Weather-App-Bloc/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:geolocator/geolocator.dart'; import 'package:weather_app_bloc_1/bloc/weather_bloc.dart'; import 'package:weather_app_bloc_1/screens/home_screen.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: FutureBuilder( future: _determinePosition(), builder: (context, snap) { if (snap.hasData) { return BlocProvider<WeatherBloc>( create: (context) => WeatherBloc()..add(FetchWeather(snap.data as Position)), child: const HomeScreen(), ); } else { return const Scaffold( body: Center( child: CircularProgressIndicator(), ), ); } })); } Future<Position> _determinePosition() async { bool serviceEnabled; LocationPermission permission; // Test if location services are enabled. serviceEnabled = await Geolocator.isLocationServiceEnabled(); if (!serviceEnabled) { // Location services are not enabled don't continue // accessing the position and request users of the // App to enable the location services. return Future.error('Location services are disabled.'); } permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); if (permission == LocationPermission.denied) { // Permissions are denied, next time you could try // requesting permissions again (this is also where // Android's shouldShowRequestPermissionRationale // returned true. According to Android guidelines // your App should show an explanatory UI now. return Future.error('Location permissions are denied'); } } if (permission == LocationPermission.deniedForever) { // Permissions are denied forever, handle appropriately. return Future.error( 'Location permissions are permanently denied, we cannot request permissions.'); } // When we reach here, permissions are granted and we can // continue accessing the position of the device. return await Geolocator.getCurrentPosition(); } }
0
mirrored_repositories/Flutter-Weather-App-Bloc/lib
mirrored_repositories/Flutter-Weather-App-Bloc/lib/data/my_data.dart
String API_KEY = "397d8380c3ad210f4ff57e587405af2b";
0
mirrored_repositories/Flutter-Weather-App-Bloc/lib
mirrored_repositories/Flutter-Weather-App-Bloc/lib/bloc/weather_event.dart
part of 'weather_bloc.dart'; @immutable abstract class WeatherEvent {} sealed class WeatherBlocEvent extends Equatable { const WeatherBlocEvent(); @override List<Object> get props => []; } class FetchWeather extends WeatherBlocEvent { final Position position; const FetchWeather(this.position); @override List<Object> get props => [position]; }
0
mirrored_repositories/Flutter-Weather-App-Bloc/lib
mirrored_repositories/Flutter-Weather-App-Bloc/lib/bloc/weather_state.dart
part of 'weather_bloc.dart'; sealed class WeatherBlocState extends Equatable { const WeatherBlocState(); @override List<Object> get props => []; } class WeatherInitial extends WeatherBlocState {} class WeatherBlocLoading extends WeatherBlocState {} class WeatherBlockFailure extends WeatherBlocState {} class WeatherBlocSuccess extends WeatherBlocState { final Weather weather; const WeatherBlocSuccess(this.weather); @override List<Object> get props => [weather]; }
0