add factory constructor

This commit is contained in:
Salvatore Giordano
2020-11-24 13:39:36 +01:00
parent 93c324ac56
commit 6b62eadaa4
22 changed files with 424 additions and 166 deletions
+2 -4
View File
@@ -33,10 +33,8 @@ class StreamBackButton extends StatelessWidget {
Navigator.of(context).pop();
}
},
child: StreamSvgIcon(
assetName: 'Icon_left.svg',
height: 24,
width: 24,
child: StreamSvgIcon.left(
size: 24,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
+4 -8
View File
@@ -72,10 +72,8 @@ class ChannelBottomSheet extends StatelessWidget {
initialData: channel.isMuted,
builder: (context, snapshot) {
return ListTile(
leading: StreamSvgIcon(
assetName: 'Icon_mute.svg',
height: 22,
width: 22,
leading: StreamSvgIcon.mute(
size: 22,
color: StreamChatTheme.of(context).primaryIconTheme.color,
),
title: Text('Mute ${channel.isGroup ? 'group' : 'user'}'),
@@ -94,10 +92,8 @@ class ChannelBottomSheet extends StatelessWidget {
Divider(),
if (channel.isGroup && !channel.isDistinct)
ListTile(
leading: StreamSvgIcon(
assetName: 'Icon_User_deselect.svg',
height: 22,
width: 22,
leading: StreamSvgIcon.userRemove(
size: 22,
color: Colors.black,
),
title: Text('Leave Group'),
+4 -10
View File
@@ -201,10 +201,8 @@ class _ChannelListViewState extends State<ChannelListView>
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: StreamSvgIcon(
assetName: 'Icon_message.svg',
height: 136,
width: 136,
child: StreamSvgIcon.message(
size: 136,
color: Color(0xffDBDBDB),
),
),
@@ -519,9 +517,7 @@ class _ChannelListViewState extends State<ChannelListView>
),
IconSlideAction(
color: backgroundColor,
iconWidget: StreamSvgIcon(
assetName: 'Icon_mute.svg',
),
iconWidget: StreamSvgIcon.mute(),
onTap: () async {
if (!channel.isMuted) {
await channel.mute();
@@ -533,9 +529,7 @@ class _ChannelListViewState extends State<ChannelListView>
if (channel.isGroup && !channel.isDistinct)
IconSlideAction(
color: backgroundColor,
iconWidget: StreamSvgIcon(
assetName: 'Icon_User_deselect.svg',
),
iconWidget: StreamSvgIcon.userRemove(),
onTap: () async {
final confirm = await showConfirmationDialog(
context,
+2 -4
View File
@@ -153,10 +153,8 @@ class ChannelPreview extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
StreamSvgIcon(
assetName: 'Icon_mute.svg',
height: 16,
width: 16,
StreamSvgIcon.mute(
size: 16,
),
Text(
' Channel is muted',
+10 -20
View File
@@ -112,11 +112,9 @@ class GiphyAttachment extends StatelessWidget {
),
child: Row(
children: [
StreamSvgIcon(
assetName: 'Icon_lightning-command runner.svg',
StreamSvgIcon.lightning(
color: StreamChatTheme.of(context).accentColor,
height: 16.0,
width: 16.0,
size: 16.0,
),
Text(
'GIPHY',
@@ -146,10 +144,8 @@ class GiphyAttachment extends StatelessWidget {
child: IconButton(
padding: const EdgeInsets.all(0),
constraints: BoxConstraints.tight(Size(32, 32)),
icon: StreamSvgIcon(
assetName: 'Icon_left.svg',
height: 24.0,
width: 24.0,
icon: StreamSvgIcon.left(
size: 24.0,
),
splashRadius: 16,
onPressed: () {
@@ -175,10 +171,8 @@ class GiphyAttachment extends StatelessWidget {
child: IconButton(
padding: const EdgeInsets.all(0),
constraints: BoxConstraints.tight(Size(32, 32)),
icon: StreamSvgIcon(
assetName: 'Icon_right.svg',
height: 24.0,
width: 24.0,
icon: StreamSvgIcon.right(
size: 24.0,
),
splashRadius: 16,
onPressed: () {
@@ -257,11 +251,9 @@ class GiphyAttachment extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
StreamSvgIcon(
assetName: 'Icon_eye-off.svg',
StreamSvgIcon.eye(
color: Colors.black.withOpacity(0.5),
height: 16.0,
width: 16.0,
size: 16.0,
),
SizedBox(
width: 8.0,
@@ -331,11 +323,9 @@ class GiphyAttachment extends StatelessWidget {
),
child: Row(
children: [
StreamSvgIcon(
assetName: 'Icon_lightning-command runner.svg',
StreamSvgIcon.lightning(
color: Colors.white,
height: 16,
width: 16,
size: 16,
),
Text(
'GIPHY',
+2 -4
View File
@@ -71,10 +71,8 @@ class _MediaListViewState extends State<MediaListView> {
child: CircleAvatar(
radius: 12,
backgroundColor: Colors.white,
child: StreamSvgIcon(
assetName: 'Icon_check.svg',
height: 24,
width: 24,
child: StreamSvgIcon.check(
size: 24,
color: Colors.black,
),
),
+6 -12
View File
@@ -188,8 +188,7 @@ class MessageActionsModal extends StatelessWidget {
style:
Theme.of(context).textTheme.headline6.copyWith(color: Colors.red),
),
leading: StreamSvgIcon(
assetName: 'Icon_delete.svg',
leading: StreamSvgIcon.delete(
color: Colors.red,
),
onTap: () {
@@ -208,8 +207,7 @@ class MessageActionsModal extends StatelessWidget {
'Copy message',
style: Theme.of(context).textTheme.headline6,
),
leading: StreamSvgIcon(
assetName: 'Icon_copy.svg',
leading: StreamSvgIcon.copy(
color: StreamChatTheme.of(context).primaryIconTheme.color,
),
onTap: () async {
@@ -225,8 +223,7 @@ class MessageActionsModal extends StatelessWidget {
'Edit message',
style: Theme.of(context).textTheme.headline6,
),
leading: StreamSvgIcon(
assetName: 'Icon_edit.svg',
leading: StreamSvgIcon.edit(
color: StreamChatTheme.of(context).primaryIconTheme.color,
),
onTap: () async {
@@ -267,10 +264,8 @@ class MessageActionsModal extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
icon: StreamSvgIcon(
assetName: 'Icon_edit.svg',
height: 22,
width: 22,
icon: StreamSvgIcon.edit(
size: 22,
color:
StreamChatTheme.of(context).primaryIconTheme.color,
),
@@ -324,8 +319,7 @@ class MessageActionsModal extends StatelessWidget {
'Thread reply',
style: Theme.of(context).textTheme.headline6,
),
leading: StreamSvgIcon(
assetName: 'Icon_Thread_Reply.svg',
leading: StreamSvgIcon.thread(
color: StreamChatTheme.of(context).primaryIconTheme.color,
),
onTap: () {
+21 -44
View File
@@ -284,10 +284,8 @@ class MessageInputState extends State<MessageInput> {
crossFadeState: _sendAsDm
? CrossFadeState.showFirst
: CrossFadeState.showSecond,
firstChild: StreamSvgIcon(
assetName: 'Icon_check.svg',
height: 16.0,
width: 16.0,
firstChild: StreamSvgIcon.check(
size: 16.0,
color: Colors.white,
),
secondChild: SizedBox(
@@ -331,8 +329,7 @@ class MessageInputState extends State<MessageInput> {
_actionsShrunk = false;
});
},
icon: StreamSvgIcon(
assetName: 'Icon_empty_circle_left.svg',
icon: StreamSvgIcon.emptyCircleLeft(
color: StreamChatTheme.of(context).accentColor,
),
),
@@ -404,8 +401,7 @@ class MessageInputState extends State<MessageInput> {
_chosenCommand?.name ?? "",
style: TextStyle(color: Colors.white),
),
avatar: StreamSvgIcon(
assetName: 'Icon_lightning-command runner.svg',
avatar: StreamSvgIcon.lightning(
color: Colors.white,
),
),
@@ -582,9 +578,7 @@ class MessageInputState extends State<MessageInput> {
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
),
child: StreamSvgIcon(
assetName:
'Icon_lightning-command runner.svg',
child: StreamSvgIcon.lightning(
color: StreamChatTheme.of(context)
.accentColor,
),
@@ -622,12 +616,9 @@ class MessageInputState extends State<MessageInput> {
trailing: CircleAvatar(
backgroundColor:
StreamChatTheme.of(context).accentColor,
child: StreamSvgIcon(
assetName:
'Icon_lightning-command runner.svg',
child: StreamSvgIcon.lightning(
color: Colors.white,
height: 12.5,
width: 12.5,
size: 12.5,
),
maxRadius: 12,
),
@@ -661,10 +652,8 @@ class MessageInputState extends State<MessageInput> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
icon: StreamSvgIcon(
assetName: 'pictures.svg',
height: 24,
width: 24,
icon: StreamSvgIcon.pictures(
size: 24,
color: _filePickerIndex == 0
? StreamChatTheme.of(context).accentColor
: Colors.black.withOpacity(0.5),
@@ -676,10 +665,8 @@ class MessageInputState extends State<MessageInput> {
},
),
IconButton(
icon: StreamSvgIcon(
assetName: 'files.svg',
height: 24,
width: 24,
icon: StreamSvgIcon.files(
size: 24,
color: _filePickerIndex == 1
? StreamChatTheme.of(context).accentColor
: Colors.black.withOpacity(0.5),
@@ -689,10 +676,8 @@ class MessageInputState extends State<MessageInput> {
},
),
IconButton(
icon: StreamSvgIcon(
assetName: 'Icon_camera.svg',
height: 24,
width: 24,
icon: StreamSvgIcon.camera(
size: 24,
color: _filePickerIndex == 2
? StreamChatTheme.of(context).accentColor
: Colors.black.withOpacity(0.5),
@@ -702,10 +687,8 @@ class MessageInputState extends State<MessageInput> {
},
),
IconButton(
icon: StreamSvgIcon(
assetName: 'Icon_record.svg',
height: 24,
width: 24,
icon: StreamSvgIcon.record(
size: 24,
color: _filePickerIndex == 3
? StreamChatTheme.of(context).accentColor
: Colors.black.withOpacity(0.5),
@@ -1000,8 +983,7 @@ class MessageInputState extends State<MessageInput> {
fontWeight: FontWeight.bold),
),
subtitle: Text('@${m.userId}'),
trailing: StreamSvgIcon(
assetName: 'mentions.svg',
trailing: StreamSvgIcon.mentions(
color: StreamChatTheme.of(context)
.accentColor,
),
@@ -1098,8 +1080,7 @@ class MessageInputState extends State<MessageInput> {
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8.0),
child: StreamSvgIcon(
assetName: 'Icon_smile.svg',
child: StreamSvgIcon.smile(
color: StreamChatTheme.of(context).accentColor,
),
),
@@ -1234,10 +1215,8 @@ class MessageInputState extends State<MessageInput> {
},
fillColor: Colors.black.withOpacity(.5),
child: Center(
child: StreamSvgIcon(
assetName: 'Icon_close.svg',
height: 24,
width: 24,
child: StreamSvgIcon.close(
size: 24,
color: Colors.white,
),
),
@@ -1307,8 +1286,7 @@ class MessageInputState extends State<MessageInput> {
child: Padding(
padding:
const EdgeInsets.only(left: 4.0, right: 8.0, top: 8.0, bottom: 8.0),
child: StreamSvgIcon(
assetName: 'Icon_lightning-command runner.svg',
child: StreamSvgIcon.lightning(
color: Color(0xFF000000).withAlpha(128),
),
),
@@ -1331,8 +1309,7 @@ class MessageInputState extends State<MessageInput> {
child: Padding(
padding:
EdgeInsets.only(left: 8.0, right: padding, top: 8.0, bottom: 8.0),
child: StreamSvgIcon(
assetName: 'Icon_attach.svg',
child: StreamSvgIcon.attach(
color: _openFilePickerSection
? StreamChatTheme.of(context).accentColor
: Color(0xFF000000).withAlpha(128),
+1 -2
View File
@@ -375,8 +375,7 @@ class _MessageListViewState extends State<MessageListView> {
children: [
FloatingActionButton(
backgroundColor: Colors.white,
child: StreamSvgIcon(
assetName: 'Icon_down.svg',
child: StreamSvgIcon.down(
color: Colors.black,
),
onPressed: () {
+336
View File
@@ -39,4 +39,340 @@ class StreamSvgIcon extends StatelessWidget {
alignment: Alignment.center,
);
}
factory StreamSvgIcon.settings({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'settings.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.down({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_down.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.attach({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_attach.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.smile({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_smile.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.mentions({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'mentions.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.record({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_record.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.camera({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_camera.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.files({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'files.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.pictures({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'pictures.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.left({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_left.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.user({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_user.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.userAdd({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_User_add.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.check({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_check.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.penWrite({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_pen-write.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.contacts({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_contacts.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.close({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_close.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.search({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_search.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.right({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_right.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.mute({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_mute.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.userRemove({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_User_deselect.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.lightning({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_lightning-command runner.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.emptyCircleLeft({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_empty_circle_left.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.message({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_message.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.thread({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_Thread_Reply.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.edit({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_edit.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.copy({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_copy.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.delete({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_delete.svg',
color: color,
width: size,
height: size,
);
}
factory StreamSvgIcon.eye({
double size,
Color color,
}) {
return StreamSvgIcon(
assetName: 'Icon_eye-off.svg',
color: color,
width: size,
height: size,
);
}
}
+2 -4
View File
@@ -86,10 +86,8 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
aspectRatio: 1,
child: IconButton(
onPressed: onBackPressed,
icon: StreamSvgIcon(
assetName: 'Icon_close.svg',
height: 24,
width: 24,
icon: StreamSvgIcon.close(
size: 24,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
+2 -4
View File
@@ -74,10 +74,8 @@ class UserItem extends StatelessWidget {
),
trailing: selected
? CircleAvatar(
child: StreamSvgIcon(
assetName: 'Icon_check.svg',
height: 20,
width: 20,
child: StreamSvgIcon.check(
size: 20,
),
radius: 10,
)