merged code
This commit is contained in:
commit
3fb412edba
@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
|
// import 'dart:ui' as html;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
@ -8,6 +9,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class LoginWidget extends StatefulWidget {
|
class LoginWidget extends StatefulWidget {
|
||||||
final bool isDesktop;
|
final bool isDesktop;
|
||||||
|
|||||||
@ -1,18 +1,26 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io' as io show Directory, File;
|
import 'dart:io' as io show Directory, File;
|
||||||
|
import 'package:flutter_quill/flutter_quill.dart' hide Text;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_quill/flutter_quill.dart' hide Text;
|
||||||
|
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart';
|
import 'package:flutter_quill/flutter_quill.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
import 'package:flutter_quill/flutter_quill_internal.dart';
|
||||||
import 'package:flutter_quill/quill_delta.dart';
|
import 'package:flutter_quill/quill_delta.dart';
|
||||||
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
|
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:responsive_builder/responsive_builder.dart';
|
import 'package:responsive_builder/responsive_builder.dart';
|
||||||
|
|
||||||
import '../../routes/custom_appBar.dart';
|
import '../../routes/custom_appBar.dart';
|
||||||
import '../../routes/custom_drawer.dart';
|
import '../../routes/custom_drawer.dart';
|
||||||
import '../../services/apiService.dart';
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
import '../../widgets/custom_user_travel.dart';
|
||||||
|
|
||||||
/// Custom Embed Definition
|
/// Custom Embed Definition
|
||||||
class TimeStampEmbed {
|
class TimeStampEmbed {
|
||||||
@ -26,21 +34,40 @@ class Template extends StatefulWidget {
|
|||||||
|
|
||||||
class TemplateState extends State<Template> {
|
class TemplateState extends State<Template> {
|
||||||
final ApiService apiService = ApiService();
|
final ApiService apiService = ApiService();
|
||||||
final QuillController _controller = QuillController.basic();
|
|
||||||
final FocusNode _editorFocusNode = FocusNode();
|
Color layoutColor = Colors.redAccent;
|
||||||
final ScrollController _editorScrollController = ScrollController();
|
Color bodyColor = Colors.white;
|
||||||
|
|
||||||
|
QuillController _controller = QuillController.basic();
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_controller.document = Document();
|
_controller = QuillController.basic(); // starts with empty document
|
||||||
|
loadInitialData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _insertTimeStamp() {
|
@override
|
||||||
final timestamp = DateTime.now().toIso8601String();
|
void dispose() {
|
||||||
// Insert embed at the current selection
|
_focusNode.dispose();
|
||||||
final delta = Delta()..insert({TimeStampEmbed.type: {'value': timestamp}});
|
_controller.dispose();
|
||||||
_controller.compose(delta, _controller.selection, ChangeSource.local);
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadInitialData() async {
|
||||||
|
String? layoutString = await getLayoutColor();
|
||||||
|
String? bodyStringColor = await getBodyColor();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
layoutColor = layoutString != null
|
||||||
|
? Color(int.parse(layoutString))
|
||||||
|
: Colors.redAccent;
|
||||||
|
|
||||||
|
bodyColor = bodyStringColor != null
|
||||||
|
? Color(int.parse(bodyStringColor))
|
||||||
|
: Colors.white;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -55,75 +82,134 @@ class TemplateState extends State<Template> {
|
|||||||
body: Padding(
|
body: Padding(
|
||||||
padding: isDesktop
|
padding: isDesktop
|
||||||
? EdgeInsets.symmetric(
|
? EdgeInsets.symmetric(
|
||||||
horizontal: MediaQuery.of(context).size.width * 0.1,
|
horizontal: MediaQuery.of(context).size.width *
|
||||||
)
|
0.1, // 30% of screen width as horizontal padding
|
||||||
|
vertical: MediaQuery.of(context).size.height *
|
||||||
|
0, // 5% of screen height as vertical padding
|
||||||
|
)
|
||||||
: EdgeInsets.all(0),
|
: EdgeInsets.all(0),
|
||||||
child: SafeArea(
|
child: Row(
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
// if (isDesktop) CustomDrawer(isDesktop: true),
|
||||||
QuillSimpleToolbar(
|
Expanded(
|
||||||
controller: _controller,
|
child: buildUserTable(
|
||||||
config: QuillSimpleToolbarConfig(
|
isDesktop, context, bodyColor, layoutColor)),
|
||||||
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
|
],
|
||||||
showClipboardPaste: true,
|
|
||||||
customButtons: [
|
|
||||||
QuillToolbarCustomButtonOptions(
|
|
||||||
icon: const Icon(Icons.access_time),
|
|
||||||
onPressed: _insertTimeStamp,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: QuillEditor(
|
|
||||||
focusNode: _editorFocusNode,
|
|
||||||
scrollController: _editorScrollController,
|
|
||||||
controller: _controller,
|
|
||||||
config: QuillEditorConfig(
|
|
||||||
placeholder: 'Start writing your notes...',
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
embedBuilders: [
|
|
||||||
...FlutterQuillEmbeds.editorBuilders(),
|
|
||||||
TimeStampEmbedBuilder(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Embed Builder for TimeStamp
|
Widget buildUserTable(
|
||||||
class TimeStampEmbedBuilder extends EmbedBuilder {
|
bool isDesktop, context, Color? bodyColor, Color layoutColor) {
|
||||||
@override
|
return Container(
|
||||||
String get key => TimeStampEmbed.type;
|
margin: isDesktop ? const EdgeInsets.only(top: 10.0, bottom: 10.0) : null,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text("Editor"),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
buildTempalteSubject(isDesktop),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
buildTempalteBody(isDesktop)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
Widget buildTempalteSubject(bool isDesktop) {
|
||||||
Widget build(BuildContext context, EmbedContext embedContext) {
|
return Column(
|
||||||
final data = embedContext.node.value.data as Map<String, dynamic>;
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
final String time = data['value'] ?? '';
|
|
||||||
|
|
||||||
return Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.access_time_rounded, size: 18),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text(
|
Text(
|
||||||
time,
|
"Subject",
|
||||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
CustomTextFieldUserTravellerWrapper(
|
||||||
|
isFocused: false,
|
||||||
|
isDesktop: isDesktop,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TextField(
|
||||||
|
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
|
||||||
|
// controller: _controller[""],
|
||||||
|
onChanged: (value) {
|
||||||
|
// _clearError("local_id_num");
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: "enter the subject",
|
||||||
|
labelStyle:
|
||||||
|
GoogleFonts.poppins(fontSize: 12, color: Colors.grey),
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Widget buildTempalteBody(bool isDesktop) {
|
||||||
String toPlainText(Embed node) {
|
return Column(
|
||||||
final data = node.value.data as Map<String, dynamic>;
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
return '[${data['value'] ?? ''}]';
|
children: [
|
||||||
|
Text(
|
||||||
|
"Content",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
|
// ✅ Modern toolbar
|
||||||
|
QuillSimpleToolbar(
|
||||||
|
controller: _controller,
|
||||||
|
config: QuillSimpleToolbarConfig(
|
||||||
|
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
|
// ✅ Modern editor
|
||||||
|
// Container(
|
||||||
|
// height: 300,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border: Border.all(color: Colors.grey),
|
||||||
|
// borderRadius: BorderRadius.circular(8),
|
||||||
|
// ),
|
||||||
|
// child: QuillEditor(
|
||||||
|
// focusNode: _focusNode,
|
||||||
|
// scrollController: ScrollController(),
|
||||||
|
// controller: _controller,
|
||||||
|
// config: QuillEditorConfig(
|
||||||
|
// padding: const EdgeInsets.all(8),
|
||||||
|
// embedBuilders: FlutterQuillEmbeds.editorBuilders(),
|
||||||
|
// sharedConfigurations: const QuillSharedConfigurations(
|
||||||
|
// locale: Locale('en'),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
lib/app.dart
28
lib/app.dart
@ -14,12 +14,14 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart';
|
import 'package:flutter_quill/flutter_quill.dart';
|
||||||
import 'package:frontend/routes/custom_router.dart';
|
import 'package:frontend/routes/custom_router.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart' hide Text;
|
import 'package:flutter_quill/flutter_quill.dart' hide Text;
|
||||||
|
import 'dart:html' as html;
|
||||||
|
|
||||||
class MyApp extends StatefulWidget {
|
class MyApp extends StatefulWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
@ -29,14 +31,40 @@ class MyApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
|
String? _authCode;
|
||||||
|
bool _isAuthRedirect = false;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here
|
||||||
|
if (kIsWeb) {
|
||||||
|
final uri = Uri.parse(html.window.location.href);
|
||||||
|
if (uri.path == '/authredirection' &&
|
||||||
|
uri.queryParameters['code'] != null) {
|
||||||
|
_authCode = uri.queryParameters['code'];
|
||||||
|
// _isAuthRedirect = true;
|
||||||
|
|
||||||
|
// print(">>> _isAuthRedirect: $_isAuthRedirect");
|
||||||
|
print(">>> Auth code found at startup: $_authCode");
|
||||||
|
|
||||||
|
// You can now:
|
||||||
|
// - call an API
|
||||||
|
// - store this in a Provider
|
||||||
|
// - or just pass it through GoRouter as usual
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// if (_isAuthRedirect) {
|
||||||
|
// print("Rendering MicrosoftPage with code: $_authCode");
|
||||||
|
// return MaterialApp(
|
||||||
|
// home: MicrosoftPage(code: _authCode),
|
||||||
|
// debugShowCheckedModeBanner: false,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
title: 'TRIP MANAGEMENT',
|
title: 'TRIP MANAGEMENT',
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
|
|||||||
@ -31,6 +31,13 @@ final GoRouter router = GoRouter(
|
|||||||
path: '/',
|
path: '/',
|
||||||
builder: (context, state) => LoginPage(),
|
builder: (context, state) => LoginPage(),
|
||||||
),
|
),
|
||||||
|
// GoRoute(
|
||||||
|
// path: '/authredirection',
|
||||||
|
// builder: (context, state) {
|
||||||
|
// final code = state.uri.queryParameters['code'];
|
||||||
|
// return MicrosoftPage(code: code);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/home',
|
path: '/home',
|
||||||
builder: (context, state) => HomePage(),
|
builder: (context, state) => HomePage(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user