Skip to content

Commit

Permalink
Merge pull request #9 from anantshri/main
Browse files Browse the repository at this point in the history
adding url encoding / decoding
  • Loading branch information
nileshtrivedi committed Jan 21, 2022
2 parents b6fd2ca + 45ea325 commit 24d2554
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/view/dashboard_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:devtools/view/tabs/base64_encoding_decoding_screen.dart';
import 'package:devtools/view/tabs/json_format_validate_screen.dart';
import 'package:devtools/view/tabs/json_to_yaml_screen.dart';
import 'package:devtools/view/tabs/jwt_debugger_screen.dart';
import 'package:devtools/view/tabs/url_encoding_decoding_screen.dart';
import 'package:devtools/view/tabs/word_count.dart';
import 'package:devtools/view/tabs/yaml_to_json_screen.dart';
import 'package:devtools/view/tabs/qr_code_to_text_screen.dart';
Expand Down Expand Up @@ -30,6 +31,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
const TextToQrCodeScreen(),
const JWTDebuggerScreen(),
const WordCountScreen(),
const UrlEncodingDecodingScreen(),
];

Color textLuminance(Color backgroundColor) {
Expand Down Expand Up @@ -169,6 +171,17 @@ class _DashboardScreenState extends State<DashboardScreen> {
style: TextStyle(fontSize: 13),
),
),

SidebarItem(
leading: MacosIcon(
Icons.lock,
color: Colors.white70,
),
label: Text(
'URL Encoding / Decoding',
style: TextStyle(fontSize: 13),
),
),
],
);
},
Expand Down
199 changes: 199 additions & 0 deletions lib/view/tabs/url_encoding_decoding_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import 'package:clipboard/clipboard.dart';
import 'package:devtools/view/widgets/custom_radio_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

class UrlEncodingDecodingScreen extends StatefulWidget {
const UrlEncodingDecodingScreen({Key? key}) : super(key: key);

@override
_UrlEncodingDecodingScreenState createState() =>
_UrlEncodingDecodingScreenState();
}

class _UrlEncodingDecodingScreenState
extends State<UrlEncodingDecodingScreen> {
int _groupValue = 0;
TextEditingController _inputTextController = TextEditingController();
TextEditingController _outputTextController = TextEditingController();

@override
Widget build(BuildContext context) {
return MacosScaffold(
titleBar: const TitleBar(
centerTitle: true,
title: Text(
"Url Encoding/Decoding",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
decoration: BoxDecoration(
border: null,
),
),
children: [
ContentArea(builder: (context, scrollController) {
return SingleChildScrollView(
controller: scrollController,
padding: const EdgeInsets.all(20),
child: Column(
children: [
//!Input Section
//! Header Top Section
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
const Text(
'Input:',
style: TextStyle(fontSize: 14),
),
const SizedBox(
width: 10,
),
PushButton(
buttonSize: ButtonSize.small,
child: const Text('Clipboard'),
onPressed: () {
FlutterClipboard.paste().then((value) {
_inputTextController.text = value;
if (_groupValue == 0) {
String encoded =
Uri.encodeFull(value);
_outputTextController.text = encoded;
} else if (_groupValue == 1) {
String decoded =
Uri.decodeFull(value);
_outputTextController.text = decoded;
}
});
},
),
const SizedBox(
width: 5,
),
PushButton(
buttonSize: ButtonSize.small,
child: const Text('Clear'),
onPressed: () {
_inputTextController.text = "";
_outputTextController.text = "";
},
),
],
),
Row(
children: [
CustomRadioListTile<int>(
value: 0,
groupValue: _groupValue,
onChanged: (value) {
setState(() {
_groupValue = value!;
});
String encoded = Uri
.encodeFull(_inputTextController.text);
_outputTextController.text = encoded;
},
title: 'Encode',
),
const SizedBox(
width: 10,
),
CustomRadioListTile<int>(
value: 1,
groupValue: _groupValue,
onChanged: (value) {
setState(() {
_groupValue = value!;
});
String decoded = Uri.decodeFull(_inputTextController.text);
_outputTextController.text = decoded;
},
title: 'Decode',
),
],
)
],
),
const SizedBox(
height: 10,
),
MacosTextField(
controller: _inputTextController,
onChanged: (value) {
if (_groupValue == 0) {
String encoded = Uri.encodeFull(value);
_outputTextController.text = encoded;
} else if (_groupValue == 1) {
String decoded = Uri.decodeFull(value);
_outputTextController.text = decoded;
}
},
maxLines: null,
minLines: 15,
),
const SizedBox(
height: 20,
),
//! Output Section
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Output:',
style: TextStyle(fontSize: 14),
),
Row(
children: [
PushButton(
buttonSize: ButtonSize.small,
child: const Text('Copy'),
onPressed: () {
FlutterClipboard.copy(_outputTextController.text);
},
),
const SizedBox(
width: 5,
),
PushButton(
buttonSize: ButtonSize.small,
child: const Text('Use as input'),
onPressed: () {
String value = _outputTextController.text;
_inputTextController.text =
_outputTextController.text;
if (_groupValue == 0) {
String encoded =
Uri.encodeFull(value);
_outputTextController.text = encoded;
} else if (_groupValue == 1) {
String decoded = Uri.decodeFull(value);
_outputTextController.text = decoded;
}
},
),
],
)
],
),
const SizedBox(
height: 10,
),
MacosTextField(
controller: _outputTextController,
maxLines: null,
minLines: 15,
)
],
),
);
}),
],
);
}
}

0 comments on commit 24d2554

Please sign in to comment.