Skip to content

Commit

Permalink
change design and position of send button (#42)
Browse files Browse the repository at this point in the history
* change design and position of send button

* fix line formatting

* Undo irrelevant changes

* set format & remove deprecated code

* fix buttton size

---------

Co-authored-by: Muzzammil Shahid <[email protected]>
  • Loading branch information
AbdulRehman421 and muzzammilshahid authored Jun 7, 2024
1 parent e6f8adc commit 6f18e81
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 68 deletions.
146 changes: 79 additions & 67 deletions lib/screens/mobile/mobile_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
fontWeight: FontWeight.bold,
),
),
automaticallyImplyLeading: false,
actions: [
if (!kIsWeb)
Consumer<RouterToggleSwitchProvider>(
Expand Down Expand Up @@ -214,7 +213,6 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
)
: null,
),
drawer: const Drawer(),
body: _tabNames.isNotEmpty
? Padding(
padding: const EdgeInsets.only(top: 10),
Expand Down Expand Up @@ -347,8 +345,6 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
buildArgs(_tabData[index].sendButtonText, _argsProviders[index]),
const SizedBox(height: 20),
buildKwargs(_tabData[index].sendButtonText, _kwargsProviders[index]),
const SizedBox(height: 20),
sendButton(_tabData[index].sendButtonText, index),
const SizedBox(height: 50),
resultText(_tabData[index].sendButtonText),
_buildInvocationResults(index),
Expand All @@ -362,53 +358,59 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv

Widget _buildTabActionDropdown(int index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey),
),
child: Row(
children: [
DropdownButton<String>(
focusColor: Colors.transparent,
value: _tabData[index].selectedValue.isEmpty ? null : _tabData[index].selectedValue,
hint: Text(
"Actions",
style: TextStyle(color: dropDownTextColor),
),
items: ["Register", "Subscribe", "Call", "Publish"].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(
value,
style: TextStyle(color: dropDownTextColor),
),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_tabData[index].selectedValue = newValue!;
_tabData[index].sendButtonText = newValue;
});
},
),
Container(height: 30, width: 1, color: Colors.grey),
Expanded(
padding: const EdgeInsets.only(left: 15, right: 15, top: 5),
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 10),
child: TextFormField(
controller: _tabData[index].linkController,
decoration: const InputDecoration(
hintText: "ws://localhost:8080/ws",
hintStyle: TextStyle(fontWeight: FontWeight.w200),
labelText: "Enter URL here",
border: InputBorder.none,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
),
contentPadding: EdgeInsets.all(10),
),
),
),
],
),
),
sendButton(_tabData[index].sendButtonText, index),
Container(width: 1, height: 45, color: Colors.black),
Container(
height: 45,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10),
),
color: Colors.blue,
),
child: PopupMenuButton<String>(
onSelected: (String newValue) {
setState(() {
_tabData[index].selectedValue = newValue;
_tabData[index].sendButtonText = newValue;
});
},
itemBuilder: (BuildContext context) {
return ["Register", "Subscribe", "Call", "Publish"].map((String value) {
return PopupMenuItem<String>(
value: value,
child: Text(value),
);
}).toList();
},
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.white,
), // Transparent icon to avoid extra arrow
),
),
],
),
);
}
Expand Down Expand Up @@ -596,31 +598,41 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
final scaffoldMessenger = ScaffoldMessenger.of(context);

Widget buildButton(String label, Future<void> Function() action) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 110),
child: MaterialButton(
onPressed: () async {
try {
await action();
} on Exception catch (error) {
scaffoldMessenger.showSnackBar(
SnackBar(
content: Text("$sendButton Error: $error"),
duration: const Duration(seconds: 3),
return SizedBox(
height: 45,
width: 145,
child: Expanded(
child: ElevatedButton(
onPressed: () async {
try {
await action();
} on Exception catch (error) {
scaffoldMessenger.showSnackBar(
SnackBar(
content: Text("$sendButton Error: $error"),
duration: const Duration(seconds: 3),
),
);
}
},
style: const ButtonStyle(
backgroundColor: WidgetStatePropertyAll(Colors.blue),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10),
),
),
);
}
},
color: Colors.blueAccent,
minWidth: 200,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
child: Text(
label,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
child: Text(
_tabData[index].sendButtonText,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
Expand Down Expand Up @@ -750,7 +762,7 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
Future<void> _unRegister(int index, Session? session, var reg) async {
await session?.unregister(reg);
setState(() {
_tabData[index].sendButtonText = "send";
_tabData[index].sendButtonText = "Register";
_tabData[index].selectedSerializer = "";
_tabData[index].selectedValue = "";
_tabData[index].topicProcedureController.clear();
Expand All @@ -761,7 +773,7 @@ class _MobileHomeScaffoldState extends State<MobileHomeScaffold> with TickerProv
Future<void> _unSubscribe(int index, Session? session, var sub) async {
await session?.unsubscribe(sub);
setState(() {
_tabData[index].sendButtonText = "send";
_tabData[index].sendButtonText = "Subscribe";
_tabData[index].selectedSerializer = "";
_tabData[index].selectedValue = "";
});
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/tab_data_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TabData {

String selectedValue = "";
String selectedSerializer = "";
String sendButtonText = "Send";
String sendButtonText = "Call";
List<String>? callRslt = [];
TextEditingController linkController = TextEditingController();
TextEditingController realmController = TextEditingController();
Expand Down

0 comments on commit 6f18e81

Please sign in to comment.