financial changes

master
gitadmin 2 months ago
parent ebe650103f
commit 23e9425217

@ -114,8 +114,7 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
value: transactionType, value: transactionType,
onChanged: (val) => onChanged: (val) =>
setState(() => transactionType = val), setState(() => transactionType = val),
hintStyle: fontTextStyle( hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
14, const Color(0xFF939495), FontWeight.w400),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
fieldLabel("Account Name", requiredMark: true), fieldLabel("Account Name", requiredMark: true),
@ -124,8 +123,7 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
items: const ["Name1", "Name2"], items: const ["Name1", "Name2"],
value: accountName, value: accountName,
onChanged: (val) => setState(() => accountName = val), onChanged: (val) => setState(() => accountName = val),
hintStyle: fontTextStyle( hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
14, const Color(0xFF939495), FontWeight.w400),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
fieldLabel("Amount (in ₹)", requiredMark: true), fieldLabel("Amount (in ₹)", requiredMark: true),
@ -140,8 +138,7 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
.isEmpty) .isEmpty)
? "Amount is required" ? "Amount is required"
: null, : null,
hintStyle: fontTextStyle( hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
14, const Color(0xFF939495), FontWeight.w400),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
Row( Row(
@ -162,10 +159,7 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
value: paymentStatus, value: paymentStatus,
onChanged: (val) => onChanged: (val) =>
setState(() => paymentStatus = val), setState(() => paymentStatus = val),
hintStyle: fontTextStyle( hintStyle: fontTextStyle(14, Color(0xFF939495), FontWeight.w400), // styled
14,
const Color(0xFF939495),
FontWeight.w400), // styled
), ),
], ],
), ),
@ -218,8 +212,8 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
// TODO: Save handler // TODO: Save handler
} }
}, },
child: const Text("Save", child: Text("Save",
style: TextStyle(fontSize: 16)), style:fontTextStyle(14, Color(0xFFFFFFFF), FontWeight.w600),),
), ),
), ),
], ],
@ -244,11 +238,14 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
}) { }) {
return DropdownButtonFormField<String>( return DropdownButtonFormField<String>(
value: value, value: value,
// must be null to show the hint
isExpanded: true, isExpanded: true,
isDense: true, isDense: true,
// 👇 your custom down-arrow image
icon: Image.asset('images/downarrow.png', width: 16, height: 16),
iconSize: 16, // optional, keeps layout tight
decoration: InputDecoration( decoration: InputDecoration(
// don't set hintText here; use the `hint:` widget below
contentPadding: contentPadding ?? contentPadding: contentPadding ??
const EdgeInsets.symmetric(horizontal: 12, vertical: 12), const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
), ),
@ -258,15 +255,12 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
hint, hint,
textAlign: centerHint ? TextAlign.center : TextAlign.start, textAlign: centerHint ? TextAlign.center : TextAlign.start,
style: hintStyle ?? style: hintStyle ??
fontTextStyle( fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
14,
const Color(0xFF939495),
FontWeight.w400),
), ),
), ),
items: items
items: .map((e) => DropdownMenuItem(value: e, child: Text(e)))
items.map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), .toList(),
onChanged: onChanged, onChanged: onChanged,
dropdownColor: Colors.white, dropdownColor: Colors.white,
validator: (v) => (v == null || v.isEmpty) ? "Required" : null, validator: (v) => (v == null || v.isEmpty) ? "Required" : null,
@ -285,8 +279,7 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
if (requiredMark) ...[ if (requiredMark) ...[
const SizedBox(width: 2), const SizedBox(width: 2),
Text("*", Text("*",
style: fontTextStyle( style: fontTextStyle(12, const Color(0xFFD32F2F), FontWeight.w800)),
12, const Color(0xFFD32F2F), FontWeight.w800)),
], ],
], ],
), ),
@ -301,16 +294,24 @@ class _AddTransactionScreenState extends State<AddTransactionScreen> {
}) { }) {
return DropdownButtonFormField<String>( return DropdownButtonFormField<String>(
value: value, value: value,
decoration: InputDecoration(labelText: label),
isExpanded: true, isExpanded: true,
items: isDense: true,
items.map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(),
// 👇 same custom icon here
icon: Image.asset('images/downarrow.png', width: 16, height: 16),
iconSize: 16,
decoration: InputDecoration(labelText: label),
items: items
.map((e) => DropdownMenuItem(value: e, child: Text(e)))
.toList(),
onChanged: onChanged, onChanged: onChanged,
dropdownColor: Colors.white, dropdownColor: Colors.white,
validator: (v) => (v == null || v.isEmpty) ? "Required" : null, validator: (v) => (v == null || v.isEmpty) ? "Required" : null,
); );
} }
Widget buildTextField({ Widget buildTextField({
required String hint, required String hint,
required TextEditingController controller, required TextEditingController controller,

@ -244,126 +244,102 @@ class _FinancialMainScreenState extends State<FinancialMainScreen>
SizedBox(width: 4), SizedBox(width: 4),
Text( Text(
"Create Account", "Create Account",
style: fontTextStyle( style: fontTextStyle(12, const Color(0xFFFFFFFF), FontWeight.w400),
14, const Color(0xFFFFFFFF), FontWeight.w400),
), ),
], ],
), ),
), ),
), ),
// Account Summary (ONLY header + count)
Container( Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
), ),
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Row( Expanded(
child: Text(
"Account Summary",
style: fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
const Expanded( Text(
child: Text( "05",
"Account Summary", style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500),
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.w600),
),
), ),
Column( const SizedBox(height: 2),
children: const [ Text(
Text( "4 active, 1 overdue",
"05", style: fontTextStyle(10, const Color(0xFF646566), FontWeight.w400),
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.blue),
),
SizedBox(height: 2),
Text(
"4 active, 1 overdue",
style: TextStyle(
fontSize: 12,
color: Colors.grey,
),
),
],
), ),
], ],
), ),
const SizedBox(height: 16), ],
Row( ),
children: [ ),
Expanded(
child: Container( const SizedBox(height: 12),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration( // NEW: Balances in a separate container/card
borderRadius: BorderRadius.circular(12), Container(
color: const Color(0xfffafafa), padding: const EdgeInsets.all(16),
),
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: const [ Expanded(
Text( child: Container(
"Receivable Balance", padding: const EdgeInsets.all(12),
style: TextStyle( decoration: BoxDecoration(
fontSize: 12, color: Colors.black54), borderRadius: BorderRadius.circular(12),
), color: const Color(0xffFFFFFF),
SizedBox(height: 4),
Text(
"₹24,000",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.red),
),
Text(
"40.6% of total credit",
style: TextStyle(
fontSize: 11, color: Colors.grey),
),
],
),
),
), ),
const SizedBox(width: 12), child: Column(
Expanded( crossAxisAlignment: CrossAxisAlignment.start,
child: Container( children: [
padding: const EdgeInsets.all(12), Text("Receivable Balance",
decoration: BoxDecoration( style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w500)),
borderRadius: BorderRadius.circular(12), const SizedBox(height: 4),
color: const Color(0xfffafafa), Text("₹24,000",
), style: fontTextStyle(16, Color(0xFFE2483D), FontWeight.w500)),
child: Column( Text("40.6% of total credit",
crossAxisAlignment: CrossAxisAlignment.start, style: fontTextStyle(10, Color(0xFF646566), FontWeight.w400)),
children: const [ ],
Text(
"Advance Balance",
style: TextStyle(
fontSize: 12, color: Colors.black54),
),
SizedBox(height: 4),
Text(
"₹24,000",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.green),
),
Text(
"60.4% of total credit",
style: TextStyle(
fontSize: 11, color: Colors.grey),
),
],
),
),
), ),
], ),
),
const SizedBox(width: 12),
Expanded(
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: const Color(0xffFFFFFF),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Advance Balance",
style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w500)),
const SizedBox(height: 4),
Text("₹24,000",
style: fontTextStyle(16, Color(0xFFE2483D), FontWeight.w500)),
Text("60.4% of total credit",
style: fontTextStyle(10, Color(0xFF646566), FontWeight.w400)),
],
),
),
), ),
], ],
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// Search Bar // Search Bar
@ -386,13 +362,13 @@ class _FinancialMainScreenState extends State<FinancialMainScreen>
), ),
), ),
), ),
IconButton( Image.asset("images/icon_tune.png", width: 24, height: 24),
onPressed: () {}, const SizedBox(width: 16),
icon: const Icon(Icons.sort, color: Colors.grey), Image.asset("images/up_down arrow.png", width: 24, height: 24),
),
], ],
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// Accounts List // Accounts List
@ -462,36 +438,7 @@ class _FinancialMainScreenState extends State<FinancialMainScreen>
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Name + Status // Name + Status
Row( Row( children: [ Expanded( child: Text( name, style: fontTextStyle(14, Color(0xFF2D2E30), FontWeight.w500)), ), Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( color: status == "active" ? Colors.green.withOpacity(0.1) : Colors.red.withOpacity(0.1), borderRadius: BorderRadius.circular(12), ), child: Text( status, style: TextStyle( color: status == "active" ? Colors.green : Colors.redAccent, fontSize: 12, fontWeight: FontWeight.w500, ), ), ) ], ),
children: [
Expanded(
child: Text(
name,
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold),
),
),
Container(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: status == "active"
? Colors.green.withOpacity(0.1)
: Colors.red.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
status,
style: TextStyle(
color:
status == "active" ? Colors.green : Colors.redAccent,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
)
],
),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
orders, orders,

@ -4,6 +4,35 @@ import 'package:flutter/services.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import 'package:supplier_new/resources/drivers_model.dart'; import 'package:supplier_new/resources/drivers_model.dart';
class FirstCharUppercaseFormatter extends TextInputFormatter {
const FirstCharUppercaseFormatter();
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
TextEditingValue newValue,
) {
final text = newValue.text;
if (text.isEmpty) return newValue;
// Find first non-space char
final i = text.indexOf(RegExp(r'\S'));
if (i == -1) return newValue;
final first = text[i];
final upper = first.toUpperCase();
if (first == upper) return newValue;
final newText = text.replaceRange(i, i + 1, upper);
return newValue.copyWith(
text: newText,
selection: newValue.selection,
composing: TextRange.empty,
);
}
}
class ResourcesDriverScreen extends StatefulWidget { class ResourcesDriverScreen extends StatefulWidget {
const ResourcesDriverScreen({super.key}); const ResourcesDriverScreen({super.key});
@ -145,11 +174,11 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
} }
// ---------- bottom sheet ---------- // ---------- bottom sheet ----------
void _openDriverFormSheet(BuildContext context) { Future<void> _openDriverFormSheet(BuildContext context)async {
_resetForm(); // fresh form every time
showModalBottomSheet( await showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, // allow content to move for keyboard isScrollControlled: true,
backgroundColor: Colors.transparent, // style inner container backgroundColor: Colors.transparent, // style inner container
builder: (context) { builder: (context) {
final bottomInset = MediaQuery.of(context).viewInsets.bottom; final bottomInset = MediaQuery.of(context).viewInsets.bottom;
@ -175,7 +204,7 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
Expanded( Expanded(
child: Center( child: Center(
child: Container( child: Container(
width: 36, width: 86,
height: 4, height: 4,
margin: const EdgeInsets.only(bottom: 12), margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -185,10 +214,6 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
), ),
), ),
), ),
IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.close),
),
], ],
), ),
@ -197,6 +222,10 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
child: TextFormField( child: TextFormField(
controller: _nameCtrl, controller: _nameCtrl,
validator: (v) => _required(v, field: "Driver Name"), validator: (v) => _required(v, field: "Driver Name"),
textCapitalization: TextCapitalization.none,
inputFormatters: const [
FirstCharUppercaseFormatter(), // << live first-letter caps
],
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Full Name", hintText: "Full Name",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400), hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
@ -303,6 +332,10 @@ class _ResourcesDriverScreenState extends State<ResourcesDriverScreen> {
child: TextFormField( child: TextFormField(
controller: _locationCtrl, controller: _locationCtrl,
validator: (v) => _required(v, field: "Location"), validator: (v) => _required(v, field: "Location"),
textCapitalization: TextCapitalization.none,
inputFormatters: const [
FirstCharUppercaseFormatter(), // << live first-letter caps
],
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Area / locality", hintText: "Area / locality",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400), hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
@ -679,7 +712,12 @@ class _LabeledField extends StatelessWidget {
final String label; final String label;
final Widget child; final Widget child;
const _LabeledField({required this.label, required this.child}); const _LabeledField({required this.label, required this.child});
String _capFirstWord(String input) {
if (input.isEmpty) return input;
final i = input.indexOf(RegExp(r'\S'));
if (i == -1) return input;
return input.replaceRange(i, i + 1, input[i].toUpperCase());
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
@ -687,7 +725,10 @@ class _LabeledField extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(label, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600)), Text(
_capFirstWord(label),
style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600),
),
const SizedBox(height: 6), const SizedBox(height: 6),
child, child,
], ],

@ -3,12 +3,38 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import 'package:supplier_new/resources/tankers_model.dart'; import 'package:supplier_new/resources/tankers_model.dart';
// Screens (single import each) keep if you actually navigate to these
import 'fleet.dart'; import 'fleet.dart';
import 'resources_drivers.dart'; import 'resources_drivers.dart';
import 'resources_sources.dart'; import 'resources_sources.dart';
class FirstCharUppercaseFormatter extends TextInputFormatter {
const FirstCharUppercaseFormatter();
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
TextEditingValue newValue,
) {
final text = newValue.text;
if (text.isEmpty) return newValue;
// Find first non-space char
final i = text.indexOf(RegExp(r'\S'));
if (i == -1) return newValue;
final first = text[i];
final upper = first.toUpperCase();
if (first == upper) return newValue;
final newText = text.replaceRange(i, i + 1, upper);
return newValue.copyWith(
text: newText,
selection: newValue.selection,
composing: TextRange.empty,
);
}
}
void main() => runApp(const MaterialApp(home: ResourcesFleetScreen())); void main() => runApp(const MaterialApp(home: ResourcesFleetScreen()));
class ResourcesFleetScreen extends StatefulWidget { class ResourcesFleetScreen extends StatefulWidget {
@ -169,10 +195,8 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
} }
} }
void openTankerSimpleSheet(BuildContext context) { Future<void> openTankerSimpleSheet(BuildContext context) async {
_resetForm(); // open fresh await showModalBottomSheet(
showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
@ -194,11 +218,33 @@ class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Row(
children: [
Expanded(
child: Center(
child: Container(
width: 86,
height: 4,
margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: const Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(2),
),
),
),
),
],
),
_LabeledField( _LabeledField(
label: "Tanker Name *", label: "Tanker Name *",
child: TextFormField( child: TextFormField(
controller: _nameCtrl, controller: _nameCtrl,
validator: (v) => _required(v, field: "Tanker Name"), validator: (v) => _required(v, field: "Tanker Name"),
textCapitalization: TextCapitalization.none,
inputFormatters: const [
FirstCharUppercaseFormatter(), // << live first-letter caps
],
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Enter Tanker Name", hintText: "Enter Tanker Name",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400), hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
@ -722,6 +768,13 @@ class _LabeledField extends StatelessWidget {
const _LabeledField({required this.label, required this.child}); const _LabeledField({required this.label, required this.child});
String _capFirstWord(String input) {
if (input.isEmpty) return input;
final i = input.indexOf(RegExp(r'\S'));
if (i == -1) return input;
return input.replaceRange(i, i + 1, input[i].toUpperCase());
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
@ -729,7 +782,10 @@ class _LabeledField extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(label, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600)), Text(
_capFirstWord(label),
style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600),
),
const SizedBox(height: 6), const SizedBox(height: 6),
child, child,
], ],

@ -4,12 +4,42 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:supplier_new/common/settings.dart'; import 'package:supplier_new/common/settings.dart';
import 'package:supplier_new/resources/source_loctaions_model.dart'; import 'package:supplier_new/resources/source_loctaions_model.dart';
import '../google_maps_place_picker_mb/src/models/pick_result.dart';
import '../google_maps_place_picker_mb/src/place_picker.dart';
import 'package:supplier_new/google_maps_place_picker_mb/google_maps_place_picker.dart';
import 'dart:io' show File, Platform;
import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:location/location.dart' as locationmap;
// If you use the PlacePicker flow in the button below, make sure you have class FirstCharUppercaseFormatter extends TextInputFormatter {
// the needed imports in your project (google_maps_flutter, place_picker, etc). const FirstCharUppercaseFormatter();
// import 'package:google_maps_flutter/google_maps_flutter.dart';
// import 'package:place_picker/place_picker.dart'; @override
// import 'package:location/location.dart'; TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
TextEditingValue newValue,
) {
final text = newValue.text;
if (text.isEmpty) return newValue;
// Find first non-space char
final i = text.indexOf(RegExp(r'\S'));
if (i == -1) return newValue;
final first = text[i];
final upper = first.toUpperCase();
if (first == upper) return newValue;
final newText = text.replaceRange(i, i + 1, upper);
return newValue.copyWith(
text: newText,
selection: newValue.selection,
composing: TextRange.empty,
);
}
}
void main() => runApp(const MaterialApp(home: ResourcesSourceScreen())); void main() => runApp(const MaterialApp(home: ResourcesSourceScreen()));
@ -20,6 +50,38 @@ class ResourcesSourceScreen extends StatefulWidget {
State<ResourcesSourceScreen> createState() => _ResourcesSourceScreenState(); State<ResourcesSourceScreen> createState() => _ResourcesSourceScreenState();
} }
PickResult? selectedPlace;
bool _mapsInitialized = false;
final String _mapsRenderer = "latest";
var kInitialPosition = const LatLng(15.462477, 78.717401);
locationmap.Location location = locationmap.Location();
final GoogleMapsFlutterPlatform mapsImplementation =
GoogleMapsFlutterPlatform.instance;
void initRenderer() {
if (_mapsInitialized) return;
if (mapsImplementation is GoogleMapsFlutterAndroid) {
switch (_mapsRenderer) {
case "legacy":
(mapsImplementation as GoogleMapsFlutterAndroid)
.initializeWithRenderer(AndroidMapRenderer.legacy);
break;
case "latest":
(mapsImplementation as GoogleMapsFlutterAndroid)
.initializeWithRenderer(AndroidMapRenderer.latest);
break;
}
}
// setState(() {
// _mapsInitialized = true;
// });
}
class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> { class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
int selectedTab = 2; int selectedTab = 2;
String search = ''; String search = '';
@ -35,9 +97,6 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
String? selectedWaterType; String? selectedWaterType;
final List<String> waterTypes = const ['Drinking water', 'Bore water', 'Both']; final List<String> waterTypes = const ['Drinking water', 'Bore water', 'Both'];
// Optional: values used by your map flow
// final location = Location(); // from 'location' package
// PickResult? selectedPlace;
double? lat; double? lat;
double? lng; double? lng;
String? address; String? address;
@ -146,12 +205,11 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
} }
} }
void _openSourceFormSheet(BuildContext context) { Future<void> _openSourceFormSheet(BuildContext context)async {
_resetForm(); // fresh form each time you open await showModalBottomSheet(
showModalBottomSheet( context: context,
context: context, isScrollControlled: true,
isScrollControlled: true, backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent,
builder: (context) { builder: (context) {
final kbInset = MediaQuery.of(context).viewInsets.bottom; final kbInset = MediaQuery.of(context).viewInsets.bottom;
return FractionallySizedBox( return FractionallySizedBox(
@ -169,11 +227,33 @@ class _ResourcesSourceScreenState extends State<ResourcesSourceScreen> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Row(
children: [
Expanded(
child: Center(
child: Container(
width: 86,
height: 4,
margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: const Color(0xFFE0E0E0),
borderRadius: BorderRadius.circular(2),
),
),
),
),
],
),
_LabeledField( _LabeledField(
label: "Location Name *", label: "Location Name *",
child: TextFormField( child: TextFormField(
controller: _locationNameController, controller: _locationNameController,
validator: (v) => _required(v, field: "Location Name"), validator: (v) => _required(v, field: "Location Name"),
textCapitalization: TextCapitalization.none,
inputFormatters: const [
FirstCharUppercaseFormatter(), // << live first-letter caps
],
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Location Name", hintText: "Location Name",
hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400), hintStyle: fontTextStyle(14, const Color(0xFF939495), FontWeight.w400),
@ -634,6 +714,13 @@ class _LabeledField extends StatelessWidget {
const _LabeledField({required this.label, required this.child}); const _LabeledField({required this.label, required this.child});
String _capFirstWord(String input) {
if (input.isEmpty) return input;
final i = input.indexOf(RegExp(r'\S'));
if (i == -1) return input;
return input.replaceRange(i, i + 1, input[i].toUpperCase());
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
@ -641,7 +728,10 @@ class _LabeledField extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(label, style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600)), Text(
_capFirstWord(label),
style: fontTextStyle(12, const Color(0xFF515253), FontWeight.w600),
),
const SizedBox(height: 6), const SizedBox(height: 6),
child, child,
], ],

Loading…
Cancel
Save