mirror of
https://github.com/rainloreley/shlink-manager.git
synced 2024-11-23 10:13:03 +01:00
a bit of refactoring
This commit is contained in:
parent
4f8cc9e4b6
commit
202ab20747
|
@ -33,7 +33,7 @@ class GlobalTheme {
|
||||||
return ColorScheme(
|
return ColorScheme(
|
||||||
primary: Color(0xff747ab5),
|
primary: Color(0xff747ab5),
|
||||||
onPrimary: Colors.white,
|
onPrimary: Colors.white,
|
||||||
secondary: Color(0x445d63a6),// Color(0xFFDDE0E0),
|
secondary: Color(0x335d63a6),// Color(0xFFDDE0E0),
|
||||||
onSecondary: Color(0xFF322942),
|
onSecondary: Color(0xFF322942),
|
||||||
tertiary: Colors.grey[300],
|
tertiary: Colors.grey[300],
|
||||||
onTertiary: Colors.grey[700],
|
onTertiary: Colors.grey[700],
|
||||||
|
@ -44,7 +44,7 @@ class GlobalTheme {
|
||||||
surface: Color(0xFFFAFBFB),
|
surface: Color(0xFFFAFBFB),
|
||||||
onSurface: Color(0xFF241E30),
|
onSurface: Color(0xFF241E30),
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
).harmonized();
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ColorScheme get darkColorScheme {
|
static ColorScheme get darkColorScheme {
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shlink_app/API/server_manager.dart';
|
||||||
|
|
||||||
|
SnackBar buildApiErrorSnackbar(Failure r, BuildContext context) {
|
||||||
|
var text = "";
|
||||||
|
|
||||||
|
if (r is RequestFailure) {
|
||||||
|
text = r.description;
|
||||||
|
} else {
|
||||||
|
text = (r as ApiFailure).detail;
|
||||||
|
if ((r).invalidElements != null) {
|
||||||
|
text = "$text: ${(r).invalidElements}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final snackBar = SnackBar(
|
||||||
|
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.error,
|
||||||
|
behavior: SnackBarBehavior.floating);
|
||||||
|
|
||||||
|
return snackBar;
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import 'package:flutter_sharing_intent/flutter_sharing_intent.dart';
|
||||||
import 'package:flutter_sharing_intent/model/sharing_file.dart';
|
import 'package:flutter_sharing_intent/model/sharing_file.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShlinkStats/shlink_stats.dart';
|
import 'package:shlink_app/API/Classes/ShlinkStats/shlink_stats.dart';
|
||||||
import 'package:shlink_app/API/server_manager.dart';
|
import 'package:shlink_app/util/build_api_error_snackbar.dart';
|
||||||
import 'package:shlink_app/views/short_url_edit_view.dart';
|
import 'package:shlink_app/views/short_url_edit_view.dart';
|
||||||
import 'package:shlink_app/views/url_list_view.dart';
|
import 'package:shlink_app/views/url_list_view.dart';
|
||||||
import 'package:shlink_app/widgets/available_servers_bottom_sheet.dart';
|
import 'package:shlink_app/widgets/available_servers_bottom_sheet.dart';
|
||||||
|
@ -68,18 +68,9 @@ class _HomeViewState extends State<HomeView> {
|
||||||
shlinkStats = l;
|
shlinkStats = l;
|
||||||
});
|
});
|
||||||
}, (r) {
|
}, (r) {
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
if (r is RequestFailure) {
|
buildApiErrorSnackbar(r, context)
|
||||||
text = r.description;
|
);
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,18 +82,9 @@ class _HomeViewState extends State<HomeView> {
|
||||||
shortUrlsLoaded = true;
|
shortUrlsLoaded = true;
|
||||||
});
|
});
|
||||||
}, (r) {
|
}, (r) {
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
if (r is RequestFailure) {
|
buildApiErrorSnackbar(r, context)
|
||||||
text = r.description;
|
);
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'package:shlink_app/API/Classes/ShortURL/RedirectRule/condition_device_ty
|
||||||
import 'package:shlink_app/API/Classes/ShortURL/RedirectRule/redirect_rule_condition.dart';
|
import 'package:shlink_app/API/Classes/ShortURL/RedirectRule/redirect_rule_condition.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShortURL/RedirectRule/redirect_rule_condition_type.dart';
|
import 'package:shlink_app/API/Classes/ShortURL/RedirectRule/redirect_rule_condition_type.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
||||||
import 'package:shlink_app/API/server_manager.dart';
|
import 'package:shlink_app/util/build_api_error_snackbar.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
import '../API/Classes/ShortURL/RedirectRule/redirect_rule.dart';
|
import '../API/Classes/ShortURL/RedirectRule/redirect_rule.dart';
|
||||||
|
|
||||||
|
@ -41,18 +41,9 @@ class _RedirectRulesDetailViewState extends State<RedirectRulesDetailView> {
|
||||||
_sortListByPriority();
|
_sortListByPriority();
|
||||||
return true;
|
return true;
|
||||||
}, (r) {
|
}, (r) {
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
if (r is RequestFailure) {
|
buildApiErrorSnackbar(r, context)
|
||||||
text = r.description;
|
);
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -63,18 +54,9 @@ class _RedirectRulesDetailViewState extends State<RedirectRulesDetailView> {
|
||||||
response.fold((l) {
|
response.fold((l) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}, (r) {
|
}, (r) {
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
if (r is RequestFailure) {
|
buildApiErrorSnackbar(r, context)
|
||||||
text = r.description;
|
);
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:shlink_app/API/server_manager.dart';
|
import 'package:shlink_app/util/build_api_error_snackbar.dart';
|
||||||
import 'package:shlink_app/views/opensource_licenses_view.dart';
|
import 'package:shlink_app/views/opensource_licenses_view.dart';
|
||||||
import 'package:shlink_app/widgets/available_servers_bottom_sheet.dart';
|
import 'package:shlink_app/widgets/available_servers_bottom_sheet.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
@ -43,19 +43,9 @@ class _SettingsViewState extends State<SettingsView> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_serverStatus = ServerStatus.disconnected;
|
_serverStatus = ServerStatus.disconnected;
|
||||||
});
|
});
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
var text = "";
|
buildApiErrorSnackbar(r, context)
|
||||||
if (r is RequestFailure) {
|
);
|
||||||
text = r.description;
|
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShortURLSubmission/short_url_submission.dart';
|
import 'package:shlink_app/API/Classes/ShortURLSubmission/short_url_submission.dart';
|
||||||
import 'package:shlink_app/API/server_manager.dart';
|
import 'package:shlink_app/API/server_manager.dart';
|
||||||
|
import 'package:shlink_app/util/build_api_error_snackbar.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
|
|
||||||
class ShortURLEditView extends StatefulWidget {
|
class ShortURLEditView extends StatefulWidget {
|
||||||
|
@ -72,6 +73,34 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _saveButtonPressed() {
|
||||||
|
if (!isSaving) {
|
||||||
|
setState(() {
|
||||||
|
isSaving = true;
|
||||||
|
longUrlError = "";
|
||||||
|
randomSlugLengthError = "";
|
||||||
|
});
|
||||||
|
if (longUrlController.text == "") {
|
||||||
|
setState(() {
|
||||||
|
longUrlError = "URL cannot be empty";
|
||||||
|
isSaving = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else if (int.tryParse(randomSlugLengthController.text) ==
|
||||||
|
null ||
|
||||||
|
int.tryParse(randomSlugLengthController.text)! < 1 ||
|
||||||
|
int.tryParse(randomSlugLengthController.text)! > 50) {
|
||||||
|
setState(() {
|
||||||
|
randomSlugLengthError = "invalid number";
|
||||||
|
isSaving = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_submitShortUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _submitShortUrl() async {
|
void _submitShortUrl() async {
|
||||||
var newSubmission = ShortURLSubmission(
|
var newSubmission = ShortURLSubmission(
|
||||||
longUrl: longUrlController.text,
|
longUrl: longUrlController.text,
|
||||||
|
@ -119,22 +148,9 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
isSaving = false;
|
isSaving = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
buildApiErrorSnackbar(r, context)
|
||||||
if (r is RequestFailure) {
|
);
|
||||||
text = r.description;
|
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
if ((r).invalidElements != null) {
|
|
||||||
text = "$text: ${(r).invalidElements}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -150,8 +166,9 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
|
padding: EdgeInsets.only(top: 16, left: 8, right: 8),
|
||||||
child: Column(
|
child: Wrap(
|
||||||
|
runSpacing: 16,
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
controller: longUrlController,
|
controller: longUrlController,
|
||||||
|
@ -166,7 +183,6 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -228,7 +244,6 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (randomSlug) const SizedBox(height: 16),
|
|
||||||
if (randomSlug)
|
if (randomSlug)
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
@ -253,7 +268,6 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: titleController,
|
controller: titleController,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
|
@ -266,7 +280,6 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -281,7 +294,6 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -296,7 +308,6 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -313,36 +324,13 @@ class _ShortURLEditViewState extends State<ShortURLEditView>
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (!isSaving) {
|
_saveButtonPressed();
|
||||||
setState(() {
|
|
||||||
isSaving = true;
|
|
||||||
longUrlError = "";
|
|
||||||
randomSlugLengthError = "";
|
|
||||||
});
|
|
||||||
if (longUrlController.text == "") {
|
|
||||||
setState(() {
|
|
||||||
longUrlError = "URL cannot be empty";
|
|
||||||
isSaving = false;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
} else if (int.tryParse(randomSlugLengthController.text) ==
|
|
||||||
null ||
|
|
||||||
int.tryParse(randomSlugLengthController.text)! < 1 ||
|
|
||||||
int.tryParse(randomSlugLengthController.text)! > 50) {
|
|
||||||
setState(() {
|
|
||||||
randomSlugLengthError = "invalid number";
|
|
||||||
isSaving = false;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
_submitShortUrl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: isSaving
|
child: isSaving
|
||||||
? const Padding(
|
? const Padding(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:shlink_app/API/server_manager.dart';
|
import 'package:shlink_app/util/build_api_error_snackbar.dart';
|
||||||
import 'package:shlink_app/views/redirect_rules_detail_view.dart';
|
import 'package:shlink_app/views/redirect_rules_detail_view.dart';
|
||||||
import 'package:shlink_app/views/short_url_edit_view.dart';
|
import 'package:shlink_app/views/short_url_edit_view.dart';
|
||||||
import 'package:shlink_app/widgets/url_tags_list_widget.dart';
|
import 'package:shlink_app/widgets/url_tags_list_widget.dart';
|
||||||
|
@ -67,18 +67,9 @@ class _URLDetailViewState extends State<URLDetailView> {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
return true;
|
return true;
|
||||||
}, (r) {
|
}, (r) {
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
if (r is RequestFailure) {
|
buildApiErrorSnackbar(r, context)
|
||||||
text = r.description;
|
);
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text, style: TextStyle(color: Theme.of(context).colorScheme.onError)),
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.error,
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
import 'package:shlink_app/API/Classes/ShortURL/short_url.dart';
|
||||||
import 'package:shlink_app/API/server_manager.dart';
|
import 'package:shlink_app/util/build_api_error_snackbar.dart';
|
||||||
import 'package:shlink_app/views/short_url_edit_view.dart';
|
import 'package:shlink_app/views/short_url_edit_view.dart';
|
||||||
import 'package:shlink_app/views/url_detail_view.dart';
|
import 'package:shlink_app/views/url_detail_view.dart';
|
||||||
import 'package:shlink_app/widgets/url_tags_list_widget.dart';
|
import 'package:shlink_app/widgets/url_tags_list_widget.dart';
|
||||||
|
@ -38,18 +38,9 @@ class _URLListViewState extends State<URLListView> {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}, (r) {
|
}, (r) {
|
||||||
var text = "";
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
if (r is RequestFailure) {
|
buildApiErrorSnackbar(r, context)
|
||||||
text = r.description;
|
);
|
||||||
} else {
|
|
||||||
text = (r as ApiFailure).detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(text),
|
|
||||||
backgroundColor: Colors.red[400],
|
|
||||||
behavior: SnackBarBehavior.floating);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user