chore: Hide FAB story buttons on focus
This commit is contained in:
parent
4b90bf7310
commit
ced37f02ec
4 changed files with 39 additions and 32 deletions
|
|
@ -27,6 +27,7 @@ class AddStoryPage extends StatefulWidget {
|
|||
|
||||
class AddStoryController extends State<AddStoryPage> {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
final FocusNode focusNode = FocusNode();
|
||||
late Color backgroundColor;
|
||||
late Color backgroundColorDark;
|
||||
MatrixImageFile? image;
|
||||
|
|
@ -38,6 +39,8 @@ class AddStoryController extends State<AddStoryPage> {
|
|||
|
||||
bool hasText = false;
|
||||
|
||||
bool textFieldHasFocus = false;
|
||||
|
||||
Timer? _updateColorsCooldown;
|
||||
|
||||
void updateColors() {
|
||||
|
|
@ -167,6 +170,13 @@ class AddStoryController extends State<AddStoryPage> {
|
|||
final text = Matrix.of(context).client.userID!;
|
||||
backgroundColor = text.color;
|
||||
backgroundColorDark = text.darkColor;
|
||||
focusNode.addListener(() {
|
||||
if (textFieldHasFocus != focusNode.hasFocus) {
|
||||
setState(() {
|
||||
textFieldHasFocus = focusNode.hasFocus;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
final shareContent = Matrix.of(context).shareContent;
|
||||
if (shareContent != null) {
|
||||
|
|
|
|||
|
|
@ -80,10 +80,11 @@ class AddStoryView extends StatelessWidget {
|
|||
child: Center(
|
||||
child: TextField(
|
||||
controller: controller.controller,
|
||||
focusNode: controller.focusNode,
|
||||
minLines: 1,
|
||||
maxLines: 15,
|
||||
maxLength: 500,
|
||||
autofocus: true,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
|
|
@ -114,29 +115,31 @@ class AddStoryView extends StatelessWidget {
|
|||
floatingActionButton: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FloatingActionButton(
|
||||
onPressed: controller.captureVideo,
|
||||
backgroundColor: controller.backgroundColorDark,
|
||||
foregroundColor: Colors.white,
|
||||
heroTag: null,
|
||||
child: const Icon(Icons.video_camera_front_outlined),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FloatingActionButton(
|
||||
onPressed: controller.capturePhoto,
|
||||
backgroundColor: controller.backgroundColorDark,
|
||||
foregroundColor: Colors.white,
|
||||
heroTag: null,
|
||||
child: const Icon(Icons.camera_alt_outlined),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FloatingActionButton(
|
||||
onPressed: controller.importMedia,
|
||||
backgroundColor: controller.backgroundColorDark,
|
||||
foregroundColor: Colors.white,
|
||||
heroTag: null,
|
||||
child: const Icon(Icons.photo_outlined),
|
||||
),
|
||||
if (!controller.hasMedia && !controller.textFieldHasFocus) ...[
|
||||
FloatingActionButton(
|
||||
onPressed: controller.captureVideo,
|
||||
backgroundColor: controller.backgroundColorDark,
|
||||
foregroundColor: Colors.white,
|
||||
heroTag: null,
|
||||
child: const Icon(Icons.video_camera_front_outlined),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FloatingActionButton(
|
||||
onPressed: controller.capturePhoto,
|
||||
backgroundColor: controller.backgroundColorDark,
|
||||
foregroundColor: Colors.white,
|
||||
heroTag: null,
|
||||
child: const Icon(Icons.camera_alt_outlined),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FloatingActionButton(
|
||||
onPressed: controller.importMedia,
|
||||
backgroundColor: controller.backgroundColorDark,
|
||||
foregroundColor: Colors.white,
|
||||
heroTag: null,
|
||||
child: const Icon(Icons.photo_outlined),
|
||||
),
|
||||
],
|
||||
if (controller.hasMedia || controller.hasText) ...[
|
||||
const SizedBox(height: 16),
|
||||
FloatingActionButton(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue