Improve design of message view text input
This commit is contained in:
parent
2b7b4e2dba
commit
3fcb9b7a49
2 changed files with 71 additions and 46 deletions
|
@ -25,7 +25,7 @@ class MessageBubble extends StatelessWidget {
|
|||
Material(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
color: backgroundColor,
|
||||
textStyle: Theme.of(context).textTheme.bodyMedium?.copyWith(color: foregroundColor),
|
||||
textStyle: Theme.of(context).textTheme.bodySmall?.copyWith(color: foregroundColor),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
child: switch (message.type) {
|
||||
|
|
|
@ -18,13 +18,14 @@ class MessagesList extends StatefulWidget {
|
|||
State<StatefulWidget> createState() => _MessagesListState();
|
||||
}
|
||||
|
||||
class _MessagesListState extends State<MessagesList> {
|
||||
class _MessagesListState extends State<MessagesList> with SingleTickerProviderStateMixin {
|
||||
final TextEditingController _messageTextController = TextEditingController();
|
||||
final ScrollController _sessionListScrollController = ScrollController();
|
||||
final ScrollController _messageScrollController = ScrollController();
|
||||
|
||||
bool _isSendable = false;
|
||||
bool _showSessionListScrollChevron = false;
|
||||
bool _showBottomBarShadow = false;
|
||||
|
||||
double get _shevronOpacity => _showSessionListScrollChevron ? 1.0 : 0.0;
|
||||
|
||||
|
@ -52,6 +53,19 @@ class _MessagesListState extends State<MessagesList> {
|
|||
});
|
||||
}
|
||||
});
|
||||
_messageScrollController.addListener(() {
|
||||
if (!_messageScrollController.hasClients) return;
|
||||
if (_messageScrollController.position.atEdge && _messageScrollController.position.pixels == 0 &&
|
||||
_showBottomBarShadow) {
|
||||
setState(() {
|
||||
_showBottomBarShadow = false;
|
||||
});
|
||||
} else if (!_showBottomBarShadow) {
|
||||
setState(() {
|
||||
_showBottomBarShadow = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -74,7 +88,11 @@ class _MessagesListState extends State<MessagesList> {
|
|||
Text(widget.friend.username),
|
||||
if (widget.friend.isHeadless) Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: Icon(Icons.dns, size: 18, color: Theme.of(context).colorScheme.onSecondaryContainer.withAlpha(150),),
|
||||
child: Icon(Icons.dns, size: 18, color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.onSecondaryContainer
|
||||
.withAlpha(150),),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -177,13 +195,21 @@ class _MessagesListState extends State<MessagesList> {
|
|||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Padding(
|
||||
bottomNavigationBar: AnimatedContainer(
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
blurRadius: _showBottomBarShadow ? 8 : 0,
|
||||
color: Theme.of(context).shadowColor,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
),
|
||||
padding: MediaQuery
|
||||
.of(context)
|
||||
.viewInsets,
|
||||
child: BottomAppBar(
|
||||
elevation: 0.0,
|
||||
padding: const EdgeInsets.symmetric(vertical: 0, horizontal: 6),
|
||||
.viewInsets + const EdgeInsets.symmetric(horizontal: 4),
|
||||
duration: const Duration(milliseconds: 250),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
@ -209,7 +235,7 @@ class _MessagesListState extends State<MessagesList> {
|
|||
isDense: true,
|
||||
hintText: "Send a message to ${widget.friend
|
||||
.username}...",
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(24)
|
||||
)
|
||||
|
@ -255,13 +281,12 @@ class _MessagesListState extends State<MessagesList> {
|
|||
iconSize: 28,
|
||||
icon: const Icon(Icons.send),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue