fix localprofile button

This commit is contained in:
J. A. Messias 2024-12-04 17:02:17 -03:00
parent b8c2aab73c
commit 6e100c84ce
1 changed files with 82 additions and 82 deletions

View File

@ -21,13 +21,18 @@ class LocalProfileComponentWidget extends StatefulWidget {
} }
class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidget> { class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidget> {
bool _isLoading = false;
Future retrieveProfileInfo() async {
setState(() {_isLoading = true;});
Future callback() async {
await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); await StorageHelper().set(KeychainStorageKey.clientUUID.value, '');
LocalsRepositoryImpl.license.add(false); LocalsRepositoryImpl.license.add(false);
final response = await LocalsRepositoryImpl().update(context); final response = await LocalsRepositoryImpl().update(context);
LocalsRepositoryImpl.license.add(response); LocalsRepositoryImpl.license.add(response);
setState(() {_isLoading = false;});
} }
@override @override
@ -58,7 +63,7 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
return BlocBuilder<LocalProfileBloc, LocalProfileState>( return BlocBuilder<LocalProfileBloc, LocalProfileState>(
builder: (context, state) { builder: (context, state) {
return _buildAsyncLocalProfile(context, state, limitedFontSize, callback); return _buildAsyncLocalProfile(context, state, limitedFontSize);
}, },
); );
@ -96,12 +101,7 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
focusColor: Colors.transparent, focusColor: Colors.transparent,
hoverColor: Colors.transparent, hoverColor: Colors.transparent,
highlightColor: Colors.transparent, highlightColor: Colors.transparent,
onTap: () async { onTap: _isLoading ? null : retrieveProfileInfo,
await StorageHelper().set(KeychainStorageKey.clientUUID.value, '');
LocalsRepositoryImpl.license.add(false);
final response = await LocalsRepositoryImpl().update(context);
LocalsRepositoryImpl.license.add(response);
},
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(200.0), borderRadius: BorderRadius.circular(200.0),
child: CachedNetworkImage( child: CachedNetworkImage(
@ -157,96 +157,96 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
); );
} }
Container _buildAsyncLocalProfile(BuildContext context, LocalProfileState state, double limitedFontSize, Future Function() callback) { Container _buildAsyncLocalProfile(BuildContext context, LocalProfileState state, double limitedFontSize) {
return Container( return Container(
decoration: const BoxDecoration(), decoration: const BoxDecoration(),
child: Align( child: Align(
alignment: const AlignmentDirectional(0.0, -1.0), alignment: const AlignmentDirectional(0.0, -1.0),
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
elevation: 0.0, elevation: 0.0,
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: 119.0, height: 119.0,
decoration: BoxDecoration( decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).primary,
border: Border.all(
color: FlutterFlowTheme.of(context).primary, color: FlutterFlowTheme.of(context).primary,
border: Border.all(
color: FlutterFlowTheme.of(context).primary,
),
), ),
), child: Row(
child: Row( mainAxisSize: MainAxisSize.max,
mainAxisSize: MainAxisSize.max, children: [
children: [ Align(
Align( alignment: const AlignmentDirectional(-1.0, 0.0),
alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding(
child: Padding( padding: const EdgeInsets.all(2.0),
padding: const EdgeInsets.all(2.0), child: InkWell(
child: InkWell( splashColor: Colors.transparent,
splashColor: Colors.transparent, focusColor: Colors.transparent,
focusColor: Colors.transparent, hoverColor: Colors.transparent,
hoverColor: Colors.transparent, highlightColor: Colors.transparent,
highlightColor: Colors.transparent, onTap: _isLoading ? null : retrieveProfileInfo,
onTap: callback, child: ClipRRect(
child: ClipRRect( borderRadius: BorderRadius.circular(200.0),
borderRadius: BorderRadius.circular(200.0), child: CachedNetworkImage(
child: CachedNetworkImage( imageBuilder: (context, imageProvider) => Container(
imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration(
decoration: BoxDecoration( image: DecorationImage(
image: DecorationImage( image: imageProvider,
image: imageProvider, fit: BoxFit.cover,
fit: BoxFit.cover, ),
), ),
), ),
imageUrl: valueOrDefault('https://freaccess.com.br/freaccess/Images/Clients/${state.cliUUID}.png', 'assets/images/home.png'),
width: 80.0,
height: 80.0,
fit: BoxFit.cover,
alignment: const Alignment(0.0, 0.0),
placeholder: (context, url) => Image.asset('assets/images/home.png'),
errorListener: (_) => Image.asset('assets/images/home.png'),
errorWidget: (_, __, ___) => Image.asset('assets/images/home.png'),
), ),
imageUrl: valueOrDefault('https://freaccess.com.br/freaccess/Images/Clients/${state.cliUUID}.png', 'assets/images/home.png'), )),
width: 80.0,
height: 80.0,
fit: BoxFit.cover,
alignment: const Alignment(0.0, 0.0),
placeholder: (context, url) => Image.asset('assets/images/home.png'),
errorListener: (_) => Image.asset('assets/images/home.png'),
errorWidget: (_, __, ___) => Image.asset('assets/images/home.png'),
),
)),
),
),
Expanded(
child: Tooltip(
message: valueOrDefault<String>(
convertToUppercase(state.cliName),
FFLocalizations.of(context).getVariableText(
ptText: 'SEM LOCAL VINCULADO',
enText: 'NO LINKED LOCAL',
),
), ),
child: Text( ),
valueOrDefault<String>( Expanded(
child: Tooltip(
message: valueOrDefault<String>(
convertToUppercase(state.cliName), convertToUppercase(state.cliName),
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'SEM LOCAL VINCULADO', ptText: 'SEM LOCAL VINCULADO',
enText: 'NO LINKED LOCAL', enText: 'NO LINKED LOCAL',
), ),
), ),
overflow: TextOverflow.ellipsis, child: Text(
maxLines: 1, valueOrDefault<String>(
style: FlutterFlowTheme.of(context).labelMedium.override( convertToUppercase(state.cliName),
fontFamily: 'Nunito', FFLocalizations.of(context).getVariableText(
color: FlutterFlowTheme.of(context).info, ptText: 'SEM LOCAL VINCULADO',
fontSize: limitedFontSize, enText: 'NO LINKED LOCAL',
letterSpacing: 0.0,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
), ),
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: FlutterFlowTheme.of(context).labelMedium.override(
fontFamily: 'Nunito',
color: FlutterFlowTheme.of(context).info,
fontSize: limitedFontSize,
letterSpacing: 0.0,
fontWeight: FontWeight.w500,
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
),
),
), ),
), ),
), ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)),
].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), ),
), ),
), ),
), ),
), );
);
}
}
} }