Prioritize either Girona or Dali
While it may be possible to combine Girona and Figueres in a day, I do not recommend it. Girona deserves one full day and here is an itinerary for one day in Girona. If you are a Dali fan, then go on a Dali Triangle tour and skip Girona.
If you plan to combine both Girona and Figueres, be prepared for a long day. Plan it out well, especially the train schedules. And book tickets in advance; Barcelona Sants has a long line for tickets as do Dali Museum!
How to get there
Girona and Figueres are both on the same fast train AVE line from Sants stations in Barcelona. Trains leave more or less every hour, Girona is 40 minutes from Barcelona while Figueres is just another 20 minutes away. There are also slower (media distancia and regional) services between Girona and Figueres that take 30 minutes.
First, go to Figueres
My suggestion is first to go from Barcelona to Figueres, then visit Girona on the way back later in the day without any time constraints. The Dali Theatre-Museum is open 9am to 8pm in the summer with shorter fall and winter hours from 1030 to 6pm. August also has a great night visit option (10pm to 1am). Book your Dali museum tickets in advance because entry is timed and tickets sell fast. Keep 20 minutes to walk between Figueres Vilafant station and the museum. Plan to leave on an early train from Barcelona Sants.
From Figueres go to Girona and keep in mind that you will take 15 minutes to walk from the Girona station to the old city where the meat of the action is! Girona is a simply breathtaking visit and you should take your time to absorb the history, culture, architecture, Catalan pride, and food, all in a day or less in this case. It is possible if you know how to plan your day in Girona.
Make sure to stay in Girona till late, after all, you will be back in Barcelona in under 40 minutes. The last AVE for Barcelona leaves Girona at around 9 pm.