|
@@ -15,12 +15,17 @@ class SettingsUserView extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return BlocProvider<SettingsUserViewBloc>(
|
|
|
- create: (context) => getIt<SettingsUserViewBloc>(param1: user)..add(const SettingsUserEvent.initial()),
|
|
|
+ create: (context) => getIt<SettingsUserViewBloc>(param1: user)
|
|
|
+ ..add(const SettingsUserEvent.initial()),
|
|
|
child: BlocBuilder<SettingsUserViewBloc, SettingsUserState>(
|
|
|
builder: (context, state) => SingleChildScrollView(
|
|
|
child: Column(
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [_renderUserNameInput(context), const VSpace(20), _renderCurrentIcon(context)],
|
|
|
+ children: [
|
|
|
+ _renderUserNameInput(context),
|
|
|
+ const VSpace(20),
|
|
|
+ _renderCurrentIcon(context)
|
|
|
+ ],
|
|
|
),
|
|
|
),
|
|
|
),
|
|
@@ -33,8 +38,9 @@ class SettingsUserView extends StatelessWidget {
|
|
|
}
|
|
|
|
|
|
Widget _renderCurrentIcon(BuildContext context) {
|
|
|
- String icon = context.read<SettingsUserViewBloc>().state.userProfile.icon;
|
|
|
- return _CurrentIcon(icon);
|
|
|
+ String iconUrl =
|
|
|
+ context.read<SettingsUserViewBloc>().state.userProfile.iconUrl;
|
|
|
+ return _CurrentIcon(iconUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -53,19 +59,23 @@ class _UserNameInput extends StatelessWidget {
|
|
|
labelText: 'Name',
|
|
|
),
|
|
|
onSubmitted: (val) {
|
|
|
- context.read<SettingsUserViewBloc>().add(SettingsUserEvent.updateUserName(val));
|
|
|
+ context
|
|
|
+ .read<SettingsUserViewBloc>()
|
|
|
+ .add(SettingsUserEvent.updateUserName(val));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
class _CurrentIcon extends StatelessWidget {
|
|
|
- final String icon;
|
|
|
- const _CurrentIcon(this.icon, {Key? key}) : super(key: key);
|
|
|
+ final String iconUrl;
|
|
|
+ const _CurrentIcon(this.iconUrl, {Key? key}) : super(key: key);
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- _setIcon(String icon) {
|
|
|
- context.read<SettingsUserViewBloc>().add(SettingsUserEvent.updateUserIcon(icon));
|
|
|
+ _setIcon(String iconUrl) {
|
|
|
+ context
|
|
|
+ .read<SettingsUserViewBloc>()
|
|
|
+ .add(SettingsUserEvent.updateUserIcon(iconUrl));
|
|
|
Navigator.of(context).pop();
|
|
|
}
|
|
|
|
|
@@ -78,7 +88,10 @@ class _CurrentIcon extends StatelessWidget {
|
|
|
builder: (BuildContext context) {
|
|
|
return SimpleDialog(
|
|
|
title: const Text('Select an Icon'),
|
|
|
- children: <Widget>[SizedBox(height: 300, width: 300, child: IconGallery(_setIcon))]);
|
|
|
+ children: <Widget>[
|
|
|
+ SizedBox(
|
|
|
+ height: 300, width: 300, child: IconGallery(_setIcon))
|
|
|
+ ]);
|
|
|
},
|
|
|
);
|
|
|
},
|
|
@@ -93,8 +106,9 @@ class _CurrentIcon extends StatelessWidget {
|
|
|
alignment: Alignment.centerLeft,
|
|
|
child: Container(
|
|
|
margin: const EdgeInsets.all(5.0),
|
|
|
- decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
|
|
|
- child: svgWithSize('emoji/$icon', const Size(60, 60)),
|
|
|
+ decoration:
|
|
|
+ BoxDecoration(border: Border.all(color: Colors.grey)),
|
|
|
+ child: svgWithSize('emoji/$iconUrl', const Size(60, 60)),
|
|
|
)),
|
|
|
])),
|
|
|
);
|
|
@@ -106,16 +120,18 @@ class IconGallery extends StatelessWidget {
|
|
|
const IconGallery(this.setIcon, {Key? key}) : super(key: key);
|
|
|
|
|
|
Future<List<String>> _getIcons(BuildContext context) async {
|
|
|
- final manifestContent = await DefaultAssetBundle.of(context).loadString('AssetManifest.json');
|
|
|
+ final manifestContent =
|
|
|
+ await DefaultAssetBundle.of(context).loadString('AssetManifest.json');
|
|
|
|
|
|
final Map<String, dynamic> manifestMap = json.decode(manifestContent);
|
|
|
|
|
|
- final icons = manifestMap.keys
|
|
|
- .where((String key) => key.startsWith('assets/images/emoji/') && key.endsWith('.svg'))
|
|
|
+ final iconUrls = manifestMap.keys
|
|
|
+ .where((String key) =>
|
|
|
+ key.startsWith('assets/images/emoji/') && key.endsWith('.svg'))
|
|
|
.map((String key) => key.split('/').last.split('.').first)
|
|
|
.toList();
|
|
|
|
|
|
- return icons;
|
|
|
+ return iconUrls;
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -127,8 +143,8 @@ class IconGallery extends StatelessWidget {
|
|
|
return GridView.count(
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
crossAxisCount: 5,
|
|
|
- children: (snapshot.data ?? []).map((String icon) {
|
|
|
- return IconOption(icon, setIcon);
|
|
|
+ children: (snapshot.data ?? []).map((String iconUrl) {
|
|
|
+ return IconOption(iconUrl, setIcon);
|
|
|
}).toList(),
|
|
|
);
|
|
|
} else {
|
|
@@ -142,10 +158,11 @@ class IconGallery extends StatelessWidget {
|
|
|
}
|
|
|
|
|
|
class IconOption extends StatelessWidget {
|
|
|
- final String icon;
|
|
|
+ final String iconUrl;
|
|
|
final Function setIcon;
|
|
|
|
|
|
- IconOption(this.icon, this.setIcon, {Key? key}) : super(key: ValueKey(icon));
|
|
|
+ IconOption(this.iconUrl, this.setIcon, {Key? key})
|
|
|
+ : super(key: ValueKey(iconUrl));
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
@@ -153,9 +170,9 @@ class IconOption extends StatelessWidget {
|
|
|
color: Colors.transparent,
|
|
|
child: GestureDetector(
|
|
|
onTap: () {
|
|
|
- setIcon(icon);
|
|
|
+ setIcon(iconUrl);
|
|
|
},
|
|
|
- child: svgWidget('emoji/$icon'),
|
|
|
+ child: svgWidget('emoji/$iconUrl'),
|
|
|
),
|
|
|
);
|
|
|
}
|