Tesis 1.0.0
Loading...
Searching...
No Matches
TicketDetailDialogFragment.java
Go to the documentation of this file.
1package com.example.food_front;
2
3import android.app.Dialog;
4import android.os.Bundle;
5import android.view.LayoutInflater;
6import android.view.View;
7import android.view.ViewGroup;
8import android.widget.LinearLayout;
9import android.widget.TextView;
10import androidx.annotation.NonNull;
11import androidx.annotation.Nullable;
12import androidx.fragment.app.DialogFragment;
13
14public class TicketDetailDialogFragment extends DialogFragment {
15 private String fecha;
16 private String nroPedido;
17 private String metodoPago;
18 private String total;
19
20 public static TicketDetailDialogFragment newInstance(String fecha, String nroPedido, String metodoPago, String total, String productos) {
22 Bundle args = new Bundle();
23 args.putString("fecha", fecha);
24 args.putString("nroPedido", nroPedido);
25 args.putString("metodoPago", metodoPago);
26 args.putString("total", total);
27 args.putString("productos", productos);
28 fragment.setArguments(args);
29 return fragment;
30 }
31
32 private String productos;
33
34 @Nullable
35 @Override
36 public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
37 if (getArguments() != null) {
38 fecha = getArguments().getString("fecha", "-");
39 nroPedido = getArguments().getString("nroPedido", "-");
40 metodoPago = getArguments().getString("metodoPago", "-");
41 total = getArguments().getString("total", "-");
42 productos = getArguments().getString("productos", "-");
43 }
44 LinearLayout layout = new LinearLayout(requireContext());
45 layout.setOrientation(LinearLayout.VERTICAL);
46 layout.setPadding(64, 64, 64, 64); // Más grande
47 layout.setBackgroundColor(android.graphics.Color.WHITE);
48 layout.setMinimumWidth(900); // Más ancho
49 layout.setMinimumHeight(900); // Más alto
50
51 TextView title = new TextView(requireContext());
52 title.setText("Detalles del Ticket");
53 title.setTextSize(24);
54 title.setTypeface(null, android.graphics.Typeface.BOLD);
55 title.setTextColor(android.graphics.Color.BLACK);
56 layout.addView(title);
57
58 TextView tvFecha = new TextView(requireContext());
59 tvFecha.setText("Fecha: " + fecha);
60 layout.addView(tvFecha);
61
62 TextView tvNro = new TextView(requireContext());
63 tvNro.setText("N° Pedido: " + nroPedido);
64 layout.addView(tvNro);
65
66 TextView tvPago = new TextView(requireContext());
67 tvPago.setText("Método de pago: " + metodoPago);
68 layout.addView(tvPago);
69
70 TextView tvTotal = new TextView(requireContext());
71 tvTotal.setText("Total: $ " + total);
72 layout.addView(tvTotal);
73
74 // Productos reales
75 TextView tvProductos = new TextView(requireContext());
76 tvProductos.setText("Productos:\n" + productos);
77 layout.addView(tvProductos);
78
79 TextView tvGracias = new TextView(requireContext());
80 tvGracias.setText("¡Gracias por tu compra!");
81 tvGracias.setTextColor(android.graphics.Color.parseColor("#388E3C"));
82 tvGracias.setTextSize(18);
83 tvGracias.setPadding(0, 24, 0, 0);
84 layout.addView(tvGracias);
85
86 return layout;
87 }
88
89 @Override
90 public Dialog onCreateDialog(Bundle savedInstanceState) {
91 Dialog dialog = super.onCreateDialog(savedInstanceState);
92 dialog.setTitle("Detalles del Ticket");
93 return dialog;
94 }
95}
View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
static TicketDetailDialogFragment newInstance(String fecha, String nroPedido, String metodoPago, String total, String productos)