Skip to content

Commit

Permalink
Merge pull request #23 from Usta66/master
Browse files Browse the repository at this point in the history
  • Loading branch information
VB10 committed Sep 24, 2022
2 parents ce59609 + c8be62e commit 535658f
Show file tree
Hide file tree
Showing 19 changed files with 660 additions and 84 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"workbench.colorCustomizations": {
"titleBar.activeBackground": "#21481E",
"titleBar.activeForeground": "#F7FBF7"
}
},
"cmake.sourceDirectory": "${workspaceFolder}/windows"
}
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,29 @@
| Name | Readme |
| ------------------------ | --------------------------------------------------------------------------------------------------------- |
| Bottom List Picker | [Readme](lib/feature/bottomlistpicker/readme.md) |
[Gif](github/gifs/bottomlistpicker/bottom_list_picker.gif)
[Gif](github/gifs/bottomlistpicker/bottom_list_picker.gif)
| Bottom List Picker | [Readme](github/gifs/bottomlistpicker/bottom_list_picker.gif) |


# Circle Avatar Image And Alphabet



<table>
<tr>
<td> Circle Avatar Image And Alphabet </td>
</tr>

<tr>
<td><img src="github/gifs/circle_avatar_image_and_alphabet/circle_avatar_image_and_alphabet.gif" width=270 height=480></td>
</tr>

</table>
[Readme](lib/feature/circle_avatar_image_and_alphabet/readme.md)




# Rating Bar

Expand Down
5 changes: 5 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions lib/atomic/datetime/hour_selector/hour_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
import '../../../feature/dropdown/searchable_dropdown_with_paginated_request/searchable_dropdown_with_paginated_request.dart';

extension CustomTimeOfDayExtension on TimeOfDay {
Duration substract(TimeOfDay timeOfDay) =>
Duration(hours: hour, minutes: minute) - Duration(hours: timeOfDay.hour, minutes: timeOfDay.minute);
Duration substract(TimeOfDay timeOfDay) => Duration(hours: hour, minutes: minute) - Duration(hours: timeOfDay.hour, minutes: timeOfDay.minute);

TimeOfDay addMinutes(int minutes) {
if (minutes == 0) return this;
Expand All @@ -19,6 +18,7 @@ extension CustomTimeOfDayExtension on TimeOfDay {
String toStringFormat() => (hour < 10 ? '0' : '') + '$hour:' + (minute < 10 ? '0' : '') + '$minute';
}

// ignore: todo
//TODO bu widgeta disabled hours özelliği de kazandırılabilir. Verilen saatler kırmızı gelir ve seçilemez.

// ignore: must_be_immutable
Expand Down Expand Up @@ -160,8 +160,7 @@ class SelectableHourWidget extends StatelessWidget {
final TimeOfDay time;
final SelectableHourStatus selectableHourStatus;
final Function(TimeOfDay time) onTap;
const SelectableHourWidget({Key? key, required this.time, required this.selectableHourStatus, required this.onTap})
: super(key: key);
const SelectableHourWidget({Key? key, required this.time, required this.selectableHourStatus, required this.onTap}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand Down
17 changes: 9 additions & 8 deletions lib/feature/bottomlistpicker/example/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ class User extends INetworkModel {
website = json['website'];
}

@override
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['username'] = this.username;
data['email'] = this.email;

data['phone'] = this.phone;
data['website'] = this.website;
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['username'] = username;
data['email'] = email;

data['phone'] = phone;
data['website'] = website;

return data;
}
Expand Down
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();
}
}
}
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",
)),
],
),
),
),
),
);
},
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';

class CircleAvatarImageAndAlphabetExampleViewModel extends ChangeNotifier {
final picker = ImagePicker();
File? image;
int color = 0xFFFF9000;

set changeColor(int color) {
color = color;
notifyListeners();
}

late TextEditingController controllerAdi, controllerSoyadi;
CircleAvatarImageAndAlphabetExampleViewModel() {
controllerAdi = TextEditingController()
..addListener(() {
notifyListeners();
});

controllerSoyadi = TextEditingController()
..addListener(() {
notifyListeners();
});
}

getImage(bool issourceGallery) async {
final pickedFile = await picker.pickImage(source: issourceGallery ? ImageSource.gallery : ImageSource.camera);

if (pickedFile != null) {
image = File(pickedFile.path);

image = await _cropImage(image);
}

notifyListeners();
}

Future<File?>? _cropImage(File? image) async {
if (image != null) {
var croppedFile = await ImageCropper.platform.cropImage(sourcePath: image.path, aspectRatioPresets: [
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.original,
CropAspectRatioPreset.ratio4x3,
CropAspectRatioPreset.ratio16x9
], uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper',
toolbarColor: Colors.deepOrange,
toolbarWidgetColor: Colors.white,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false),
IOSUiSettings(
title: 'Cropper',
)
]);

if (croppedFile != null) {
return File(croppedFile.path);
} else {
return null;
}
} else {
return null;
}
}

void selectedColor(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: SingleChildScrollView(
child: MaterialPicker(
pickerColor: Colors.deepOrange,
onColorChanged: (secilenRenk) {
color = secilenRenk.value;

image = null;

notifyListeners();

Navigator.pop(context);
},
),
),
);
});
}
}
7 changes: 7 additions & 0 deletions lib/feature/circle_avatar_image_and_alphabet/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


Bu widget'a image path verdiğiniz zaman verilen image gösterir.
Image path null ise verilen tetx'in baş haflerini veya tamamını
avatarın içine yazdırabilirsiniz.

[Gif](github/gifs/circle_avatar_image_and_alphabet/circle_avatar_image_and_alphabet.gif)

0 comments on commit 535658f

Please sign in to comment.