riverscuomo / spotkin_flutter

A front end for Spotkin server
https://spotkin.web.app
7 stars 4 forks source link

improve spotkin update button jpg #39

Closed riverscuomo closed 1 month ago

riverscuomo commented 1 month ago

Image.asset( 'assets/images/updatespotkinbutton.jpg', fit: BoxFit.cover, errorBuilder: (context, error, stackTrace) => _buildDefaultIcon(), ),

taylorlee3 commented 1 month ago

@riverscuomo thoughts?

Screenshot 2024-08-09 153234

import 'package:flutter/material.dart';

class SpotifyButton extends StatelessWidget {
  final String? imageUrl;
  final VoidCallback onPressed;
  final bool isProcessing;
  final void Function() processJobs;

  const SpotifyButton({
    Key? key,
    this.imageUrl,
    required this.onPressed,
    required this.isProcessing,
    required this.processJobs,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ConstrainedBox(
      constraints: const BoxConstraints(minWidth: 80, minHeight: 110),
      child: ElevatedButton(
        onPressed: isProcessing ? null : processJobs,
        style: ElevatedButton.styleFrom(
          backgroundColor: Colors.green[400],
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(20),
          ),
          padding: const EdgeInsets.symmetric(vertical: 8),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              width: 50,
              height: 50,
              child: Center(
                child: isProcessing
                    ? const SizedBox(
                        width: 30,
                        height: 30,
                        child: CircularProgressIndicator(
                          valueColor:
                              AlwaysStoppedAnimation<Color>(Colors.white),
                          strokeWidth: 2,
                        ),
                      )
                    : CircleAvatar(
                        radius: 25,
                        backgroundImage:
                            imageUrl != null ? NetworkImage(imageUrl!) : null,
                        backgroundColor: Colors.green[400],
                        child: imageUrl == null
                            ? Image.asset(
                                'assets/images/transparent_spotkin.png',
                                fit: BoxFit.cover,
                                errorBuilder: (context, error, stackTrace) =>
                                    _buildDefaultIcon(),
                              )
                            : null,
                      ),
              ),
            ),
            const SizedBox(height: 8),
            Text(
              isProcessing ? 'Processing...' : 'Update',
              style: const TextStyle(fontWeight: FontWeight.bold),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildDefaultIcon() {
    return const Icon(
      Icons.music_note,
      color: Colors.white,
      size: 30,
    );
  }
}