refactor(flutter_gui): moved constants to seperate file

This commit is contained in:
Patryk Hegenberg 2024-05-17 13:50:53 +02:00
parent f0f67332a0
commit 1b83c0b5ff
5 changed files with 46 additions and 45 deletions

View file

@ -0,0 +1,7 @@
import 'package:flutter/material.dart';
class Constants {
static const backColor = Color(0xFF32363E);
static const highlightColor = Color(0xFF98C379);
static const textColor = Color(0xFFABB2BF);
}

View file

@ -79,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
centerTitle: true, centerTitle: true,
title: Text( title: Text(
widget.title, widget.title,
style: TextStyle(color: textColor), style: const TextStyle(color: textColor),
), ),
actions: [ actions: [
PopupMenuButton<String>( PopupMenuButton<String>(

View file

@ -6,10 +6,11 @@ import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_test_gui/src/rust/api/simple.dart'; import 'package:flutter_test_gui/src/rust/api/simple.dart';
import 'package:flutter_test_gui/src/rust/frb_generated.dart'; import 'package:flutter_test_gui/src/rust/frb_generated.dart';
import 'package:flutter_test_gui/consts/consts.dart';
const backColor = Color(0xFF32363E); // const backColor = Color(0xFF32363E);
const highlightColor = Color(0xFF98C379); // const highlightColor = Color(0xFF98C379);
const textColor = Color(0xFFABB2BF); // const textColor = Color(0xFFABB2BF);
class ReceiveScreen extends StatefulWidget { class ReceiveScreen extends StatefulWidget {
@override @override
@ -100,12 +101,12 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
height: 200, height: 200,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: textColor, color: Constants.textColor,
), ),
child: const Center( child: const Center(
child: Icon( child: Icon(
Icons.qr_code, Icons.qr_code,
color: highlightColor, color: Constants.highlightColor,
size: 100, size: 100,
), ),
), ),
@ -130,18 +131,18 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
controller: myController, controller: myController,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: const TextStyle(
color: highlightColor, color: Constants.highlightColor,
), ),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Enter Transfername', labelText: 'Enter Transfername',
alignLabelWithHint: true, alignLabelWithHint: true,
floatingLabelAlignment: FloatingLabelAlignment.center, floatingLabelAlignment: FloatingLabelAlignment.center,
labelStyle: TextStyle(color: Colors.white54), labelStyle: TextStyle(color: Constants.textColor),
enabledBorder: UnderlineInputBorder( enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white), borderSide: BorderSide(color: Constants.textColor),
), ),
focusedBorder: UnderlineInputBorder( focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white), borderSide: BorderSide(color: Constants.textColor),
), ),
), ),
), ),
@ -150,8 +151,8 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
const SizedBox(height: 16), const SizedBox(height: 16),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: textColor, backgroundColor: Constants.textColor,
foregroundColor: highlightColor, foregroundColor: Constants.highlightColor,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
), ),
@ -163,7 +164,7 @@ class _ReceiveScreenState extends State<ReceiveScreen> {
), ),
Text( Text(
greetingText, greetingText,
style: const TextStyle(color: Colors.white), style: const TextStyle(color: Constants.textColor),
), ),
], ],
)), )),

View file

@ -7,10 +7,11 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter_test_gui/pages/waiting_screen.dart'; import 'package:flutter_test_gui/pages/waiting_screen.dart';
import 'package:flutter_test_gui/src/rust/api/simple.dart'; import 'package:flutter_test_gui/src/rust/api/simple.dart';
import 'package:flutter_test_gui/src/rust/frb_generated.dart'; import 'package:flutter_test_gui/src/rust/frb_generated.dart';
import 'package:flutter_test_gui/consts/consts.dart';
const backColor = Color(0xFF32363E); // const backColor = Color(0xFF32363E);
const highlightColor = Color(0xFF98C379); // const highlightColor = Color(0xFF98C379);
const textColor = Color(0xFFABB2BF); // const textColor = Color(0xFFABB2BF);
class SendScreen extends StatefulWidget { class SendScreen extends StatefulWidget {
@override @override
@ -47,7 +48,7 @@ class _SendScreenState extends State<SendScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: backColor, backgroundColor: Constants.backColor,
body: Column( body: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -77,35 +78,26 @@ class _SendScreenState extends State<SendScreen> {
Container( Container(
height: 200, height: 200,
width: 200, width: 200,
decoration: BoxDecoration( decoration: const BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: _dragging color: Constants.textColor),
? Colors.blue.withOpacity(0.4) child: _dragging
: textColor),
child: _list.isEmpty
? const Center( ? const Center(
child: Icon( child: Icon(
Icons.add_circle_outlined, Icons.add_rounded,
color: highlightColor, color: Constants.highlightColor,
size: 200, size: 200,
), ),
) )
: Text(_list.join("\n")), : const Center(
child: Icon(
Icons.upload_rounded,
color: Constants.highlightColor,
size: 200,
),
),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
if (_list.isNotEmpty)
SizedBox(
height: 100,
child: ListView.builder(
itemCount: _list.length,
itemBuilder: (context, index) {
return Text(
_list[index].name,
style: const TextStyle(color: Colors.white),
);
},
),
)
], ],
), ),
), ),
@ -115,8 +107,8 @@ class _SendScreenState extends State<SendScreen> {
), ),
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: textColor, backgroundColor: Constants.textColor,
foregroundColor: highlightColor, foregroundColor: Constants.highlightColor,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
), ),

View file

@ -6,10 +6,11 @@ import 'package:cross_file/cross_file.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_test_gui/src/rust/api/simple.dart'; import 'package:flutter_test_gui/src/rust/api/simple.dart';
import 'package:flutter_test_gui/src/rust/frb_generated.dart'; import 'package:flutter_test_gui/src/rust/frb_generated.dart';
import 'package:flutter_test_gui/consts/consts.dart';
const backColor = Color(0xFF32363E); // const backColor = Color(0xFF32363E);
const highlightColor = Color(0xFF98C379); // const highlightColor = Color(0xFF98C379);
const textColor = Color(0xFFABB2BF); // const textColor = Color(0xFFABB2BF);
class WaitingScreen extends StatefulWidget { class WaitingScreen extends StatefulWidget {
final List<XFile> files; final List<XFile> files;
@ -54,7 +55,7 @@ class _WaitingScreenState extends State<WaitingScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: backColor, backgroundColor: Constants.backColor,
body: Center( body: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -68,7 +69,7 @@ class _WaitingScreenState extends State<WaitingScreen> {
data: widget.transferName, data: widget.transferName,
version: QrVersions.auto, version: QrVersions.auto,
size: 200, size: 200,
foregroundColor: highlightColor, foregroundColor: Constants.highlightColor,
), ),
], ],
), ),