-
Notifications
You must be signed in to change notification settings - Fork 42
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
23 changed files
with
747 additions
and
83 deletions.
There are no files selected for viewing
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
Binary file added
BIN
+7.34 MB
github/gifs/circle_avatar_image_and_alphabet/circle_avatar_image_and_alphabet.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
7 changes: 7 additions & 0 deletions
7
lib/atomic/rating_bar/extension/rating_bar_icon_extension.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
enum RatingBarIcon { star, heart } | ||
|
||
extension RatingBarIconExtension on RatingBarIcon { | ||
Icon get icon => Icon(index == 0 ? Icons.star : Icons.favorite); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:ready_to_use_widgets/atomic/rating_bar/extension/rating_bar_icon_extension.dart'; | ||
|
||
class RatingBar extends StatefulWidget { | ||
const RatingBar({ | ||
Key? key, | ||
required this.onPressed, | ||
this.ratingBarIcon = RatingBarIcon.star, | ||
this.iconSize = 70.0, | ||
this.initialValue = 1, | ||
this.direction = Axis.horizontal, | ||
this.progressColor = const Color(0xFFFFBF00), | ||
this.backgroundColor = const Color(0xFFC5C5C5), | ||
}) : assert(initialValue >= 0 && initialValue <= 5), | ||
super(key: key); | ||
|
||
final void Function(int index) onPressed; | ||
final RatingBarIcon ratingBarIcon; | ||
final int initialValue; | ||
final Color progressColor; | ||
final Axis direction; | ||
final double iconSize; | ||
final Color backgroundColor; | ||
|
||
@override | ||
State<RatingBar> createState() => _RatingBarState(); | ||
} | ||
|
||
class _RatingBarState extends State<RatingBar> { | ||
final int size = 5; | ||
late ValueNotifier<int> selectedRate; | ||
|
||
@override | ||
void initState() { | ||
selectedRate = ValueNotifier(widget.initialValue); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListView.builder( | ||
itemCount: size, | ||
shrinkWrap: true, | ||
physics: const NeverScrollableScrollPhysics(), | ||
scrollDirection: widget.direction, | ||
itemBuilder: (context, index) => ValueListenableBuilder( | ||
valueListenable: selectedRate, | ||
builder: (_, __, ___) => _iconButton(index), | ||
), | ||
); | ||
} | ||
|
||
IconButton _iconButton(int index) => IconButton( | ||
icon: widget.ratingBarIcon.icon, | ||
iconSize: widget.iconSize, | ||
onPressed: () { | ||
selectedRate.value = index + 1; | ||
widget.onPressed.call(selectedRate.value); | ||
}, | ||
color: index + 1 <= selectedRate.value | ||
? widget.progressColor | ||
: widget.backgroundColor, | ||
); | ||
} |
File renamed without changes.
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
59 changes: 59 additions & 0 deletions
59
lib/feature/circle_avatar_image_and_alphabet/circle_avatar_image_and_alphabet.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:auto_size_text/auto_size_text.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:kartal/kartal.dart'; | ||
|
||
class CircleAvatarImageAndAlphabet extends StatelessWidget { | ||
final Function()? onTap; | ||
final String? imagePath; | ||
final String? text; | ||
final int? color; | ||
final bool isFullText; | ||
final double radius; | ||
|
||
const CircleAvatarImageAndAlphabet({Key? key, this.onTap, required this.radius, this.text, this.imagePath, this.color, this.isFullText = false}) | ||
: super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: onTap, | ||
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ | ||
CircleAvatar( | ||
backgroundImage: imagePath == null ? null : FileImage(File(imagePath!)), | ||
radius: radius, | ||
child: imagePath == null | ||
? Padding( | ||
padding: context.paddingLow, | ||
child: AutoSizeText( | ||
text != null ? getTextFirsCharter(text!) : " ", | ||
style: Theme.of(context).textTheme.headline3, | ||
textAlign: TextAlign.center, | ||
maxLines: 2, | ||
), | ||
) | ||
: null, | ||
backgroundColor: color != null ? Color(color!) : null), | ||
]), | ||
); | ||
} | ||
|
||
String getTextFirsCharter(String text) { | ||
String value = ""; | ||
var splitTextList = text.split(" "); | ||
|
||
if (isFullText) { | ||
return text.toUpperCase(); | ||
} else { | ||
for (var element in splitTextList) { | ||
if (element.isNotNullOrNoEmpty) { | ||
value = value + element[0]; | ||
} | ||
} | ||
|
||
return value.toUpperCase(); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...rcle_avatar_image_and_alphabet_example/circle_avatar_image_and_alphabet_example_view.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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:ready_to_use_widgets/feature/circle_avatar_image_and_alphabet/circle_avatar_image_and_alphabet.dart'; | ||
import 'package:kartal/kartal.dart'; | ||
import '../../../atomic/text_field/custom_text_field.dart'; | ||
import 'circle_avatar_image_and_alphabet_example_view_model.dart'; | ||
|
||
class CircleAvatarImageAndAlphabetExampleView extends StatelessWidget { | ||
const CircleAvatarImageAndAlphabetExampleView({Key? key, required this.viewModel}) : super(key: key); | ||
|
||
final CircleAvatarImageAndAlphabetExampleViewModel viewModel; | ||
@override | ||
Widget build(BuildContext context) { | ||
return ChangeNotifierProvider( | ||
create: (context) => viewModel, | ||
builder: (context, child) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
centerTitle: true, | ||
title: const Text("Circle Avatar Image And Alphabet"), | ||
), | ||
body: SingleChildScrollView( | ||
child: Padding( | ||
padding: context.paddingMedium, | ||
child: Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
IconButton( | ||
onPressed: () { | ||
viewModel.getImage(false); | ||
}, | ||
icon: const Icon(Icons.add_a_photo_outlined)), | ||
Consumer<CircleAvatarImageAndAlphabetExampleViewModel>( | ||
builder: (context, value, child) { | ||
return CircleAvatarImageAndAlphabet( | ||
color: viewModel.color, | ||
imagePath: viewModel.image == null ? null : viewModel.image!.path, | ||
radius: context.width * 0.2, | ||
text: viewModel.controllerAdi.text + " " + viewModel.controllerSoyadi.text, | ||
onTap: () { | ||
viewModel.selectedColor(context); | ||
}, | ||
); | ||
}, | ||
), | ||
IconButton( | ||
onPressed: () { | ||
viewModel.getImage(true); | ||
}, | ||
icon: const Icon(Icons.file_upload)) | ||
], | ||
), | ||
Padding( | ||
padding: context.verticalPaddingLow, | ||
child: CustomTextField( | ||
controller: viewModel.controllerAdi, | ||
labelText: "Adı", | ||
)), | ||
Padding( | ||
padding: context.verticalPaddingLow, | ||
child: CustomTextField( | ||
controller: viewModel.controllerSoyadi, | ||
labelText: "Soyadi", | ||
)), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
} |
Oops, something went wrong.