-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
2,013 additions
and
71 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 139 additions & 21 deletions
160
...features/dashboard_features/analytics/presentation/widgets/all_expense_dialog_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,154 @@ | ||
import 'package:carlog/core/extensions/styles_extenstion.dart'; | ||
import 'package:carlog/features/dashboard_features/analytics/domain/entities/car_expense_entity.dart'; | ||
import 'package:carlog/features/dashboard_features/analytics/domain/entities/car_expense_enum.dart'; | ||
import 'package:carlog/features/dashboard_features/analytics/presentation/bloc/analytics_bloc.dart'; | ||
import 'package:carlog/features/dashboard_features/analytics/presentation/widgets/expense_card_widget.dart'; | ||
import 'package:carlog/features/other_features/user_app/presentation/bloc/user_app_bloc.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
Future<void> allExpenseModal(BuildContext appContext) { | ||
return showModalBottomSheet( | ||
showDragHandle: true, | ||
useRootNavigator: true, | ||
backgroundColor: appContext.surfaceColor, | ||
isScrollControlled: true, | ||
useSafeArea: true, | ||
context: appContext, | ||
builder: (context) => GestureDetector( | ||
onTap: () => FocusScope.of(context).unfocus(), | ||
child: SizedBox( | ||
width: double.infinity, | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.only(bottom: 10, top: 4), | ||
child: Container( | ||
width: 40, | ||
height: 5, | ||
decoration: BoxDecoration( | ||
color: context.primaryColor, | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
constraints: | ||
BoxConstraints(maxHeight: MediaQuery.of(appContext).size.height * 0.85), | ||
builder: (context) => MultiBlocProvider( | ||
providers: [ | ||
BlocProvider.value( | ||
value: appContext.read<AnalyticsBloc>(), | ||
), | ||
BlocProvider.value( | ||
value: appContext.read<UserAppBloc>(), | ||
), | ||
], | ||
child: const AllExpenseDialogWidget(), | ||
), | ||
); | ||
} | ||
|
||
class AllExpenseDialogWidget extends StatefulWidget { | ||
const AllExpenseDialogWidget({ | ||
super.key, | ||
}); | ||
|
||
@override | ||
State<AllExpenseDialogWidget> createState() => _AllExpenseDialogWidgetState(); | ||
} | ||
|
||
class _AllExpenseDialogWidgetState extends State<AllExpenseDialogWidget> { | ||
final List<CarExpenseEnum> carExpensesType = [ | ||
CarExpenseEnum.all, | ||
CarExpenseEnum.insuranceFee, | ||
CarExpenseEnum.serviceFee, | ||
CarExpenseEnum.roadFee, | ||
CarExpenseEnum.carWash, | ||
CarExpenseEnum.parkingFee, | ||
CarExpenseEnum.tires, | ||
CarExpenseEnum.tuning, | ||
CarExpenseEnum.other, | ||
]; | ||
CarExpenseEnum selectedCarExpenseType = CarExpenseEnum.all; | ||
|
||
List<Widget> carExpensesTiles(List<CarExpenseEntity> data) { | ||
final filteredData = data | ||
.where((e) => selectedCarExpenseType != CarExpenseEnum.all | ||
? e.expense == selectedCarExpenseType | ||
: true) | ||
.map((e) => ExpenseCardWidget( | ||
carExpenseEntity: e, | ||
)) | ||
.toList(); | ||
|
||
if (filteredData.isEmpty) { | ||
return [ | ||
const Center( | ||
child: Text("There are no expenses that we can show"), | ||
) | ||
]; | ||
} else { | ||
return filteredData; | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: double.infinity, | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.only(bottom: 20), | ||
child: SizedBox( | ||
height: 40, | ||
child: ListView( | ||
scrollDirection: Axis.horizontal, | ||
// itemExtent: 150, | ||
children: carExpensesType | ||
.map( | ||
(e) => Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 8), | ||
child: Container( | ||
clipBehavior: Clip.hardEdge, | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
color: context.primaryContainer, | ||
width: 2, | ||
), | ||
borderRadius: BorderRadius.circular(20), | ||
color: selectedCarExpenseType == e | ||
? context.primaryContainer | ||
: null, | ||
), | ||
child: GestureDetector( | ||
onTap: () { | ||
if (selectedCarExpenseType != e) { | ||
setState(() { | ||
selectedCarExpenseType = e; | ||
}); | ||
} | ||
}, | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Text( | ||
CarExpenseExtension.getCustomName(e), | ||
textAlign: TextAlign.center, | ||
style: TextStyle( | ||
fontWeight: selectedCarExpenseType == e | ||
? FontWeight.bold | ||
: null), | ||
), | ||
), | ||
), | ||
), | ||
), | ||
) | ||
.toList(), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
BlocBuilder<AnalyticsBloc, AnalyticsState>( | ||
builder: (context, state) { | ||
return state.maybeWhen( | ||
orElse: () => const SizedBox(), | ||
data: (data) => Expanded( | ||
child: ListView( | ||
physics: const ClampingScrollPhysics(), | ||
children: carExpensesTiles(data), | ||
), | ||
), | ||
); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
); | ||
} | ||
} |
Oops, something went wrong.