Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lantern Desktop Beta 8.0.0 collected testing issues #1057

Merged
merged 10 commits into from
Apr 29, 2024
4 changes: 0 additions & 4 deletions lib/account/device_linking/authorize_device_via_email.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class AuthorizeDeviceViaEmail extends StatelessWidget {
controller: emailController,
autovalidateMode: AutovalidateMode.disabled,
//TODO: this throws an error when we set it to AutovalidateMode.onUserInteraction
contentPadding: const EdgeInsetsDirectional.only(
top: 8.0,
bottom: 8.0,
),
label: 'Email'.i18n,
helperText: 'auth_email_helper_text'.i18n,
keyboardType: TextInputType.emailAddress,
Expand Down
8 changes: 1 addition & 7 deletions lib/account/report_issue.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// ignore_for_file: use_build_context_synchronously

import 'package:email_validator/email_validator.dart';
import 'package:lantern/common/common.dart';
import 'package:lantern/common/ui/app_loading_dialog.dart';
Expand Down Expand Up @@ -88,10 +87,6 @@ class _ReportIssueState extends State<ReportIssue> {
initialValue: emailAddress,
controller: emailController,
autovalidateMode: AutovalidateMode.disabled,
contentPadding: const EdgeInsetsDirectional.only(
top: 8.0,
bottom: 8.0,
),
label: 'email'.i18n,
onChanged: (value) {
setState(() {});
Expand Down Expand Up @@ -161,8 +156,7 @@ class _ReportIssueState extends State<ReportIssue> {
child: CTextField(
tooltipMessage: 'report_description'.i18n,
controller: descController,
contentPadding: const EdgeInsetsDirectional.all(8.0),
label: '',
contentPadding: isDesktop() ? const EdgeInsetsDirectional.all(16.0) : const EdgeInsetsDirectional.all(8.0),
hintText: 'issue_description'.i18n,
autovalidateMode: AutovalidateMode.disabled,
maxLines: 8,
Expand Down
3 changes: 2 additions & 1 deletion lib/common/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export 'ui/text_highlighter.dart';
export 'ui/text_styles.dart';
export 'ui/transitions.dart';
export 'app_secret.dart';

final appLogger = Logger(
printer: PrettyPrinter(
methodCount: 0,
Expand All @@ -110,4 +111,4 @@ bool isMobile() {

bool isDesktop() {
return Platform.isMacOS || Platform.isLinux || Platform.isWindows;
}
}
59 changes: 34 additions & 25 deletions lib/common/ui/custom/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:lantern/common/common.dart';
class CTextField extends StatefulWidget {
late final CustomTextEditingController controller;
late final String? initialValue;
late final dynamic label;
late final dynamic? label;
late final String? helperText;
late final String? hintText;
late final Widget? prefixIcon;
Expand Down Expand Up @@ -36,7 +36,7 @@ class CTextField extends StatefulWidget {
CTextField({
required this.controller,
this.initialValue,
required this.label,
this.label,
this.helperText,
this.hintText,
this.prefixIcon,
Expand Down Expand Up @@ -154,7 +154,15 @@ class _CTextFieldState extends State<CTextField> {
widget.textCapitalization ?? TextCapitalization.none,
decoration: InputDecoration(
contentPadding: widget.contentPadding ??
const EdgeInsetsDirectional.all(0),
(isDesktop()
? const EdgeInsetsDirectional.only(
top: 24,
bottom: 24,
)
: const EdgeInsetsDirectional.only(
top: 8,
bottom: 8,
)),
isDense: true,
floatingLabelBehavior: FloatingLabelBehavior.never,
// we handle floating labels using our custom method below
Expand Down Expand Up @@ -204,29 +212,30 @@ class _CTextFieldState extends State<CTextField> {
),
),
// * Label
(widget.label is String)
? Container(
margin: const EdgeInsetsDirectional.only(start: 11),
padding: EdgeInsetsDirectional.only(
start: hasFocus ? 2 : 0,
end: hasFocus ? 2 : 0,
),
color: white,
child: !hasFocus && widget.controller.value.text.isEmpty
? Container()
: CText(
widget.label,
style: CTextStyle(
fontSize: 12,
lineHeight: 12,
color: fieldKey.currentState?.mounted == true &&
fieldKey.currentState?.hasError == true
? indicatorRed
: blue4,
if (widget.label != null)
(widget.label is String)
? Container(
margin: const EdgeInsetsDirectional.only(start: 11),
padding: EdgeInsetsDirectional.only(
start: hasFocus ? 20 : 0,
end: hasFocus ? 20 : 0,
),
color: white,
child: !hasFocus && widget.controller.value.text.isEmpty
? Container()
: CText(
widget.label,
style: CTextStyle(
fontSize: 12,
lineHeight: 12,
color: fieldKey.currentState?.mounted == true &&
fieldKey.currentState?.hasError == true
? indicatorRed
: blue4,
),
),
),
)
: widget.label,
)
: widget.label,
],
);
}
Expand Down
108 changes: 63 additions & 45 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,58 +31,65 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
MethodChannel? navigationChannel;
Function()? _cancelEventSubscription;

_HomePageState();

@override
void initState() {
if (isDesktop()) {
_startupSequence();
super.initState();
}

void _startupSequence() {
if (isMobile()) {
// This is a mobile device
channelListener();
} else {
// This is a desktop device
setupTrayManager();
windowManager.addListener(this);
_init();
}
super.initState();
if (isMobile()) {
mainMethodChannel = const MethodChannel('lantern_method_channel');
navigationChannel = const MethodChannel('navigation');
sessionModel.getChatEnabled().then((chatEnabled) {
if (chatEnabled) {
messagingModel
.shouldShowTryLanternChatModal()
.then((shouldShowModal) async {
if (shouldShowModal) {
// open VPN tab
await sessionModel.setSelectedTab(TAB_VPN);
// show Try Lantern Chat dialog
await context.router
.push(FullScreenDialogPage(widget: TryLanternChat()));
}
});
}
});
}

navigationChannel?.setMethodCallHandler(_handleNativeNavigationRequest);
// Let back-end know that we're ready to handle navigation
navigationChannel?.invokeListMethod('ready');
_cancelEventSubscription =
sessionModel.eventManager.subscribe(Event.All, (event, params) {
switch (event) {
case Event.SurveyAvailable:
// show survey snackbar
showSuerySnackbar(
context: context,
buttonText: params['buttonText'] as String,
message: params['message'] as String,
onPressed: () {
mainMethodChannel?.invokeMethod('showLastSurvey');
ScaffoldMessenger.of(context).hideCurrentSnackBar();
});
void channelListener() {
mainMethodChannel = const MethodChannel('lantern_method_channel');
navigationChannel = const MethodChannel('navigation');
sessionModel.getChatEnabled().then((chatEnabled) {
if (chatEnabled) {
messagingModel
.shouldShowTryLanternChatModal()
.then((shouldShowModal) async {
if (shouldShowModal) {
// open VPN tab
await sessionModel.setSelectedTab(TAB_VPN);
// show Try Lantern Chat dialog
await context.router
.push(FullScreenDialogPage(widget: TryLanternChat()));
}
});
}
});

break;
default:
break;
}
});
}
navigationChannel?.setMethodCallHandler(_handleNativeNavigationRequest);
// Let back-end know that we're ready to handle navigation
navigationChannel?.invokeListMethod('ready');
_cancelEventSubscription =
sessionModel.eventManager.subscribe(Event.All, (event, params) {
switch (event) {
case Event.SurveyAvailable:
// show survey snackbar
showSuerySnackbar(
context: context,
buttonText: params['buttonText'] as String,
message: params['message'] as String,
onPressed: () {
mainMethodChannel?.invokeMethod('showLastSurvey');
ScaffoldMessenger.of(context).hideCurrentSnackBar();
});

break;
default:
break;
}
});
}

void _init() async {
Expand Down Expand Up @@ -111,7 +118,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
void onTrayMenuItemClick(MenuItem menuItem) async {
switch (menuItem.key) {
case 'show':
windowManager.show();
windowManager.focus();
atavism marked this conversation as resolved.
Show resolved Hide resolved
case 'exit':
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
case 'status':
Expand Down Expand Up @@ -157,6 +164,11 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
}
}

@override
void onWindowEvent(String eventName) {
print('[WindowManager] onWindowEvent: $eventName');
}

Future<dynamic> _handleNativeNavigationRequest(MethodCall methodCall) async {
switch (methodCall.method) {
case 'openConversation':
Expand All @@ -168,6 +180,12 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
}
}

@override
void onWindowFocus() {
print('[WindowManager] onWindowFocus');
setState(() {});
}

@override
void dispose() {
if (isDesktop()) {
Expand Down
8 changes: 0 additions & 8 deletions lib/plans/checkout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ class _CheckoutState extends State<Checkout>
autovalidateMode: widget.isPro
? AutovalidateMode.always
: AutovalidateMode.disabled,
contentPadding: const EdgeInsetsDirectional.only(
top: 8.0,
bottom: 8.0,
),
label: 'email'.i18n,
keyboardType: TextInputType.emailAddress,
prefixIcon: const CAssetImage(path: ImagePaths.email),
Expand All @@ -140,10 +136,6 @@ class _CheckoutState extends State<Checkout>
child: CTextField(
controller: refCodeController,
autovalidateMode: AutovalidateMode.disabled,
contentPadding: const EdgeInsetsDirectional.only(
top: 8.0,
bottom: 8.0,
),
onChanged: (text) {
setState(() {
showContinueButton = enableContinueButton();
Expand Down
Loading