Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
laiiihz committed Nov 17, 2023
1 parent 86454c6 commit 8261bcd
Show file tree
Hide file tree
Showing 37 changed files with 409 additions and 301 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ flutter_distributor release --name release
## Special Thanks

* [lijy91](https://github.com/lijy91) : [flutter_distributor](https://github.com/leanflutter/flutter_distributor)([pub](https://pub.dev/packages/flutter_distributor)), [window_manager](https://github.com/leanflutter/window_manager)([pub](https://pub.dev/packages/window_manager))
* [lijy91](https://github.com/lijy91)
* [flutter_distributor](https://github.com/leanflutter/flutter_distributor)![flutter_distributor](https://img.shields.io/pub/v/flutter_distributor)
* [window_manager](https://github.com/leanflutter/window_manager)![window_manager](https://img.shields.io/pub/v/window_manager)

## Privacy Policy

Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"deviceModel": "Device Model",
"emptyValue": "Empty content",
"encode": "Encode",
"encoded": "Encoded",
"encoderDecoderApp": "Encoder Decoder",
"encoderDecoderBase64": "Base64 Encoder/Decoder",
"encoderDecoderGzip": "GZip Encoder/Decoder",
Expand Down Expand Up @@ -127,6 +128,7 @@
"octal": "Octal",
"operatingSystem": "Operating System",
"operatingSystemVersion": "Operating System Version",
"original": "Original",
"osRelease": "OS Release",
"output": "output",
"parsedDate": "Parsed Date",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"deviceModel": "设备型号",
"emptyValue": "内容为空",
"encode": "编码",
"encoded": "编码后",
"encoderDecoderApp": "编码解码",
"encoderDecoderBase64": "Base64 编码/解码工具",
"encoderDecoderGzip": "GZip 编码/解码工具",
Expand Down Expand Up @@ -127,6 +128,7 @@
"octal": "八进制",
"operatingSystem": "操作系统",
"operatingSystemVersion": "操作系统版本",
"original": "原始",
"osRelease": "操作系统版本",
"output": "输出",
"parsedDate": "解析的日期",
Expand Down
5 changes: 2 additions & 3 deletions lib/models/app_atom.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:alga/models/app_category.dart';
import 'package:alga/routers/app_router.dart';
import 'package:alga/tools/tools.dart';
Expand Down Expand Up @@ -227,14 +226,14 @@ class AppAtom {
static final gzip = AppAtom(
icon: const Icon(Icons.folder_zip),
title: (context) => context.tr.encoderDecoderGzip,
path: GzipCompressDecompressRoute().location,
path: GZipCompressRoute().location,
categories: [AppCategory.encodersDecoders],
);

static final jwtDecoder = AppAtom(
icon: const SvgAssetIcon('assets/icons/JWT.svg', colorIcon: true),
title: (context) => context.tr.decoderJWT,
path: JWTDecoderRoute().location,
path: JwtDecoderRoute().location,
categories: [AppCategory.encodersDecoders],
);

Expand Down
5 changes: 2 additions & 3 deletions lib/routers/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ GoRouter appRouter(AppRouterRef ref) {
TypedGoRoute<AbsLengthConverterRoute>(path: 'abs-length-converter'),
TypedGoRoute<UriEncoderDecoderRoute>(path: 'uri-encoder-decoder'),
TypedGoRoute<Base64EncoderDecoderRoute>(path: 'base64-encoder-decoder'),
TypedGoRoute<GzipCompressDecompressRoute>(
path: 'gzip-compress-decompress'),
TypedGoRoute<JWTDecoderRoute>(path: 'jwt-decoder'),
TypedGoRoute<GZipCompressRoute>(path: 'gzip-compress-decompress'),
TypedGoRoute<JwtDecoderRoute>(path: 'jwt-decoder'),
TypedGoRoute<UriParserRoute>(path: 'uri-parser'),
TypedGoRoute<JsonFormatterRoute>(path: 'json-format'),
TypedGoRoute<DartFormatterRoute>(path: 'dart-format'),
Expand Down
14 changes: 7 additions & 7 deletions lib/routers/app_router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import 'dart:convert';

import 'package:alga/l10n/l10n.dart';
import 'package:alga/ui/widgets/buttons/clear_button.dart';
import 'package:alga/ui/widgets/buttons/copy_button.dart';
import 'package:alga/ui/widgets/toolbar/alga_toolbar.dart';
import 'package:alga/ui/widgets/toolbar/toolbar_paste.dart';
import 'package:alga/utils/extension/list_ext.dart';
import 'package:archive/archive.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class GZipCompressRoute extends GoRouteData {
@override
Widget build(BuildContext context, GoRouterState state) {
return const GZipCompressPage();
}
}

class GZipCompressPage extends StatefulWidget {
const GZipCompressPage({super.key});

@override
State<GZipCompressPage> createState() => _GZipCompressPageState();
}

class _GZipCompressPageState extends State<GZipCompressPage> {
final _originalInput = TextEditingController();
final _encodedInput = TextEditingController();
String? _originalError;
String? _encodedError;
@override
void dispose() {
_originalInput.dispose();
_encodedInput.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(context.tr.encoderDecoderGzip),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
AlgaToolbar(
title: Text(context.tr.original),
actions: [
PasteButton(
controller: _originalInput,
onChanged: (t) {
_originalInput.text = t;
_encode(t);
},
),
CopyButton(() => _originalInput.text),
ClearButton(controller: _originalInput),
],
),
Expanded(
child: TextField(
expands: true,
maxLines: null,
controller: _originalInput,
onChanged: _encode,
textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(errorText: _originalError),
),
),
AlgaToolbar(
title: Text(context.tr.encoded),
actions: [
PasteButton(
controller: _originalInput,
onChanged: (t) {
_encodedInput.text = t;
_decode(t);
},
),
CopyButton(() => _encodedInput.text),
ClearButton(controller: _encodedInput),
],
),
Expanded(
child: TextField(
expands: true,
maxLines: null,
controller: _encodedInput,
onChanged: _decode,
textAlignVertical: TextAlignVertical.top,
decoration: InputDecoration(errorText: _encodedError),
),
),
].sep(const SizedBox(height: 4)),
),
),
);
}

void _encode(String text) {
final g = GZipEncoder();
const b = Base64Encoder();
try {
final results = g.encode(utf8.encode(text));
if (results == null) throw Exception('Empty Data');
_encodedInput.text = b.convert(results);
_originalError = null;
} catch (e) {
_originalError = e.toString();
}
_safe();
}

void _decode(String text) {
final g = GZipDecoder();
const b = Base64Decoder();
try {
final results = g.decodeBytes(b.convert(text));
_originalInput.text = utf8.decode(results);
_encodedError = null;
} catch (e) {
_encodedError = e.toString();
}
}

void _safe() {
if (mounted) setState(() {});
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8261bcd

Please sign in to comment.