-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Join space with invitation code (#13)
* temp * join space with invitation code and get invitation of selected space * live data streaming * remove unwanted code * stream member live data * temp * revert stream * manage selection with id * add snack bar error and show selected id always at 1st index * show congratulation prompt on joining space
- Loading branch information
1 parent
dc2f32d
commit 50d4a1b
Showing
20 changed files
with
1,080 additions
and
238 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:style/extenstions/context_extenstions.dart'; | ||
import 'package:yourspace_flutter/domain/extenstions/context_extenstions.dart'; | ||
|
||
|
||
Future<void> showConfirmation( | ||
BuildContext context, { | ||
String? title, | ||
String? message, | ||
String? confirmBtnText, | ||
required VoidCallback onConfirm, | ||
bool isDestructiveAction = true, | ||
String? cancelButtonText, | ||
VoidCallback? onCancel, | ||
}) { | ||
HapticFeedback.mediumImpact(); | ||
return showAdaptiveDialog( | ||
context: context, | ||
builder: (context) { | ||
return AlertDialog.adaptive( | ||
surfaceTintColor: context.colorScheme.containerNormalOnSurface, | ||
title: (title != null) ? Text(title) : null, | ||
content: Text(message ?? context.l10n.alert_confirm_default_title), | ||
actions: [ | ||
adaptiveAction( | ||
context: context, | ||
onPressed: () async { | ||
context.pop(); | ||
onCancel?.call(); | ||
}, | ||
child: Text(cancelButtonText ?? context.l10n.common_cancel), | ||
), | ||
adaptiveAction( | ||
context: context, | ||
isDestructiveAction: isDestructiveAction, | ||
onPressed: () async { | ||
context.pop(); | ||
onConfirm(); | ||
}, | ||
child: Text( | ||
confirmBtnText ?? context.l10n.common_yes, | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
|
||
Future<void> showOkayConfirmation( | ||
BuildContext context, { | ||
required String title, | ||
required String message, | ||
bool isDestructiveAction = true, | ||
VoidCallback? onOkay, | ||
}) { | ||
HapticFeedback.mediumImpact(); | ||
return showAdaptiveDialog( | ||
context: context, | ||
builder: (context) { | ||
return AlertDialog.adaptive( | ||
surfaceTintColor: context.colorScheme.containerNormalOnSurface, | ||
title: Text(title), | ||
content: Text(message), | ||
actions: [ | ||
adaptiveAction( | ||
context: context, | ||
onPressed: () async { | ||
context.pop(); | ||
onOkay?.call(); | ||
}, | ||
child: Text(context.l10n.common_okay), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
|
||
Widget adaptiveAction({ | ||
required BuildContext context, | ||
required VoidCallback onPressed, | ||
required Widget child, | ||
bool isDestructiveAction = false, | ||
}) { | ||
final ThemeData theme = Theme.of(context); | ||
switch (theme.platform) { | ||
case TargetPlatform.android: | ||
case TargetPlatform.fuchsia: | ||
case TargetPlatform.linux: | ||
case TargetPlatform.windows: | ||
return TextButton( | ||
onPressed: onPressed, | ||
child: DefaultTextStyle( | ||
style: TextStyle( | ||
inherit: true, | ||
color: isDestructiveAction | ||
? context.colorScheme.alert | ||
: context.colorScheme.textSecondary, | ||
), | ||
child: child, | ||
), | ||
); | ||
case TargetPlatform.iOS: | ||
case TargetPlatform.macOS: | ||
return CupertinoDialogAction( | ||
onPressed: onPressed, | ||
isDestructiveAction: isDestructiveAction, | ||
textStyle: isDestructiveAction | ||
? null | ||
: TextStyle( | ||
color: isDestructiveAction | ||
? context.colorScheme.textPrimary | ||
: context.colorScheme.textSecondary, | ||
), | ||
child: child, | ||
); | ||
} | ||
} |
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,10 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
void showErrorSnackBar(BuildContext context, String message) { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
SnackBar( | ||
content: Text(message), | ||
backgroundColor: Colors.red, | ||
), | ||
); | ||
} |
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
Oops, something went wrong.